Hibok
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

1235 satır
44 KiB

  1. //import 'package:chat/data/UserData.dart';
  2. //import 'package:chat/data/WebData.dart';
  3. //import 'package:chat/data/conversation.dart';
  4. //import 'package:chat/data/group_data_mgr.dart';
  5. //import 'package:chat/generated/i18n.dart';
  6. //import 'package:chat/home/InfoList.dart';
  7. //import 'package:chat/home/last_chat_record_widget.dart';
  8. //import 'package:chat/home/rich_title.dart';
  9. //import 'package:chat/home/unread_dot_widget.dart';
  10. //import 'package:chat/models/group_info_model.dart';
  11. //import 'package:chat/utils/CustomUI.dart';
  12. //import 'package:chat/utils/HttpUtil.dart';
  13. //import 'package:chat/utils/MessageMgr.dart';
  14. //import 'package:chat/utils/TokenMgr.dart';
  15. //import 'package:chat/utils/screen.dart';
  16. //import 'package:dio/dio.dart';
  17. //import 'package:flutter/cupertino.dart';
  18. //import 'package:flutter/material.dart';
  19. //import 'package:shared_preferences/shared_preferences.dart';
  20. //import '../data/constants.dart'
  21. // show
  22. // AppColors,
  23. // AppStyles,
  24. // Constants,
  25. // GlobalSearchPageType,
  26. // GroupOperatingPageType;
  27. //import 'package:cached_network_image/cached_network_image.dart';
  28. //
  29. //import 'create_group_view.dart';
  30. //import 'global_search.dart';
  31. //import 'group_item_widget.dart';
  32. //
  33. //class _ConversationItem extends StatelessWidget {
  34. // const _ConversationItem(
  35. // {Key key,
  36. // this.conversation,
  37. // this.callback,
  38. // this.icon,
  39. // this.bgColor,
  40. // this.iconSize = 20})
  41. // : assert(conversation != null),
  42. // super(key: key);
  43. // final icon;
  44. // final double iconSize;
  45. // final Conversation conversation;
  46. // final callback;
  47. // final bgColor;
  48. //
  49. // @override
  50. // Widget build(BuildContext context) {
  51. // Widget avatar;
  52. // if (icon != null) {
  53. // avatar = Container(
  54. // height: 47.5,
  55. // width: 47.5,
  56. // margin: EdgeInsets.only(left: 6),
  57. // alignment: Alignment.center,
  58. // decoration: BoxDecoration(
  59. // gradient: bgColor,
  60. // borderRadius: BorderRadius.all(Radius.circular(50))),
  61. // child: Image.asset(
  62. // icon,
  63. // height: iconSize,
  64. // ));
  65. // } else if (conversation.isAvatarFromNet()) {
  66. // avatar = CachedNetworkImage(
  67. // imageUrl: conversation.avatar,
  68. // placeholder: CustomUI.buildImgLoding,
  69. // width: Constants.ConversationAvatarSize,
  70. // height: Constants.ConversationAvatarSize,
  71. // );
  72. // } else {
  73. // avatar = Image.asset(
  74. // conversation.avatar,
  75. // width: Constants.ConversationAvatarSize,
  76. // height: Constants.ConversationAvatarSize,
  77. // );
  78. // }
  79. // List<Widget> _rightArea = [
  80. // Container(
  81. // padding: EdgeInsets.only(top: 4),
  82. // alignment: Alignment.center,
  83. // child: Text(conversation.updateAt,
  84. // textScaleFactor: 1.0,
  85. // style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))),
  86. // )
  87. // ];
  88. // if (conversation.unreadMsgCount > 0) {
  89. // var countStr = conversation.unreadMsgCount.toString();
  90. // if (conversation.unreadMsgCount > 99) {
  91. // countStr = '99+';
  92. // }
  93. // // 未读消息角标
  94. // Widget unreadMsgCountText = Container(
  95. // width: Constants.UnReadMsgNotifyDotSize,
  96. // height: Constants.UnReadMsgNotifyDotSize,
  97. // alignment: Alignment.center,
  98. // decoration: BoxDecoration(
  99. // borderRadius:
  100. // BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0),
  101. // color: Color(0xFFFF5454),
  102. // ),
  103. // child: Text(countStr,
  104. // textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle),
  105. // );
  106. // _rightArea.add(Expanded(
  107. // child: Align(
  108. // alignment: Alignment.bottomCenter,
  109. // child: unreadMsgCountText,
  110. // )));
  111. // }
  112. //
  113. // return InkWell(
  114. // child: Container(
  115. // padding: const EdgeInsets.all(10.0),
  116. // decoration: BoxDecoration(
  117. // color: Color(AppColors.ConversationItemBgColor),
  118. // ),
  119. // child: Row(
  120. // crossAxisAlignment: CrossAxisAlignment.center,
  121. // children: <Widget>[
  122. // avatar,
  123. // Container(width: 17.0),
  124. // Expanded(
  125. // child: Column(
  126. // crossAxisAlignment: CrossAxisAlignment.start,
  127. // children: <Widget>[
  128. // Text(conversation.title,
  129. // textScaleFactor: 1.0,
  130. // style: TextStyle(
  131. // color: Colors.black,
  132. // )),
  133. // SizedBox(
  134. // height: 5,
  135. // ),
  136. // Text(conversation.desc,
  137. // textScaleFactor: 1.0,
  138. // style: TextStyle(
  139. // fontSize: 12, color: const Color(0xFF9B9B9B)))
  140. // ],
  141. // ),
  142. // ),
  143. // // Container(width: 10.0),
  144. // SizedBox(
  145. // height: Constants.ConversationAvatarSize,
  146. // child: Column(
  147. // crossAxisAlignment: CrossAxisAlignment.end,
  148. // mainAxisAlignment: MainAxisAlignment.start,
  149. // children: _rightArea,
  150. // ),
  151. // )
  152. // ],
  153. // ),
  154. // ),
  155. // onTap: () {
  156. // callback();
  157. // },
  158. // );
  159. // }
  160. //}
  161. //
  162. //class ConversActionPage extends StatefulWidget {
  163. // ConversActionPage({Key key}) : super(key: key);
  164. //
  165. // _ConversActionPageState createState() => _ConversActionPageState();
  166. //}
  167. //
  168. //Map systemInfo = {
  169. // 'applyList': null,
  170. // 'applyCount': 0,
  171. // 'evaluateList': null,
  172. // 'evaluateCount': 0,
  173. // 'parkList': null,
  174. // 'parkCount': 0,
  175. // 'castList': null,
  176. // 'castCount': 0,
  177. // 'walletList': null,
  178. // 'walletCount': 0,
  179. //};
  180. //
  181. //int msgNum = 0;
  182. //bool isShowMsg() {
  183. // return msgNum > 0;
  184. //}
  185. //
  186. //getAllResNum(prefs) {
  187. // getResNum(prefs, Constants.ApplyCount);
  188. // getResNum(prefs, Constants.EvaluateCount);
  189. // getResNum(prefs, Constants.ParkCount);
  190. // getResNum(prefs, Constants.CastCount);
  191. // getResNum(prefs, Constants.WalletCount);
  192. //}
  193. //
  194. //getResNum(prefs, url) async {
  195. // var count = prefs.getInt(url + UserData().basicInfo.userId.toString());
  196. // systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count);
  197. //
  198. // msgNum += systemInfo[url];
  199. //}
  200. //
  201. //setResNum(url) async {
  202. // var localKey = url + UserData().basicInfo.userId.toString();
  203. // if (systemInfo[url] > 0) {
  204. // SharedPreferences prefs = await SharedPreferences.getInstance();
  205. // var count = prefs.getInt(localKey);
  206. // prefs.setInt(
  207. // localKey, count == null ? systemInfo[url] : (systemInfo[url] + count));
  208. // msgNum -= systemInfo[url];
  209. // systemInfo[url] = 0;
  210. // }
  211. //}
  212. //
  213. //class _ConversActionPageState extends State<ConversActionPage>
  214. // with SingleTickerProviderStateMixin {
  215. // TabController tabCtrl;
  216. //
  217. // void getSystemMsg(data) async {
  218. // Map data = {
  219. // "userId": UserData().basicInfo.userId,
  220. // "type": UserData().basicInfo.sex
  221. // };
  222. // data['sign'] = TokenMgr().getSign(data);
  223. //
  224. // Response res = await HttpUtil().post('message/all/message', data: data);
  225. // if (res == null) {
  226. // return;
  227. // }
  228. // Map resData = res.data;
  229. // if (resData['code'] == 0) {
  230. // SharedPreferences prefs = await SharedPreferences.getInstance();
  231. // systemInfo = resData['data'];
  232. // msgNum = 0;
  233. // getAllResNum(prefs);
  234. // if (mounted) {
  235. // setState(() {});
  236. // }
  237. // }
  238. // }
  239. //
  240. // @override
  241. // void initState() {
  242. // super.initState();
  243. //
  244. // MessageMgr().on('update_system', getSystemMsg);
  245. // MessageMgr().on('Quit Group', quitGroup);
  246. //
  247. // MessageMgr().on('Update Group List', updateGroupLastMsg);
  248. // getSystemMsg(null);
  249. //
  250. // tabCtrl = TabController(length: 3, vsync: this);
  251. // }
  252. //
  253. // @override
  254. // void dispose() {
  255. // tabCtrl.dispose();
  256. // MessageMgr().off('update_system', getSystemMsg);
  257. // super.dispose();
  258. // MessageMgr().off('Quit Group', quitGroup);
  259. //
  260. // MessageMgr().off('Update Group List', updateGroupLastMsg);
  261. // }
  262. //
  263. // @override
  264. // Widget build(BuildContext context) {
  265. // List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  266. //
  267. // return Scaffold(
  268. // backgroundColor: Colors.white,
  269. // appBar: AppBar(
  270. // //backgroundColor: Constants.LightGreyBackgroundColor,
  271. // centerTitle: false,
  272. // title: Text(
  273. // I18n.of(context).message_center,
  274. // textScaleFactor: 1.0,
  275. // style: Constants.MainTitleStyle,
  276. // ),
  277. // actions: <Widget>[
  278. // Container(
  279. // child: IconButton(
  280. // icon: CircleAvatar(
  281. // backgroundColor: Constants.GreyBackgroundColor,
  282. // radius: 13.75,
  283. // child: Padding(
  284. // padding: EdgeInsets.only(bottom: 1.5),
  285. // child: Icon(
  286. // IconData(0xe659,
  287. // fontFamily: Constants.IconFontFamily),
  288. // color: Constants.BlackTextColor,
  289. // size: 21,
  290. // ))),
  291. // onPressed: () {
  292. // CustomUI().goScanPage(context);
  293. // },
  294. // ),
  295. // ),
  296. // // InkWell(
  297. // // onTap: () {
  298. // // Navigator.of(context).push(
  299. // // new MaterialPageRoute(
  300. // // builder: (context) {
  301. // // return MessagePushPage();
  302. // // },
  303. // // ),
  304. // // );
  305. // // },
  306. // // child: Padding(
  307. // // padding: EdgeInsets.only(right: 10),
  308. // // child: CircleAvatar(
  309. // // backgroundColor: Constants.GreyBackgroundColor,
  310. // // radius: 13.75,
  311. // // child: Icon(
  312. // // Icons.settings,
  313. // // color: Constants.BlackTextColor,
  314. // // size: 22,
  315. // // )),
  316. // // )),
  317. // ],
  318. // elevation: 0,
  319. // bottom: PreferredSize(
  320. // preferredSize: Size.fromHeight(28),
  321. // child: Container(
  322. // padding: EdgeInsets.only(left: 2),
  323. // decoration: BoxDecoration(
  324. // //color: Constants.LightGreyBackgroundColor,
  325. // border:
  326. // Border(bottom: BorderSide(color: Color(0xffeaeaea)))),
  327. // alignment: Alignment.centerLeft,
  328. // child: TabBar(
  329. // isScrollable: true,
  330. // indicatorPadding: EdgeInsets.only(left: 9, right: 9),
  331. // tabs: <Widget>[
  332. // UnreadDot(
  333. // child: Container(
  334. // margin: EdgeInsets.only(right: 4),
  335. // child: Text(I18n.of(context).text_chat,
  336. // textScaleFactor: 1.0),
  337. // ),
  338. // type: 1),
  339. // UnreadDot(
  340. // child: Container(
  341. // margin: EdgeInsets.only(right: 4),
  342. // child: Text(I18n.of(context).group_chat,
  343. // textScaleFactor: 1.0),
  344. // ),
  345. // type: 4),
  346. // UnreadDot(
  347. // child: Container(
  348. // margin: EdgeInsets.only(right: 4),
  349. // child: Text(I18n.of(context).system_information,
  350. // textScaleFactor: 1.0)),
  351. // type: 2),
  352. // ],
  353. // controller: tabCtrl,
  354. // ),
  355. // )),
  356. // ),
  357. // body: SafeArea(
  358. // child: TabBarView(
  359. // children: <Widget>[
  360. // LastChatPage(),
  361. // ListView.builder(
  362. //// controller: _scrollController,
  363. // itemBuilder: (BuildContext context, int index) {
  364. // if (index == 0) {
  365. // return _buildCreateButton();
  366. // } else {
  367. // var info = groupList[index - 1];
  368. // return GroupItem(ValueKey(info), groupInfoModel: info);
  369. // }
  370. // },
  371. // itemCount: groupList.length + 1,
  372. // ),
  373. // ListView(
  374. // children: <Widget>[
  375. // SizedBox(height: 8.5),
  376. // _ConversationItem(
  377. // icon: 'assets/images/chat/icon1.png',
  378. // bgColor: Constants.RadioGradient,
  379. // conversation: Conversation(
  380. // avatar: 'assets/images/ic_tx_news.png',
  381. // title: I18n.of(context).radio_message,
  382. // desc: RichTitle.normalTitle(
  383. // systemInfo['castList'], context, InfoType.Radio),
  384. // updateAt: systemInfo['castList'] == null
  385. // ? ""
  386. // : WebData().getLoginTime(
  387. // context, systemInfo['castList']['CreateTime']),
  388. // unreadMsgCount: systemInfo['castCount'],
  389. // ),
  390. // callback: () {
  391. // setResNum(Constants.CastCount);
  392. // Navigator.of(context).push(
  393. // new MaterialPageRoute(
  394. // builder: (context) {
  395. // return InfoListPage(
  396. // title: I18n.of(context).radio_message,
  397. // type: InfoType.Radio,
  398. // );
  399. // },
  400. // ),
  401. // );
  402. // },
  403. // ),
  404. // _ConversationItem(
  405. // icon: 'assets/images/chat/icon4.png',
  406. // bgColor: Constants.MoneyGradient,
  407. // conversation: Conversation(
  408. // avatar: 'assets/images/ic_tx_news.png',
  409. // title: I18n.of(context).wallet_reminder,
  410. // desc: RichTitle.normalTitle(
  411. // systemInfo['walletList'], context, InfoType.IncomeMoney),
  412. // updateAt: systemInfo['walletList'] == null
  413. // ? ""
  414. // : WebData().getLoginTime(
  415. // context, systemInfo['walletList']['CreateTime']),
  416. // unreadMsgCount: systemInfo['walletCount'],
  417. // ),
  418. // callback: () {
  419. // setResNum(Constants.WalletCount);
  420. // Navigator.of(context).push(
  421. // new MaterialPageRoute(
  422. // builder: (context) {
  423. // return InfoListPage(
  424. // title: I18n.of(context).wallet_reminder,
  425. // type: InfoType.IncomeMoney,
  426. // );
  427. // },
  428. // ),
  429. // );
  430. // },
  431. // ),
  432. // _ConversationItem(
  433. // icon: 'assets/images/chat/icon3.png',
  434. // iconSize: 27,
  435. // bgColor: Constants.ApplyGradient,
  436. // conversation: Conversation(
  437. // avatar: 'assets/images/ic_tx_news.png',
  438. // title: I18n.of(context).application_notice,
  439. // desc: RichTitle.normalTitle(
  440. // systemInfo['applyList'], context, InfoType.Apply),
  441. // updateAt: systemInfo['applyList'] == null
  442. // ? ""
  443. // : WebData().getLoginTime(
  444. // context, systemInfo['applyList']['CreatTime']),
  445. // unreadMsgCount: systemInfo['applyCount'],
  446. // ),
  447. // callback: () {
  448. // setResNum(Constants.ApplyCount);
  449. // Navigator.of(context).push(
  450. // new MaterialPageRoute(
  451. // builder: (context) {
  452. // return InfoListPage(
  453. // title: I18n.of(context).application_notice,
  454. // type: InfoType.Apply,
  455. // );
  456. // },
  457. // ),
  458. // );
  459. // },
  460. // ),
  461. // _ConversationItem(
  462. // icon: 'assets/images/chat/icon6.png',
  463. // bgColor: Constants.EvaGradient,
  464. // conversation: Conversation(
  465. // avatar: 'assets/images/ic_tx_news.png',
  466. // title: I18n.of(context).evaluation_notice,
  467. // desc: RichTitle.normalTitle(systemInfo['evaluateList'],
  468. // context, InfoType.Evaluation),
  469. // updateAt: systemInfo['evaluateList'] == null
  470. // ? ''
  471. // : WebData().getLoginTime(
  472. // context, systemInfo['evaluateList']['CreateTime']),
  473. // unreadMsgCount: systemInfo['evaluateCount'],
  474. // ),
  475. // callback: () {
  476. // setResNum(Constants.EvaluateCount);
  477. // Navigator.of(context).push(
  478. // new MaterialPageRoute(
  479. // builder: (context) {
  480. // return InfoListPage(
  481. // title: I18n.of(context).evaluation_notice,
  482. // type: 2,
  483. // );
  484. // },
  485. // ),
  486. // );
  487. // },
  488. // ),
  489. // _ConversationItem(
  490. // icon: 'assets/images/chat/icon5.png',
  491. // bgColor: Constants.ParkGradient,
  492. // conversation: Conversation(
  493. // avatar: 'assets/images/ic_tx_news.png',
  494. // title: I18n.of(context).appName,
  495. // desc: RichTitle.normalTitle(
  496. // systemInfo['parkList'], context, InfoType.System),
  497. // updateAt: systemInfo['parkList'] == null
  498. // ? ""
  499. // : WebData().getLoginTime(
  500. // context, systemInfo['parkList']['CreateTime']),
  501. // unreadMsgCount: systemInfo['parkCount'],
  502. // ),
  503. // callback: () {
  504. // setResNum(Constants.ParkCount);
  505. // Navigator.of(context).push(
  506. // new MaterialPageRoute(
  507. // builder: (context) {
  508. // return InfoListPage(
  509. // title: I18n.of(context).appName,
  510. // type: InfoType.System,
  511. // );
  512. // },
  513. // ),
  514. // );
  515. // },
  516. // )
  517. // ],
  518. // )
  519. // ],
  520. // controller: tabCtrl,
  521. // )));
  522. // }
  523. //
  524. // Widget _buildCreateButton() {
  525. // List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  526. // Widget _avatarIcon = ClipRRect(
  527. // borderRadius: BorderRadius.circular(GroupRadius),
  528. // child: Container(
  529. // color: const Color(0xFFF2F2F2),
  530. // height: AvatarSize,
  531. // width: AvatarSize,
  532. // child: Icon(
  533. // IconData(0xe66f, fontFamily: Constants.IconFontFamily),
  534. // color: Constants.BlueTextColor,
  535. // size: 35,
  536. // ),
  537. // ));
  538. //
  539. // Widget _button = InkWell(
  540. // onTap: () {
  541. // Navigator.of(context).push(
  542. // new MaterialPageRoute(
  543. // builder: (context) {
  544. // return CreateGroupPage(
  545. // GroupOperatingPageType.CreateGroup, [], null);
  546. // },
  547. // ),
  548. // );
  549. // },
  550. // child: Container(
  551. // padding: EdgeInsets.only(top: 14, bottom: 14),
  552. // color: Constants.GreyBackgroundColor,
  553. // child: Container(
  554. // height: ItemHeight,
  555. // decoration: BoxDecoration(color: Colors.white),
  556. // child: Row(
  557. // children: <Widget>[
  558. // SizedBox(width: LeftPadding),
  559. // _avatarIcon,
  560. // SizedBox(width: 14.0),
  561. // Text(
  562. // I18n.of(context).create_group_chat,
  563. // style: TextStyle(fontSize: 15.5),
  564. // ),
  565. // ],
  566. // ),
  567. // )));
  568. //
  569. // Widget tips = Container(
  570. // alignment: Alignment.centerLeft,
  571. // width: Screen.width,
  572. // height: 33.5,
  573. // padding: EdgeInsets.only(left: LeftPadding),
  574. // decoration: BoxDecoration(
  575. // color: Colors.white,
  576. // border: Border(bottom: Constants.GreyBorderSide)),
  577. // child: Text(I18n.of(context).group_chat + '(${groupList.length})'),
  578. // );
  579. //
  580. // return Column(
  581. // children: <Widget>[
  582. // SizedBox(
  583. // height: 10,
  584. // ),
  585. // CustomUI.buildSearchButton(context, () {
  586. // Navigator.of(context).push(
  587. // new MaterialPageRoute(
  588. // builder: (context) {
  589. // return GlobalSearchPage(
  590. // type: GlobalSearchPageType.SearchGroup,
  591. // );
  592. // },
  593. // ),
  594. // );
  595. // }, bottom: 10),
  596. // _button,
  597. // tips,
  598. // ],
  599. // );
  600. // }
  601. //
  602. // quitGroup(args) {
  603. // if (mounted) {
  604. // setState(() {
  605. // print('更新群列表');
  606. // });
  607. // }
  608. // }
  609. //
  610. // updateGroupLastMsg(args) async {
  611. // await GroupInfoMgr().sortGroupList();
  612. // if (mounted) {
  613. // setState(() {});
  614. // }
  615. // }
  616. //}
  617. import 'package:chat/data/UserData.dart';
  618. import 'package:chat/data/WebData.dart';
  619. import 'package:chat/data/conversation.dart';
  620. import 'package:chat/data/group_data_mgr.dart';
  621. import 'package:chat/generated/i18n.dart';
  622. import 'package:chat/home/InfoList.dart';
  623. import 'package:chat/home/last_chat_record_widget.dart';
  624. import 'package:chat/home/rich_title.dart';
  625. import 'package:chat/home/unread_dot_widget.dart';
  626. import 'package:chat/models/group_info_model.dart';
  627. import 'package:chat/utils/CustomUI.dart';
  628. import 'package:chat/utils/HttpUtil.dart';
  629. import 'package:chat/utils/MessageMgr.dart';
  630. import 'package:chat/utils/TokenMgr.dart';
  631. import 'package:chat/utils/screen.dart';
  632. import 'package:dio/dio.dart';
  633. import 'package:flutter/cupertino.dart';
  634. import 'package:flutter/material.dart';
  635. import 'package:shared_preferences/shared_preferences.dart';
  636. import '../data/constants.dart'
  637. show
  638. AppColors,
  639. AppStyles,
  640. Constants,
  641. GlobalSearchPageType,
  642. GroupOperatingPageType;
  643. import 'package:cached_network_image/cached_network_image.dart';
  644. import 'create_group_view.dart';
  645. import 'global_search.dart';
  646. import 'group_item_widget.dart';
  647. class _ConversationItem extends StatelessWidget {
  648. const _ConversationItem(
  649. {Key key,
  650. this.conversation,
  651. this.callback,
  652. this.icon,
  653. this.bgColor,
  654. this.iconSize = 20})
  655. : assert(conversation != null),
  656. super(key: key);
  657. final icon;
  658. final double iconSize;
  659. final Conversation conversation;
  660. final callback;
  661. final bgColor;
  662. @override
  663. Widget build(BuildContext context) {
  664. Widget avatar;
  665. if (icon != null) {
  666. avatar = Container(
  667. height: 47.5,
  668. width: 47.5,
  669. margin: EdgeInsets.only(left: 6),
  670. alignment: Alignment.center,
  671. decoration: BoxDecoration(
  672. gradient: bgColor,
  673. borderRadius: BorderRadius.all(Radius.circular(50))),
  674. child: Image.asset(
  675. icon,
  676. height: iconSize,
  677. ));
  678. } else if (conversation.isAvatarFromNet()) {
  679. avatar = CachedNetworkImage(
  680. imageUrl: conversation.avatar,
  681. placeholder: CustomUI.buildImgLoding,
  682. width: Constants.ConversationAvatarSize,
  683. height: Constants.ConversationAvatarSize,
  684. );
  685. } else {
  686. avatar = Image.asset(
  687. conversation.avatar,
  688. width: Constants.ConversationAvatarSize,
  689. height: Constants.ConversationAvatarSize,
  690. );
  691. }
  692. List<Widget> _rightArea = [
  693. Container(
  694. padding: EdgeInsets.only(top: 4),
  695. alignment: Alignment.center,
  696. child: Text(conversation.updateAt,
  697. textScaleFactor: 1.0,
  698. style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))),
  699. )
  700. ];
  701. if (conversation.unreadMsgCount > 0) {
  702. var countStr = conversation.unreadMsgCount.toString();
  703. if (conversation.unreadMsgCount > 99) {
  704. countStr = '99+';
  705. }
  706. // 未读消息角标
  707. Widget unreadMsgCountText = Container(
  708. width: Constants.UnReadMsgNotifyDotSize,
  709. height: Constants.UnReadMsgNotifyDotSize,
  710. alignment: Alignment.center,
  711. decoration: BoxDecoration(
  712. borderRadius:
  713. BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0),
  714. color: Color(0xFFFF5454),
  715. ),
  716. child: Text(countStr,
  717. textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle),
  718. );
  719. _rightArea.add(Expanded(
  720. child: Align(
  721. alignment: Alignment.bottomCenter,
  722. child: unreadMsgCountText,
  723. )));
  724. }
  725. return InkWell(
  726. child: Container(
  727. padding: const EdgeInsets.all(10.0),
  728. decoration: BoxDecoration(
  729. color: Color(AppColors.ConversationItemBgColor),
  730. ),
  731. child: Row(
  732. crossAxisAlignment: CrossAxisAlignment.center,
  733. children: <Widget>[
  734. avatar,
  735. Container(width: 17.0),
  736. Expanded(
  737. child: Column(
  738. crossAxisAlignment: CrossAxisAlignment.start,
  739. children: <Widget>[
  740. Text(conversation.title,
  741. textScaleFactor: 1.0,
  742. style: TextStyle(
  743. color: Colors.black,
  744. )),
  745. SizedBox(
  746. height: 5,
  747. ),
  748. Text(conversation.desc,
  749. textScaleFactor: 1.0,
  750. style: TextStyle(
  751. fontSize: 12, color: const Color(0xFF9B9B9B)))
  752. ],
  753. ),
  754. ),
  755. // Container(width: 10.0),
  756. SizedBox(
  757. height: Constants.ConversationAvatarSize,
  758. child: Column(
  759. crossAxisAlignment: CrossAxisAlignment.end,
  760. mainAxisAlignment: MainAxisAlignment.start,
  761. children: _rightArea,
  762. ),
  763. )
  764. ],
  765. ),
  766. ),
  767. onTap: () {
  768. callback();
  769. },
  770. );
  771. }
  772. }
  773. class ConversActionPage extends StatefulWidget {
  774. ConversActionPage({Key key}) : super(key: key);
  775. _ConversActionPageState createState() => _ConversActionPageState();
  776. }
  777. Map systemInfo = {
  778. 'applyList': null,
  779. 'applyCount': 0,
  780. 'evaluateList': null,
  781. 'evaluateCount': 0,
  782. 'parkList': null,
  783. 'parkCount': 0,
  784. 'castList': null,
  785. 'castCount': 0,
  786. 'walletList': null,
  787. 'walletCount': 0,
  788. };
  789. int msgNum = 0;
  790. bool isShowMsg() {
  791. return msgNum > 0;
  792. }
  793. getAllResNum(prefs) {
  794. getResNum(prefs, Constants.ApplyCount);
  795. getResNum(prefs, Constants.EvaluateCount);
  796. getResNum(prefs, Constants.ParkCount);
  797. getResNum(prefs, Constants.CastCount);
  798. getResNum(prefs, Constants.WalletCount);
  799. }
  800. getResNum(prefs, url) async {
  801. var count = prefs.getInt(url + UserData().basicInfo.userId.toString());
  802. systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count);
  803. msgNum += systemInfo[url];
  804. }
  805. setResNum(url) async {
  806. var localKey = url + UserData().basicInfo.userId.toString();
  807. if (systemInfo[url] > 0) {
  808. SharedPreferences prefs = await SharedPreferences.getInstance();
  809. var count = prefs.getInt(localKey);
  810. prefs.setInt(
  811. localKey, count == null ? systemInfo[url] : (systemInfo[url] + count));
  812. msgNum -= systemInfo[url];
  813. systemInfo[url] = 0;
  814. }
  815. }
  816. class _ConversActionPageState extends State<ConversActionPage>
  817. with SingleTickerProviderStateMixin {
  818. TabController tabCtrl;
  819. void getSystemMsg(data) async {
  820. Map data = {
  821. "userId": UserData().basicInfo.userId,
  822. "type": UserData().basicInfo.sex
  823. };
  824. data['sign'] = TokenMgr().getSign(data);
  825. Response res = await HttpUtil().post('message/all/message', data: data);
  826. if (res == null) {
  827. return;
  828. }
  829. Map resData = res.data;
  830. if (resData['code'] == 0) {
  831. SharedPreferences prefs = await SharedPreferences.getInstance();
  832. systemInfo = resData['data'];
  833. msgNum = 0;
  834. getAllResNum(prefs);
  835. if (mounted) {
  836. setState(() {});
  837. }
  838. }
  839. }
  840. @override
  841. void initState() {
  842. super.initState();
  843. MessageMgr().on('update_system', getSystemMsg);
  844. // MessageMgr().on('Quit Group', quitGroup);
  845. //
  846. // MessageMgr().on('Update Group List', updateGroupLastMsg);
  847. getSystemMsg(null);
  848. tabCtrl = TabController(length: 2, vsync: this);
  849. }
  850. @override
  851. void dispose() {
  852. tabCtrl.dispose();
  853. MessageMgr().off('update_system', getSystemMsg);
  854. super.dispose();
  855. }
  856. @override
  857. Widget build(BuildContext context) {
  858. // List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  859. return Scaffold(
  860. backgroundColor: Colors.white,
  861. appBar: AppBar(
  862. //backgroundColor: Constants.LightGreyBackgroundColor,
  863. centerTitle: false,
  864. title: Text(
  865. I18n.of(context).message_center,
  866. textScaleFactor: 1.0,
  867. style: Constants.MainTitleStyle,
  868. ),
  869. actions: <Widget>[
  870. Container(
  871. child: IconButton(
  872. icon: CircleAvatar(
  873. backgroundColor: Constants.GreyBackgroundColor,
  874. radius: 13.75,
  875. child: Padding(
  876. padding: EdgeInsets.only(bottom: 1.5),
  877. child: Icon(
  878. IconData(0xe659,
  879. fontFamily: Constants.IconFontFamily),
  880. color: Constants.BlackTextColor,
  881. size: 21,
  882. ))),
  883. onPressed: () {
  884. CustomUI().goScanPage(context);
  885. },
  886. ),
  887. ),
  888. // InkWell(
  889. // onTap: () {
  890. // Navigator.of(context).push(
  891. // new MaterialPageRoute(
  892. // builder: (context) {
  893. // return MessagePushPage();
  894. // },
  895. // ),
  896. // );
  897. // },
  898. // child: Padding(
  899. // padding: EdgeInsets.only(right: 10),
  900. // child: CircleAvatar(
  901. // backgroundColor: Constants.GreyBackgroundColor,
  902. // radius: 13.75,
  903. // child: Icon(
  904. // Icons.settings,
  905. // color: Constants.BlackTextColor,
  906. // size: 22,
  907. // )),
  908. // )),
  909. ],
  910. elevation: 0,
  911. bottom: PreferredSize(
  912. preferredSize: Size.fromHeight(28),
  913. child: Container(
  914. padding: EdgeInsets.only(left: 2),
  915. decoration: BoxDecoration(
  916. //color: Constants.LightGreyBackgroundColor,
  917. border:
  918. Border(bottom: BorderSide(color: Color(0xffeaeaea)))),
  919. alignment: Alignment.centerLeft,
  920. child: TabBar(
  921. isScrollable: true,
  922. indicatorPadding: EdgeInsets.only(left: 9, right: 9),
  923. tabs: <Widget>[
  924. UnreadDot(
  925. child: Container(
  926. margin: EdgeInsets.only(right: 4),
  927. child: Text(I18n.of(context).text_chat,
  928. textScaleFactor: 1.0),
  929. ),
  930. type: 1),
  931. // UnreadDot(
  932. // child: Container(
  933. // margin: EdgeInsets.only(right: 4),
  934. // child: Text(I18n.of(context).group_chat,
  935. // textScaleFactor: 1.0),
  936. // ),
  937. // type: 4),
  938. UnreadDot(
  939. child: Container(
  940. margin: EdgeInsets.only(right: 4),
  941. child: Text(I18n.of(context).system_information,
  942. textScaleFactor: 1.0)),
  943. type: 2),
  944. ],
  945. controller: tabCtrl,
  946. ),
  947. )),
  948. ),
  949. body: SafeArea(
  950. child: TabBarView(
  951. children: <Widget>[
  952. LastChatPage(),
  953. // ListView.builder(
  954. //// controller: _scrollController,
  955. // itemBuilder: (BuildContext context, int index) {
  956. // if (index == 0) {
  957. // return _buildCreateButton();
  958. // } else {
  959. // var info = groupList[index - 1];
  960. // return GroupItem(ValueKey(info), groupInfoModel: info);
  961. // }
  962. // },
  963. // itemCount: groupList.length + 1,
  964. // ),
  965. ListView(
  966. children: <Widget>[
  967. SizedBox(height: 8.5),
  968. _ConversationItem(
  969. icon: 'assets/images/chat/icon1.png',
  970. bgColor: Constants.RadioGradient,
  971. conversation: Conversation(
  972. avatar: 'assets/images/ic_tx_news.png',
  973. title: I18n.of(context).radio_message,
  974. desc: RichTitle.normalTitle(
  975. systemInfo['castList'], context, InfoType.Radio),
  976. updateAt: systemInfo['castList'] == null
  977. ? ""
  978. : WebData().getLoginTime(
  979. context, systemInfo['castList']['CreateTime']),
  980. unreadMsgCount: systemInfo['castCount'],
  981. ),
  982. callback: () {
  983. setResNum(Constants.CastCount);
  984. Navigator.of(context).push(
  985. new MaterialPageRoute(
  986. builder: (context) {
  987. return InfoListPage(
  988. title: I18n.of(context).radio_message,
  989. type: InfoType.Radio,
  990. );
  991. },
  992. ),
  993. );
  994. },
  995. ),
  996. _ConversationItem(
  997. icon: 'assets/images/chat/icon4.png',
  998. bgColor: Constants.MoneyGradient,
  999. conversation: Conversation(
  1000. avatar: 'assets/images/ic_tx_news.png',
  1001. title: I18n.of(context).wallet_reminder,
  1002. desc: RichTitle.normalTitle(systemInfo['walletList'],
  1003. context, InfoType.IncomeMoney),
  1004. updateAt: systemInfo['walletList'] == null
  1005. ? ""
  1006. : WebData().getLoginTime(
  1007. context, systemInfo['walletList']['CreateTime']),
  1008. unreadMsgCount: systemInfo['walletCount'],
  1009. ),
  1010. callback: () {
  1011. setResNum(Constants.WalletCount);
  1012. Navigator.of(context).push(
  1013. new MaterialPageRoute(
  1014. builder: (context) {
  1015. return InfoListPage(
  1016. title: I18n.of(context).wallet_reminder,
  1017. type: InfoType.IncomeMoney,
  1018. );
  1019. },
  1020. ),
  1021. );
  1022. },
  1023. ),
  1024. _ConversationItem(
  1025. icon: 'assets/images/chat/icon3.png',
  1026. iconSize: 27,
  1027. bgColor: Constants.ApplyGradient,
  1028. conversation: Conversation(
  1029. avatar: 'assets/images/ic_tx_news.png',
  1030. title: I18n.of(context).application_notice,
  1031. desc: RichTitle.normalTitle(
  1032. systemInfo['applyList'], context, InfoType.Apply),
  1033. updateAt: systemInfo['applyList'] == null
  1034. ? ""
  1035. : WebData().getLoginTime(
  1036. context, systemInfo['applyList']['CreatTime']),
  1037. unreadMsgCount: systemInfo['applyCount'],
  1038. ),
  1039. callback: () {
  1040. setResNum(Constants.ApplyCount);
  1041. Navigator.of(context).push(
  1042. new MaterialPageRoute(
  1043. builder: (context) {
  1044. return InfoListPage(
  1045. title: I18n.of(context).application_notice,
  1046. type: InfoType.Apply,
  1047. );
  1048. },
  1049. ),
  1050. );
  1051. },
  1052. ),
  1053. _ConversationItem(
  1054. icon: 'assets/images/chat/icon6.png',
  1055. bgColor: Constants.EvaGradient,
  1056. conversation: Conversation(
  1057. avatar: 'assets/images/ic_tx_news.png',
  1058. title: I18n.of(context).evaluation_notice,
  1059. desc: RichTitle.normalTitle(systemInfo['evaluateList'],
  1060. context, InfoType.Evaluation),
  1061. updateAt: systemInfo['evaluateList'] == null
  1062. ? ''
  1063. : WebData().getLoginTime(
  1064. context, systemInfo['evaluateList']['CreateTime']),
  1065. unreadMsgCount: systemInfo['evaluateCount'],
  1066. ),
  1067. callback: () {
  1068. setResNum(Constants.EvaluateCount);
  1069. Navigator.of(context).push(
  1070. new MaterialPageRoute(
  1071. builder: (context) {
  1072. return InfoListPage(
  1073. title: I18n.of(context).evaluation_notice,
  1074. type: 2,
  1075. );
  1076. },
  1077. ),
  1078. );
  1079. },
  1080. ),
  1081. _ConversationItem(
  1082. icon: 'assets/images/chat/icon5.png',
  1083. bgColor: Constants.ParkGradient,
  1084. conversation: Conversation(
  1085. avatar: 'assets/images/ic_tx_news.png',
  1086. title: I18n.of(context).appName,
  1087. desc: RichTitle.normalTitle(
  1088. systemInfo['parkList'], context, InfoType.System),
  1089. updateAt: systemInfo['parkList'] == null
  1090. ? ""
  1091. : WebData().getLoginTime(
  1092. context, systemInfo['parkList']['CreateTime']),
  1093. unreadMsgCount: systemInfo['parkCount'],
  1094. ),
  1095. callback: () {
  1096. setResNum(Constants.ParkCount);
  1097. Navigator.of(context).push(
  1098. new MaterialPageRoute(
  1099. builder: (context) {
  1100. return InfoListPage(
  1101. title: I18n.of(context).appName,
  1102. type: InfoType.System,
  1103. );
  1104. },
  1105. ),
  1106. );
  1107. },
  1108. )
  1109. ],
  1110. )
  1111. ],
  1112. controller: tabCtrl,
  1113. )));
  1114. }
  1115. Widget _buildCreateButton() {
  1116. List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  1117. Widget _avatarIcon = ClipRRect(
  1118. borderRadius: BorderRadius.circular(GroupRadius),
  1119. child: Container(
  1120. color: const Color(0xFFF2F2F2),
  1121. height: AvatarSize,
  1122. width: AvatarSize,
  1123. child: Icon(
  1124. IconData(0xe66f, fontFamily: Constants.IconFontFamily),
  1125. color: Constants.BlueTextColor,
  1126. size: 35,
  1127. ),
  1128. ));
  1129. Widget _button = InkWell(
  1130. onTap: () {
  1131. Navigator.of(context).push(
  1132. new MaterialPageRoute(
  1133. builder: (context) {
  1134. return CreateGroupPage(
  1135. GroupOperatingPageType.CreateGroup, [], null);
  1136. },
  1137. ),
  1138. );
  1139. },
  1140. child: Container(
  1141. padding: EdgeInsets.only(top: 14, bottom: 14),
  1142. color: Constants.GreyBackgroundColor,
  1143. child: Container(
  1144. height: ItemHeight,
  1145. decoration: BoxDecoration(color: Colors.white),
  1146. child: Row(
  1147. children: <Widget>[
  1148. SizedBox(width: LeftPadding),
  1149. _avatarIcon,
  1150. SizedBox(width: 14.0),
  1151. Text(
  1152. I18n.of(context).create_group_chat,
  1153. textScaleFactor: 1.0,
  1154. style: TextStyle(fontSize: 15.5),
  1155. ),
  1156. ],
  1157. ),
  1158. )));
  1159. Widget tips = Container(
  1160. alignment: Alignment.centerLeft,
  1161. width: Screen.width,
  1162. height: 33.5,
  1163. padding: EdgeInsets.only(left: LeftPadding),
  1164. decoration: BoxDecoration(
  1165. color: Colors.white,
  1166. border: Border(bottom: Constants.GreyBorderSide)),
  1167. child: Text(
  1168. I18n.of(context).group_chat + '(${groupList.length})',
  1169. textScaleFactor: 1.0,
  1170. ),
  1171. );
  1172. return Column(
  1173. children: <Widget>[
  1174. SizedBox(
  1175. height: 10,
  1176. ),
  1177. CustomUI.buildSearchButton(context, () {
  1178. Navigator.of(context).push(
  1179. new MaterialPageRoute(
  1180. builder: (context) {
  1181. return GlobalSearchPage(
  1182. type: GlobalSearchPageType.SearchGroup,
  1183. );
  1184. },
  1185. ),
  1186. );
  1187. }, bottom: 10),
  1188. _button,
  1189. tips,
  1190. ],
  1191. );
  1192. }
  1193. // quitGroup(args) {
  1194. // if (mounted) {
  1195. // setState(() {
  1196. // print('更新群列表');
  1197. // });
  1198. // }
  1199. // }
  1200. //
  1201. // updateGroupLastMsg(args) async {
  1202. // await GroupInfoMgr().sortGroupList();
  1203. // if (mounted) {
  1204. // setState(() {});
  1205. // }
  1206. // }
  1207. }