device_manage_page.dart 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. import 'package:deus_app/common/style/TitleBar.dart';
  2. import 'package:deus_app/common/style/gsy_style.dart';
  3. import 'package:deus_app/common/utils/ConstantString.dart';
  4. import 'package:deus_app/common/utils/ToastUtils.dart';
  5. import 'package:deus_app/widget/MyDrawer.dart';
  6. import 'package:flutter/cupertino.dart';
  7. import 'package:flutter/material.dart';
  8. import 'package:pull_to_refresh/pull_to_refresh.dart';
  9. class DeviceManagePage extends StatefulWidget {
  10. static var routeName = '/DeviceManagePage';
  11. const DeviceManagePage({super.key});
  12. @override
  13. State createState() {
  14. return _DeviceManage();
  15. }
  16. }
  17. class _DeviceManage extends State<DeviceManagePage> {
  18. String deviceNum = "0";
  19. final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>();
  20. RefreshController _refreshController =
  21. RefreshController(initialRefresh: false);
  22. void _onRefresh() async {
  23. // monitor network fetch
  24. await Future.delayed(Duration(milliseconds: 1000));
  25. // if failed,use refreshFailed()
  26. _refreshController.refreshCompleted();
  27. }
  28. void _onLoading() async {
  29. // monitor network fetch
  30. await Future.delayed(Duration(milliseconds: 1000));
  31. // if failed,use loadFailed(),if no data return,use LoadNodata()
  32. // items.add((items.length+1).toString());
  33. if (mounted) setState(() {});
  34. _refreshController.loadComplete();
  35. }
  36. @override
  37. Widget build(BuildContext contexts) {
  38. return Scaffold(
  39. key: _scaffoldKey,
  40. appBar: TitleBar().drawAppBar(ConstantString.deviceManageText, () {
  41. _scaffoldKey.currentState?.openEndDrawer();
  42. }),
  43. backgroundColor: const Color(0xfff2f2f2),
  44. endDrawer: MyDrawer(
  45. callback: (index, str) {
  46. showToast(str);
  47. },
  48. ),
  49. //抽屉
  50. body: Column(
  51. children: [
  52. SizedBox(
  53. height: 10,
  54. ),
  55. Row(
  56. mainAxisAlignment: MainAxisAlignment.start,
  57. children: [
  58. SizedBox(
  59. width: 15,
  60. ),
  61. Text(ConstantString.deviceNum,
  62. style: GSYConstant.smallActionLightText),
  63. Text(deviceNum, style: GSYConstant.normalTextBigWhiteBold),
  64. ],
  65. ),
  66. Expanded(
  67. child: SmartRefresher(
  68. enablePullDown: true,
  69. enablePullUp: true,
  70. header: WaterDropHeader(),
  71. footer: CustomFooter(
  72. builder: (BuildContext context, LoadStatus? mode) {
  73. Widget body;
  74. if (mode == LoadStatus.idle) {
  75. body = Text("上拉加载");
  76. } else if (mode == LoadStatus.loading) {
  77. body = CupertinoActivityIndicator();
  78. } else if (mode == LoadStatus.failed) {
  79. body = Text("加载失败!点击重试!");
  80. } else if (mode == LoadStatus.canLoading) {
  81. body = Text("松手,加载更多!");
  82. } else {
  83. body = Text("没有更多数据了!");
  84. }
  85. return Container(
  86. height: 55.0,
  87. child: Center(child: body),
  88. );
  89. },
  90. ),
  91. controller: _refreshController,
  92. onRefresh: _onRefresh,
  93. onLoading: _onLoading,
  94. child: ListView.builder(
  95. itemCount: 20,
  96. itemBuilder: (context, index) {
  97. return Container(
  98. margin: EdgeInsets.only(top: 12, left: 10, right: 10),
  99. padding: EdgeInsets.only(top: 12, bottom: 10),
  100. color: Colors.white,
  101. child: ListTile(
  102. title: Column(
  103. children: [
  104. Row(
  105. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  106. children: [
  107. Container(
  108. child: Text(
  109. '此处展示设备名称',
  110. style: TextStyle(
  111. color: Colors.black,
  112. fontSize: GSYConstant.middleTextWhiteSize,
  113. fontWeight: FontWeight.bold,
  114. ),
  115. ),
  116. ),
  117. Container(
  118. padding: EdgeInsets.only(
  119. top: 3, bottom: 3, left: 5, right: 5),
  120. child: Text(
  121. '运行中',
  122. textAlign: TextAlign.right,
  123. style: TextStyle(
  124. color: Colors.blue,
  125. fontSize: GSYConstant.minTextSize,
  126. ),
  127. ),
  128. decoration: BoxDecoration(
  129. border: new Border.all(
  130. color: Colors.blue, //边框颜色
  131. width: 1.0, //边框粗细
  132. ),
  133. borderRadius: const BorderRadius.all(
  134. const Radius.circular(3.0)), //边框的弧度
  135. ),
  136. )
  137. ]),
  138. SizedBox(
  139. height: 12,
  140. ),
  141. Row(
  142. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  143. children: [
  144. Container(
  145. child: Text(
  146. 'devicekey:',
  147. style: TextStyle(
  148. color: GSYColors.primaryLightValue,
  149. fontSize: GSYConstant.middleTextWhiteSize,
  150. ),
  151. ),
  152. ),
  153. Container(
  154. child: Text(
  155. 'devicekey',
  156. textAlign: TextAlign.right,
  157. style: TextStyle(
  158. color: GSYColors.primaryLightValue,
  159. fontSize: GSYConstant.middleTextWhiteSize,
  160. ),
  161. ),
  162. ),
  163. ]),
  164. SizedBox(
  165. height: 10,
  166. ),
  167. Row(
  168. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  169. children: [
  170. Container(
  171. child: Text(
  172. 'IMEI:',
  173. style: TextStyle(
  174. color: GSYColors.primaryLightValue,
  175. fontSize: GSYConstant.middleTextWhiteSize,
  176. ),
  177. ),
  178. ),
  179. Container(
  180. child: Text(
  181. 'IMEI',
  182. textAlign: TextAlign.right,
  183. style: TextStyle(
  184. color: GSYColors.primaryLightValue,
  185. fontSize: GSYConstant.middleTextWhiteSize,
  186. ),
  187. ),
  188. ),
  189. ]),
  190. SizedBox(
  191. height: 5,
  192. ),
  193. ],
  194. ),
  195. onTap: () {
  196. Scaffold.of(context).openEndDrawer();
  197. },
  198. ));
  199. },
  200. ),
  201. ))
  202. ],
  203. ),
  204. );
  205. }
  206. }