Hibok
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

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