heavy_lift_list_page.dart 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/internal/heavy/provider/heavy_lift_list_provider.dart';
  3. import 'package:liftmanager/internal/lift/model/lift_list_entity.dart';
  4. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  5. import 'package:liftmanager/mvp/base_page_state.dart';
  6. import 'package:liftmanager/res/resources.dart';
  7. import 'package:liftmanager/widgets/app_bar.dart';
  8. import 'package:liftmanager/widgets/my_refresh_list.dart';
  9. import 'package:liftmanager/widgets/search_bar.dart';
  10. import 'package:liftmanager/widgets/state_layout.dart';
  11. import 'package:provider/provider.dart' as p;
  12. class HeavyLiftListPage extends StatefulWidget {
  13. HeavyLiftListPage(this.projectId);
  14. final String projectId;
  15. @override
  16. HeavyLiftListPageState createState() => HeavyLiftListPageState();
  17. }
  18. class HeavyLiftListPageState extends BasePageState<HeavyLiftListPage, HeavyLiftListPresenter> {
  19. BaseListProvider<LiftListItem> provider = BaseListProvider<LiftListItem>();
  20. String _keyword = "";
  21. int _page = 1;
  22. @override
  23. void initState() {
  24. /// 默认为加载中状态,本页面场景默认为空
  25. provider.setStateTypeNotNotify(StateType.loading);
  26. super.initState();
  27. _onRefresh();
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. return p.ChangeNotifierProvider<BaseListProvider<LiftListItem>>(
  32. create: (_) => provider,
  33. child: Scaffold(
  34. appBar: MyAppBar(
  35. centerTitle: "大修电梯列表",
  36. ),
  37. body: Container(
  38. color: Color(0xFFF1F4FC),
  39. child: Column(
  40. crossAxisAlignment: CrossAxisAlignment.start,
  41. children: <Widget>[
  42. Container(
  43. color: Colors.white,
  44. padding:
  45. EdgeInsets.only(top: 10, bottom: 10, left: 15, right: 15),
  46. child: SearchBar(
  47. autofocus: false,
  48. hintText: "搜索电梯",
  49. onPressed: (text) {
  50. print(widget.projectId);
  51. _keyword = text;
  52. provider.setStateType(StateType.loading);
  53. _page = 1;
  54. presenter.searchLift(context,
  55. widget.projectId, _keyword, _page, true);
  56. },
  57. ),
  58. ),
  59. Expanded(
  60. flex: 1,
  61. child: p.Consumer<BaseListProvider<LiftListItem>>(
  62. builder: (_, provider, __) {
  63. return MyListView(
  64. key: Key('lift_list'),
  65. itemCount: provider.list.length,
  66. stateType: provider.stateType,
  67. onRefresh: _onRefresh,
  68. loadMore: _loadMore,
  69. // itemExtent: 67.0,
  70. hasMore: provider.hasMore,
  71. itemBuilder: (_, index) {
  72. return Container(
  73. margin: EdgeInsets.fromLTRB(15, 5, 15, 5),
  74. decoration: BoxDecoration(
  75. color: Colors.white,
  76. borderRadius: BorderRadius.circular(6.0),
  77. ),
  78. padding: const EdgeInsets.only(bottom: 10),
  79. child: Column(
  80. children: <Widget>[
  81. Container(
  82. decoration: BoxDecoration(
  83. border: Border(
  84. bottom: BorderSide(
  85. width: 0.5, color: Colours.text_gray_c),
  86. )),
  87. padding: EdgeInsets.only(left: 12),
  88. child: Row(
  89. children: <Widget>[
  90. Expanded(
  91. flex: 1,
  92. child: Text(
  93. provider.list[index].useCompanyCode,
  94. style: TextStyles.text15,
  95. overflow: TextOverflow.ellipsis,
  96. softWrap: false, //单行显示
  97. )),
  98. // MyButton(
  99. // key: const Key('lift_list'),
  100. // onPressed: () {
  101. //// _liftList(provider.list[index].id);
  102. // NavigatorUtils.push(context, "${LiftRouter.liftDetailPage}?project_id="+widget.projectId+"&id="+provider.list[index].id);
  103. // },
  104. // height: 25,
  105. // fontSize: 11,
  106. // colors: [
  107. // Colours.app_main,
  108. // Colours.app_main
  109. // ],
  110. // borderWidth: 0.5,
  111. // borderColor: Colours.app_main,
  112. // text: "查看详情",
  113. // )
  114. ],
  115. ),
  116. ),
  117. lineTxt("注册代码",
  118. "${provider.list[index].registrationCode}"),
  119. lineTxt(
  120. "电梯型号", "${provider.list[index].liftCode}"),
  121. lineTxt(
  122. "电梯类型", "${provider.list[index].liftTypeName}"),
  123. lineTxt(
  124. "电梯品牌", "${provider.list[index].liftBrand}")
  125. ],
  126. ),
  127. );
  128. },
  129. );
  130. }))
  131. ],
  132. ),
  133. ),
  134. ));
  135. }
  136. Widget lineTxt(title, value) {
  137. return Container(
  138. padding: EdgeInsets.only(left: 12, top: 5, right: 12),
  139. child: Row(
  140. children: <Widget>[
  141. Text("${title}",
  142. style: TextStyle(fontSize: 13, color: Colours.dark_text_gray)),
  143. Expanded(
  144. flex: 1,
  145. child: Text(
  146. "${value}",
  147. textAlign: TextAlign.right,
  148. style: TextStyle(fontSize: 13, color: Colours.dark_text_gray),
  149. ),
  150. )
  151. ],
  152. ),
  153. );
  154. }
  155. Future _onRefresh() async {
  156. _page = 1;
  157. await presenter.searchLift(context,widget.projectId, _keyword, _page, false);
  158. }
  159. Future _loadMore() async {
  160. _page++;
  161. await presenter.searchLift(context,widget.projectId, _keyword, _page, false);
  162. }
  163. @override
  164. HeavyLiftListPresenter createPresenter() {
  165. return HeavyLiftListPresenter();
  166. }
  167. }