message_cener.dart 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. import 'package:flutter/material.dart';
  2. import 'package:liftmanager/internal/wode/model/message_model.dart';
  3. import 'package:liftmanager/internal/wode/page/notice_list.dart';
  4. import 'package:liftmanager/net/api_service.dart';
  5. import 'package:liftmanager/res/iconfont.dart';
  6. import 'package:liftmanager/utils/toast.dart';
  7. import 'package:liftmanager/widgets/app_bar.dart';
  8. import 'package:umeng_common_sdk/umeng_common_sdk.dart';
  9. class MessageCenter extends StatefulWidget {
  10. @override
  11. MessageCenterState createState() => MessageCenterState();
  12. }
  13. class MessageCenterState extends State<MessageCenter> {
  14. MessageOverview overview;
  15. @override
  16. void initState() {
  17. UmengCommonSdk.onPageStart("消息中心");
  18. super.initState();
  19. getMessageOverview();
  20. }
  21. @override
  22. void dispose() {
  23. UmengCommonSdk.onPageEnd("消息中心");
  24. super.dispose();
  25. }
  26. @override
  27. Widget build(BuildContext context) {
  28. return Scaffold(
  29. // resizeToAvoidBottomPadding: true,
  30. appBar: MyAppBar(
  31. centerTitle: "消息中心",
  32. ),
  33. body: Container(
  34. padding: EdgeInsets.symmetric(horizontal: 10),
  35. child: Column(
  36. children: [
  37. GestureDetector(
  38. child: Row(
  39. crossAxisAlignment: CrossAxisAlignment.center,
  40. children: <Widget>[
  41. Container(
  42. child: Stack(
  43. overflow: Overflow.visible,
  44. children: [
  45. ClipRRect(
  46. borderRadius: BorderRadius.circular(20),
  47. child: Container(
  48. width: 40,
  49. height: 40,
  50. decoration: BoxDecoration(
  51. color: Color(0xffFDAF2C),
  52. ),
  53. // padding: EdgeInsets.only(right:10),
  54. child: Icon(
  55. Iconfont.tongzhi,
  56. size: 17.0,
  57. color: Colors.white,
  58. ),
  59. ),
  60. ),
  61. if (overview != null &&
  62. overview.systemMessageUnreadCount > 0)
  63. Positioned(
  64. right: -5,
  65. top: -1,
  66. child: Container(
  67. height: 14,
  68. padding: EdgeInsets.symmetric(horizontal: 5),
  69. alignment: Alignment.center,
  70. decoration: BoxDecoration(
  71. color: Color(0xffF94F45),
  72. borderRadius: BorderRadius.circular(7),
  73. ),
  74. child: Text(
  75. '${overview.systemMessageUnreadCount}',
  76. style: TextStyle(
  77. color: Color(0xffffffff), fontSize: 10),
  78. ),
  79. ),
  80. )
  81. ],
  82. ),
  83. ),
  84. Expanded(
  85. child: Column(
  86. children: <Widget>[
  87. SizedBox(
  88. height: 20,
  89. ),
  90. Row(
  91. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  92. children: <Widget>[
  93. SizedBox(
  94. width: 10,
  95. ),
  96. Text(
  97. "系统消息",
  98. textAlign: TextAlign.left,
  99. style: TextStyle(
  100. fontSize: 14,
  101. color: Color(0xff333333),
  102. ),
  103. ),
  104. Spacer(),
  105. Text(
  106. "${overview?.systemMessageModel?.createTime ?? ''}",
  107. textAlign: TextAlign.left,
  108. style: TextStyle(
  109. fontSize: 12,
  110. color: Color(0xffCCCCCC),
  111. ),
  112. ),
  113. ],
  114. ),
  115. SizedBox(
  116. height: 5,
  117. ),
  118. Row(
  119. children: <Widget>[
  120. SizedBox(
  121. width: 10,
  122. ),
  123. Container(
  124. child: Text(
  125. "${overview?.systemMessageModel?.content ?? ''}",
  126. textAlign: TextAlign.left,
  127. style: TextStyle(
  128. fontSize: 13,
  129. color: Color(0xff999999),
  130. ),
  131. overflow: TextOverflow.ellipsis,
  132. ),
  133. ),
  134. ],
  135. ),
  136. ],
  137. ),
  138. ),
  139. ],
  140. ),
  141. ),
  142. SizedBox(
  143. height: 20,
  144. ),
  145. Divider(),
  146. SizedBox(
  147. height: 20,
  148. ),
  149. GestureDetector(
  150. onTap: () async {
  151. await Navigator.push(context,
  152. MaterialPageRoute(builder: (context) => NoticeList()));
  153. getMessageOverview();
  154. },
  155. child: Container(
  156. color: Colors.white,
  157. child: Row(
  158. crossAxisAlignment: CrossAxisAlignment.center,
  159. children: <Widget>[
  160. Container(
  161. child: Stack(
  162. overflow: Overflow.visible,
  163. children: [
  164. ClipRRect(
  165. borderRadius: BorderRadius.circular(20),
  166. child: Container(
  167. width: 40,
  168. height: 40,
  169. decoration: BoxDecoration(
  170. color: Color(0xff5589FF),
  171. ),
  172. // padding: EdgeInsets.only(right:10),
  173. child: Icon(
  174. Iconfont.tongzhi,
  175. size: 17.0,
  176. color: Colors.white,
  177. ),
  178. ),
  179. ),
  180. if (overview != null &&
  181. overview.notificationMessageUnreadCount > 0)
  182. Positioned(
  183. right: -5,
  184. top: -1,
  185. child: Container(
  186. height: 14,
  187. padding: EdgeInsets.symmetric(horizontal: 5),
  188. alignment: Alignment.center,
  189. decoration: BoxDecoration(
  190. color: Color(0xffF94F45),
  191. borderRadius: BorderRadius.circular(7),
  192. ),
  193. child: Text(
  194. '${overview.notificationMessageUnreadCount}',
  195. style: TextStyle(
  196. color: Color(0xffffffff), fontSize: 10),
  197. ),
  198. ),
  199. )
  200. ],
  201. ),
  202. ),
  203. Expanded(
  204. child: Column(
  205. children: <Widget>[
  206. Row(
  207. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  208. children: <Widget>[
  209. SizedBox(
  210. width: 10,
  211. ),
  212. Text(
  213. "通知消息",
  214. textAlign: TextAlign.left,
  215. style: TextStyle(
  216. fontSize: 14,
  217. color: Color(0xff333333),
  218. ),
  219. ),
  220. Spacer(),
  221. Text(
  222. "${overview?.notificationMessageModel?.createTime ?? ''}",
  223. textAlign: TextAlign.left,
  224. style: TextStyle(
  225. fontSize: 12,
  226. color: Color(0xffCCCCCC),
  227. ),
  228. ),
  229. ],
  230. ),
  231. SizedBox(
  232. height: 5,
  233. ),
  234. Row(
  235. children: <Widget>[
  236. SizedBox(
  237. width: 10,
  238. ),
  239. Container(
  240. child: Text(
  241. "${overview?.notificationMessageModel?.content ?? ''}",
  242. textAlign: TextAlign.left,
  243. style: TextStyle(
  244. fontSize: 13,
  245. color: Color(0xff999999),
  246. ),
  247. overflow: TextOverflow.ellipsis,
  248. ),
  249. ),
  250. ],
  251. ),
  252. ],
  253. ),
  254. ),
  255. ],
  256. ),
  257. ),
  258. ),
  259. SizedBox(
  260. height: 20,
  261. ),
  262. Divider(),
  263. ],
  264. ),
  265. ));
  266. }
  267. getMessageOverview() {
  268. NewApiService().getMessageOverview(onSuccess: (res) {
  269. setState(() {
  270. overview = res;
  271. });
  272. }, onError: (code, msg) {
  273. toasts(msg);
  274. });
  275. }
  276. }