| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- import 'package:deus_app/common/style/TitleBar.dart';
- import 'package:deus_app/common/style/gsy_style.dart';
- import 'package:deus_app/common/utils/DioUtil.dart';
- import 'package:deus_app/common/utils/LoadingDialogHelper.dart';
- import 'package:deus_app/common/utils/ToastUtils.dart';
- import 'package:deus_app/generated/json/equipment_info_entity_helper.dart';
- import 'package:deus_app/model/equipment_info_entity.dart';
- import 'package:deus_app/page/device/device_manage_update_page.dart';
- import 'package:flutter/material.dart';
- class DeviceManageDetailPage extends StatefulWidget {
- final EquipmentInfoData data;
- const DeviceManageDetailPage({super.key, required this.data});
- @override
- State createState() {
- return _DeviceManageDetailPage(data);
- }
- }
- class _DeviceManageDetailPage extends State<DeviceManageDetailPage> {
- EquipmentInfoData data;
- _DeviceManageDetailPage(this.data);
- var _event;
- @override
- Widget build(BuildContext context) {
- // TODO: implement build
- return Scaffold(
- appBar: TitleBar().backAppbar(context, "设备详情"),
- backgroundColor: const Color(0xfff2f2f2),
- body: ListView(children: _Ws()));
- }
- List<Widget> _Ws() {
- List<Widget> ws = [];
- ws.add(_deviceDetail());
- ws.add(_deviceList());
- return ws;
- }
- Widget _deviceDetail() {
- return Column(children: [
- Container(
- decoration: BoxDecoration(color: Colors.white),
- padding: EdgeInsets.only(bottom: 15, top: 15, left: 12, right: 12),
- margin: EdgeInsets.only(bottom: 15),
- child: Column(
- children: [
- Row(
- children: [
- Container(
- // padding: EdgeInsets.fromLTRB(12, 0, 0, 0),
- alignment: Alignment.bottomLeft,
- child: Text(
- data.showName,
- style: TextStyle(
- fontSize: GSYConstant.middleTextWhiteSize,
- fontWeight: FontWeight.bold),
- ),
- ),
- Container(
- margin: EdgeInsets.only(left: 10),
- padding: EdgeInsets.fromLTRB(3, 2, 3, 2),
- alignment: Alignment.centerLeft,
- child: Text(
- data.status == 0
- ? '在线'
- : data.status == 1
- ? '离线'
- : data.status == 2
- ? '未激活'
- : '未知',
- style: TextStyle(
- fontSize: GSYConstant.minTextSize,
- color: data.status == 2
- ? Colors.red
- : data.status == 1
- ? Colors.orange
- : data.status == 0
- ? Colors.blue
- : Colors.black),
- ),
- decoration: BoxDecoration(
- border: new Border.all(
- color: data.status == 2
- ? Colors.red
- : data.status == 1
- ? Colors.orange
- : data.status == 0
- ? Colors.blue
- : Colors.black, //边框颜色
- width: 1.0, //边框粗细
- ),
- borderRadius: const BorderRadius.all(
- const Radius.circular(3.0)), //边框的弧度
- ),
- )
- ],
- ),
- Container(
- padding: EdgeInsets.only(top: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text(
- '产品名称:',
- style: GSYConstant.smallTextLight,
- ),
- Container(
- child: Text(
- data.productName,
- style: GSYConstant.smallTextLight,
- textAlign: TextAlign.right,
- ),
- ),
- ])),
- Container(
- padding: EdgeInsets.only(top: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text(
- '激活时间:',
- style: GSYConstant.smallTextLight,
- ),
- Container(
- child: Text(
- data.activationOn,
- style: GSYConstant.smallTextLight,
- textAlign: TextAlign.right,
- ),
- ),
- ])),
- Container(
- padding: EdgeInsets.only(top: 15),
- child: Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text(
- '最后上线时间:',
- style: GSYConstant.smallTextLight,
- ),
- Container(
- child: Text(
- data.lastOnlineOn,
- style: GSYConstant.smallTextLight,
- textAlign: TextAlign.right,
- ),
- ),
- ])),
- ],
- ),
- ),
- ]);
- }
- Widget _deviceList() {
- return Column(
- children: [
- Container(
- decoration: BoxDecoration(color: Colors.white),
- padding: const EdgeInsets.fromLTRB(12, 15, 12, 15),
- child: Column(
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- const Text("设备参数", style: TextStyle(
- fontSize: GSYConstant.middleTextWhiteSize,
- fontWeight: FontWeight.bold)),
- GestureDetector(
- child: const Text("修改参数",
- style: TextStyle(
- fontSize: GSYConstant.middleTextWhiteSize,
- color: Colors.blue),
- textAlign: TextAlign.right),
- onTap: () {
- Navigator.push(
- context,
- MaterialPageRoute(
- builder: (context) => DeviceManageUpdatePage(data:data)));
- },
- )
- ],
- ),
- SizedBox(
- height: 15,
- ),
- Container(
- alignment: Alignment.centerLeft,
- child: Text('当前设备已设置的参数如下:', style: GSYConstant.smallTextBold),
- ),
- SizedBox(
- height: 15,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text('A侧速度:', style: GSYConstant.smallTextLight),
- new Text(data.speedA, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
- ],
- ),
- SizedBox(
- height: 15,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text('B侧速度:', style: GSYConstant.smallTextLight),
- new Text(data.speedB, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
- ],
- ),
- SizedBox(
- height: 15,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text('A侧纤度:', style: GSYConstant.smallTextLight),
- new Text(data.finenessA, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
- ],
- ),
- SizedBox(
- height: 15,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text('B侧纤度:', style: GSYConstant.smallTextLight),
- new Text(data.finenessB, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
- ],
- ),
- SizedBox(
- height: 15,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text('A侧孔数:', style: GSYConstant.smallTextLight),
- new Text(data.holeCountA, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
- ],
- ),
- SizedBox(
- height: 15,
- ),
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- new Text('B侧孔数:', style: GSYConstant.smallTextLight),
- new Text(data.holeCountB, style: GSYConstant.smallTextLight,textAlign: TextAlign.right),
- ],
- )
- ],
- ))
- ],
- );
- }
- @override
- void initState() {
- super.initState();
- _event = eventBus.on<Object>().listen((event) {
- setState(() {
- equipmentInfo(data.id);
- });
- });
- }
- equipmentInfo(int id) async{
- LoadingDialogHelper.showLoading(context);
- var result = await DioUtil().request("equipment/equipmentInfo",method: DioMethod.get,params: {'id':id});
- EquipmentInfoEntity entity=equipmentInfoEntityFromJson(EquipmentInfoEntity(), result);
- LoadingDialogHelper.dismissLoading(context);
- if (entity.code == 0) {
- setState(() {
- data=entity.data;
- });
- } else {
- showToast(entity.msg);
- }
- }
- @override
- void dispose() {
- // TODO: implement dispose
- super.dispose();
- _event.cancel();
- }
- }
|