message_cener.dart 11 KB

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