notification_list_page.dart 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:liftmanager/internal/notification/model/notification_list_entity.dart';
  4. import 'package:liftmanager/internal/notification/presenter/notification_list_presenter.dart';
  5. import 'package:liftmanager/internal/search/presenter/base_list_provider.dart';
  6. import 'package:liftmanager/mvp/base_page_state.dart';
  7. import 'package:liftmanager/res/resources.dart';
  8. import 'package:liftmanager/routers/fluro_navigator.dart';
  9. import 'package:liftmanager/utils/image_utils.dart';
  10. import 'package:liftmanager/widgets/app_bar.dart';
  11. import 'package:liftmanager/widgets/load_image.dart';
  12. import 'package:liftmanager/widgets/my_button.dart';
  13. import 'package:liftmanager/widgets/my_refresh_list.dart';
  14. import 'package:liftmanager/widgets/popup_window.dart';
  15. import 'package:liftmanager/widgets/state_layout.dart';
  16. import 'package:provider/provider.dart' as p;
  17. class NotificationListPage extends StatefulWidget{
  18. @override
  19. State<StatefulWidget> createState() {
  20. return NotificationListPageState();
  21. }
  22. }
  23. class NotificationListPageState extends BasePageState<NotificationListPage,NotificationListPresenter> {
  24. BaseListProvider<NotificationListItem> provider = BaseListProvider<NotificationListItem>();
  25. GlobalKey _addKey = GlobalKey();
  26. Future _onRefresh() async {
  27. await presenter.myTeamList(context);
  28. }
  29. @override
  30. void initState() {
  31. provider.setStateTypeNotNotify(StateType.loading);
  32. super.initState();
  33. _onRefresh();
  34. }
  35. @override
  36. Widget build(BuildContext context) {
  37. return p.ChangeNotifierProvider<BaseListProvider<NotificationListItem>>(
  38. create: (_) => provider,
  39. child: Scaffold(
  40. appBar: MyAppBar(
  41. centerTitle: "团队管理",
  42. actions: <Widget>[
  43. IconButton(
  44. key: _addKey,
  45. onPressed: () {
  46. _showAddMenu();
  47. },
  48. icon: LoadAssetImage(
  49. "icon_add",
  50. key: const Key('add'),
  51. width: 24.0,
  52. height: 24.0,
  53. color: Colors.black,
  54. ),
  55. )
  56. ],
  57. ),
  58. body: p.Consumer<BaseListProvider<NotificationListItem>>(
  59. builder: (_, provider, __) {
  60. return MyListView(
  61. key: Key('order_search_list'),
  62. itemCount: provider.list.length,
  63. stateType: provider.stateType,
  64. onRefresh: _onRefresh,
  65. // loadMore: _loadMore,
  66. itemExtent: 67.0,
  67. hasMore: provider.hasMore,
  68. itemBuilder: (_, index) {
  69. return Container(
  70. color: Colors.white,
  71. padding: const EdgeInsets.symmetric(
  72. horizontal: 15.0, vertical: 12.0),
  73. alignment: Alignment.centerLeft,
  74. child: Row(
  75. children: <Widget>[
  76. CircleAvatar(
  77. radius: 21.5,
  78. backgroundColor: Colors.transparent,
  79. backgroundImage: ImageUtils.getImageProvider(
  80. provider.list[index]?.logoImg)
  81. ),
  82. Gaps.hGap10,
  83. Expanded(
  84. flex: 1,
  85. child: Column(
  86. mainAxisAlignment: MainAxisAlignment.center,
  87. crossAxisAlignment: CrossAxisAlignment.start,
  88. children: <Widget>[
  89. Text(provider.list[index].name,
  90. style: TextStyles.text15,),
  91. Text("${provider.list[index]?.remarks}",
  92. style: TextStyles.textGray13,overflow:TextOverflow.clip ,maxLines: 2,)
  93. ],
  94. )
  95. ),
  96. MyButton(
  97. key: const Key('login'),
  98. onPressed: () {
  99. },
  100. height: 25,
  101. fontSize: 11,
  102. colors:
  103. provider.list[index].currentTeamFlag ? [Colours
  104. .app_main, Colours.app_main] : [
  105. Colors.white,
  106. Colors.white
  107. ],
  108. borderWidth: 0.5,
  109. borderColor: Colours.app_main,
  110. text: provider.list[index].currentTeamFlag
  111. ? "当前团队"
  112. : "切换团队",
  113. textColor: provider.list[index].currentTeamFlag
  114. ? Colors.white
  115. : Colours.app_main,
  116. )
  117. ],
  118. ),
  119. );
  120. },
  121. );
  122. })));
  123. }
  124. /// design/4商品/index.html#artboard4
  125. _showAddMenu() {
  126. final RenderBox button = _addKey.currentContext.findRenderObject();
  127. final RenderBox overlay = Overlay
  128. .of(context)
  129. .context
  130. .findRenderObject();
  131. var a = button.localToGlobal(
  132. Offset(button.size.width - 8.0, button.size.height - 12.0),
  133. ancestor: overlay);
  134. var b = button.localToGlobal(button.size.bottomLeft(Offset(0, -12.0)),
  135. ancestor: overlay);
  136. final RelativeRect position = RelativeRect.fromRect(
  137. Rect.fromPoints(a, b),
  138. Offset.zero & overlay.size,
  139. );
  140. // final Color backgroundColor = ThemeUtils.getBackgroundColor(context);
  141. // final Color _iconColor = ThemeUtils.getIconColor(context);
  142. showPopupWindow(
  143. context: context,
  144. fullWidth: false,
  145. isShowBg: true,
  146. position: position,
  147. elevation: 0.0,
  148. child: GestureDetector(
  149. onTap: () => NavigatorUtils.goBack(context),
  150. child: Column(
  151. crossAxisAlignment: CrossAxisAlignment.end,
  152. children: <Widget>[
  153. Padding(
  154. padding: const EdgeInsets.only(right: 12.0),
  155. child: LoadAssetImage(
  156. "icon_jt", width: 8.0, height: 4.0,
  157. ),
  158. ),
  159. SizedBox(
  160. width: 120.0,
  161. height: 40.0,
  162. child: FlatButton.icon(
  163. textColor: Theme
  164. .of(context)
  165. .textTheme
  166. .body1
  167. .color,
  168. onPressed: () {
  169. },
  170. color: Colors.white,
  171. shape: RoundedRectangleBorder(
  172. borderRadius: BorderRadius.only(
  173. topLeft: Radius.circular(8.0),
  174. topRight: Radius.circular(8.0)),
  175. ),
  176. icon: LoadAssetImage(
  177. "wode/icon_team_add",
  178. width: 16.0,
  179. height: 16.0,
  180. color: Colors.black,
  181. ),
  182. label: const Text("创建团队")),
  183. ),
  184. Container(width: 120.0, height: 0.6, color: Colours.line),
  185. SizedBox(
  186. width: 120.0,
  187. height: 40.0,
  188. child: FlatButton.icon(
  189. textColor: Theme
  190. .of(context)
  191. .textTheme
  192. .body1
  193. .color,
  194. color: Colors.white,
  195. onPressed: () {
  196. },
  197. shape: RoundedRectangleBorder(
  198. borderRadius: BorderRadius.only(
  199. bottomLeft: Radius.circular(8.0),
  200. bottomRight: Radius.circular(8.0)),
  201. ),
  202. icon: LoadAssetImage(
  203. "wode/icon_team_add",
  204. width: 16.0,
  205. height: 16.0,
  206. color: Colors.black,
  207. ),
  208. label: const Text("加入团队")),
  209. ),
  210. ],
  211. ),
  212. ),
  213. );
  214. }
  215. @override
  216. NotificationListPresenter createPresenter() {
  217. return NotificationListPresenter();
  218. }
  219. }