Hibok
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

1235 Zeilen
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. //
  616. //import 'create_group_view.dart';
  617. //import 'global_search.dart';
  618. //import 'group_item_widget.dart';
  619. //
  620. //class _ConversationItem extends StatelessWidget {
  621. // const _ConversationItem(
  622. // {Key key,
  623. // this.conversation,
  624. // this.callback,
  625. // this.icon,
  626. // this.bgColor,
  627. // this.iconSize = 20})
  628. // : assert(conversation != null),
  629. // super(key: key);
  630. // final icon;
  631. // final double iconSize;
  632. // final Conversation conversation;
  633. // final callback;
  634. // final bgColor;
  635. //
  636. // @override
  637. // Widget build(BuildContext context) {
  638. // Widget avatar;
  639. // if (icon != null) {
  640. // avatar = Container(
  641. // height: 47.5,
  642. // width: 47.5,
  643. // margin: EdgeInsets.only(left: 6),
  644. // alignment: Alignment.center,
  645. // decoration: BoxDecoration(
  646. // gradient: bgColor,
  647. // borderRadius: BorderRadius.all(Radius.circular(50))),
  648. // child: Image.asset(
  649. // icon,
  650. // height: iconSize,
  651. // ));
  652. // } else if (conversation.isAvatarFromNet()) {
  653. // avatar = CachedNetworkImage(
  654. // imageUrl: conversation.avatar,
  655. // placeholder: CustomUI.buildImgLoding,
  656. // width: Constants.ConversationAvatarSize,
  657. // height: Constants.ConversationAvatarSize,
  658. // );
  659. // } else {
  660. // avatar = Image.asset(
  661. // conversation.avatar,
  662. // width: Constants.ConversationAvatarSize,
  663. // height: Constants.ConversationAvatarSize,
  664. // );
  665. // }
  666. // List<Widget> _rightArea = [
  667. // Container(
  668. // padding: EdgeInsets.only(top: 4),
  669. // alignment: Alignment.center,
  670. // child: Text(conversation.updateAt,
  671. // textScaleFactor: 1.0,
  672. // style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))),
  673. // )
  674. // ];
  675. // if (conversation.unreadMsgCount > 0) {
  676. // var countStr = conversation.unreadMsgCount.toString();
  677. // if (conversation.unreadMsgCount > 99) {
  678. // countStr = '99+';
  679. // }
  680. // // 未读消息角标
  681. // Widget unreadMsgCountText = Container(
  682. // width: Constants.UnReadMsgNotifyDotSize,
  683. // height: Constants.UnReadMsgNotifyDotSize,
  684. // alignment: Alignment.center,
  685. // decoration: BoxDecoration(
  686. // borderRadius:
  687. // BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0),
  688. // color: Color(0xFFFF5454),
  689. // ),
  690. // child: Text(countStr,
  691. // textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle),
  692. // );
  693. // _rightArea.add(Expanded(
  694. // child: Align(
  695. // alignment: Alignment.bottomCenter,
  696. // child: unreadMsgCountText,
  697. // )));
  698. // }
  699. //
  700. // return InkWell(
  701. // child: Container(
  702. // padding: const EdgeInsets.all(10.0),
  703. // decoration: BoxDecoration(
  704. // color: Color(AppColors.ConversationItemBgColor),
  705. // ),
  706. // child: Row(
  707. // crossAxisAlignment: CrossAxisAlignment.center,
  708. // children: <Widget>[
  709. // avatar,
  710. // Container(width: 17.0),
  711. // Expanded(
  712. // child: Column(
  713. // crossAxisAlignment: CrossAxisAlignment.start,
  714. // children: <Widget>[
  715. // Text(conversation.title,
  716. // textScaleFactor: 1.0,
  717. // style: TextStyle(
  718. // color: Colors.black,
  719. // )),
  720. // SizedBox(
  721. // height: 5,
  722. // ),
  723. // Text(conversation.desc,
  724. // textScaleFactor: 1.0,
  725. // style: TextStyle(
  726. // fontSize: 12, color: const Color(0xFF9B9B9B)))
  727. // ],
  728. // ),
  729. // ),
  730. // // Container(width: 10.0),
  731. // SizedBox(
  732. // height: Constants.ConversationAvatarSize,
  733. // child: Column(
  734. // crossAxisAlignment: CrossAxisAlignment.end,
  735. // mainAxisAlignment: MainAxisAlignment.start,
  736. // children: _rightArea,
  737. // ),
  738. // )
  739. // ],
  740. // ),
  741. // ),
  742. // onTap: () {
  743. // callback();
  744. // },
  745. // );
  746. // }
  747. //}
  748. //
  749. //class ConversActionPage extends StatefulWidget {
  750. // ConversActionPage({Key key}) : super(key: key);
  751. //
  752. // _ConversActionPageState createState() => _ConversActionPageState();
  753. //}
  754. //
  755. //Map systemInfo = {
  756. // 'applyList': null,
  757. // 'applyCount': 0,
  758. // 'evaluateList': null,
  759. // 'evaluateCount': 0,
  760. // 'parkList': null,
  761. // 'parkCount': 0,
  762. // 'castList': null,
  763. // 'castCount': 0,
  764. // 'walletList': null,
  765. // 'walletCount': 0,
  766. //};
  767. //
  768. //int msgNum = 0;
  769. //bool isShowMsg() {
  770. // return msgNum > 0;
  771. //}
  772. //
  773. //getAllResNum(prefs) {
  774. // getResNum(prefs, Constants.ApplyCount);
  775. // getResNum(prefs, Constants.EvaluateCount);
  776. // getResNum(prefs, Constants.ParkCount);
  777. // getResNum(prefs, Constants.CastCount);
  778. // getResNum(prefs, Constants.WalletCount);
  779. //}
  780. //
  781. //getResNum(prefs, url) async {
  782. // var count = prefs.getInt(url + UserData().basicInfo.userId.toString());
  783. // systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count);
  784. //
  785. // msgNum += systemInfo[url];
  786. //}
  787. //
  788. //setResNum(url) async {
  789. // var localKey = url + UserData().basicInfo.userId.toString();
  790. // if (systemInfo[url] > 0) {
  791. // SharedPreferences prefs = await SharedPreferences.getInstance();
  792. // var count = prefs.getInt(localKey);
  793. // prefs.setInt(
  794. // localKey, count == null ? systemInfo[url] : (systemInfo[url] + count));
  795. // msgNum -= systemInfo[url];
  796. // systemInfo[url] = 0;
  797. // }
  798. //}
  799. //
  800. //class _ConversActionPageState extends State<ConversActionPage>
  801. // with SingleTickerProviderStateMixin {
  802. // TabController tabCtrl;
  803. //
  804. // void getSystemMsg(data) async {
  805. // Map data = {
  806. // "userId": UserData().basicInfo.userId,
  807. // "type": UserData().basicInfo.sex
  808. // };
  809. // data['sign'] = TokenMgr().getSign(data);
  810. //
  811. // Response res = await HttpUtil().post('message/all/message', data: data);
  812. // if (res == null) {
  813. // return;
  814. // }
  815. // Map resData = res.data;
  816. // if (resData['code'] == 0) {
  817. // SharedPreferences prefs = await SharedPreferences.getInstance();
  818. // systemInfo = resData['data'];
  819. // msgNum = 0;
  820. // getAllResNum(prefs);
  821. // if (mounted) {
  822. // setState(() {});
  823. // }
  824. // }
  825. // }
  826. //
  827. // @override
  828. // void initState() {
  829. // super.initState();
  830. //
  831. // MessageMgr().on('update_system', getSystemMsg);
  832. //// MessageMgr().on('Quit Group', quitGroup);
  833. ////
  834. //// MessageMgr().on('Update Group List', updateGroupLastMsg);
  835. // getSystemMsg(null);
  836. //
  837. // tabCtrl = TabController(length: 2, vsync: this);
  838. // }
  839. //
  840. // @override
  841. // void dispose() {
  842. // tabCtrl.dispose();
  843. // MessageMgr().off('update_system', getSystemMsg);
  844. // super.dispose();
  845. // }
  846. //
  847. // @override
  848. // Widget build(BuildContext context) {
  849. //// List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  850. //
  851. // return Scaffold(
  852. // backgroundColor: Colors.white,
  853. // appBar: AppBar(
  854. // //backgroundColor: Constants.LightGreyBackgroundColor,
  855. // centerTitle: false,
  856. // title: Text(
  857. // I18n.of(context).message_center,
  858. // textScaleFactor: 1.0,
  859. // style: Constants.MainTitleStyle,
  860. // ),
  861. // actions: <Widget>[
  862. // Container(
  863. // child: IconButton(
  864. // icon: CircleAvatar(
  865. // backgroundColor: Constants.GreyBackgroundColor,
  866. // radius: 13.75,
  867. // child: Padding(
  868. // padding: EdgeInsets.only(bottom: 1.5),
  869. // child: Icon(
  870. // IconData(0xe659,
  871. // fontFamily: Constants.IconFontFamily),
  872. // color: Constants.BlackTextColor,
  873. // size: 21,
  874. // ))),
  875. // onPressed: () {
  876. // CustomUI().goScanPage(context);
  877. // },
  878. // ),
  879. // ),
  880. // // InkWell(
  881. // // onTap: () {
  882. // // Navigator.of(context).push(
  883. // // new MaterialPageRoute(
  884. // // builder: (context) {
  885. // // return MessagePushPage();
  886. // // },
  887. // // ),
  888. // // );
  889. // // },
  890. // // child: Padding(
  891. // // padding: EdgeInsets.only(right: 10),
  892. // // child: CircleAvatar(
  893. // // backgroundColor: Constants.GreyBackgroundColor,
  894. // // radius: 13.75,
  895. // // child: Icon(
  896. // // Icons.settings,
  897. // // color: Constants.BlackTextColor,
  898. // // size: 22,
  899. // // )),
  900. // // )),
  901. // ],
  902. // elevation: 0,
  903. // bottom: PreferredSize(
  904. // preferredSize: Size.fromHeight(28),
  905. // child: Container(
  906. // padding: EdgeInsets.only(left: 2),
  907. // decoration: BoxDecoration(
  908. // //color: Constants.LightGreyBackgroundColor,
  909. // border:
  910. // Border(bottom: BorderSide(color: Color(0xffeaeaea)))),
  911. // alignment: Alignment.centerLeft,
  912. // child: TabBar(
  913. // isScrollable: true,
  914. // indicatorPadding: EdgeInsets.only(left: 9, right: 9),
  915. // tabs: <Widget>[
  916. // UnreadDot(
  917. // child: Container(
  918. // margin: EdgeInsets.only(right: 4),
  919. // child: Text(I18n.of(context).text_chat,
  920. // textScaleFactor: 1.0),
  921. // ),
  922. // type: 1),
  923. //// UnreadDot(
  924. //// child: Container(
  925. //// margin: EdgeInsets.only(right: 4),
  926. //// child: Text(I18n.of(context).group_chat,
  927. //// textScaleFactor: 1.0),
  928. //// ),
  929. //// type: 4),
  930. // UnreadDot(
  931. // child: Container(
  932. // margin: EdgeInsets.only(right: 4),
  933. // child: Text(I18n.of(context).system_information,
  934. // textScaleFactor: 1.0)),
  935. // type: 2),
  936. // ],
  937. // controller: tabCtrl,
  938. // ),
  939. // )),
  940. // ),
  941. // body: SafeArea(
  942. // child: TabBarView(
  943. // children: <Widget>[
  944. // LastChatPage(),
  945. //// ListView.builder(
  946. ////// controller: _scrollController,
  947. //// itemBuilder: (BuildContext context, int index) {
  948. //// if (index == 0) {
  949. //// return _buildCreateButton();
  950. //// } else {
  951. //// var info = groupList[index - 1];
  952. //// return GroupItem(ValueKey(info), groupInfoModel: info);
  953. //// }
  954. //// },
  955. //// itemCount: groupList.length + 1,
  956. //// ),
  957. // ListView(
  958. // children: <Widget>[
  959. // SizedBox(height: 8.5),
  960. // _ConversationItem(
  961. // icon: 'assets/images/chat/icon1.png',
  962. // bgColor: Constants.RadioGradient,
  963. // conversation: Conversation(
  964. // avatar: 'assets/images/ic_tx_news.png',
  965. // title: I18n.of(context).radio_message,
  966. // desc: RichTitle.normalTitle(
  967. // systemInfo['castList'], context, InfoType.Radio),
  968. // updateAt: systemInfo['castList'] == null
  969. // ? ""
  970. // : WebData().getLoginTime(
  971. // context, systemInfo['castList']['CreateTime']),
  972. // unreadMsgCount: systemInfo['castCount'],
  973. // ),
  974. // callback: () {
  975. // setResNum(Constants.CastCount);
  976. // Navigator.of(context).push(
  977. // new MaterialPageRoute(
  978. // builder: (context) {
  979. // return InfoListPage(
  980. // title: I18n.of(context).radio_message,
  981. // type: InfoType.Radio,
  982. // );
  983. // },
  984. // ),
  985. // );
  986. // },
  987. // ),
  988. // _ConversationItem(
  989. // icon: 'assets/images/chat/icon4.png',
  990. // bgColor: Constants.MoneyGradient,
  991. // conversation: Conversation(
  992. // avatar: 'assets/images/ic_tx_news.png',
  993. // title: I18n.of(context).wallet_reminder,
  994. // desc: RichTitle.normalTitle(systemInfo['walletList'],
  995. // context, InfoType.IncomeMoney),
  996. // updateAt: systemInfo['walletList'] == null
  997. // ? ""
  998. // : WebData().getLoginTime(
  999. // context, systemInfo['walletList']['CreateTime']),
  1000. // unreadMsgCount: systemInfo['walletCount'],
  1001. // ),
  1002. // callback: () {
  1003. // setResNum(Constants.WalletCount);
  1004. // Navigator.of(context).push(
  1005. // new MaterialPageRoute(
  1006. // builder: (context) {
  1007. // return InfoListPage(
  1008. // title: I18n.of(context).wallet_reminder,
  1009. // type: InfoType.IncomeMoney,
  1010. // );
  1011. // },
  1012. // ),
  1013. // );
  1014. // },
  1015. // ),
  1016. // _ConversationItem(
  1017. // icon: 'assets/images/chat/icon3.png',
  1018. // iconSize: 27,
  1019. // bgColor: Constants.ApplyGradient,
  1020. // conversation: Conversation(
  1021. // avatar: 'assets/images/ic_tx_news.png',
  1022. // title: I18n.of(context).application_notice,
  1023. // desc: RichTitle.normalTitle(
  1024. // systemInfo['applyList'], context, InfoType.Apply),
  1025. // updateAt: systemInfo['applyList'] == null
  1026. // ? ""
  1027. // : WebData().getLoginTime(
  1028. // context, systemInfo['applyList']['CreatTime']),
  1029. // unreadMsgCount: systemInfo['applyCount'],
  1030. // ),
  1031. // callback: () {
  1032. // setResNum(Constants.ApplyCount);
  1033. // Navigator.of(context).push(
  1034. // new MaterialPageRoute(
  1035. // builder: (context) {
  1036. // return InfoListPage(
  1037. // title: I18n.of(context).application_notice,
  1038. // type: InfoType.Apply,
  1039. // );
  1040. // },
  1041. // ),
  1042. // );
  1043. // },
  1044. // ),
  1045. // _ConversationItem(
  1046. // icon: 'assets/images/chat/icon6.png',
  1047. // bgColor: Constants.EvaGradient,
  1048. // conversation: Conversation(
  1049. // avatar: 'assets/images/ic_tx_news.png',
  1050. // title: I18n.of(context).evaluation_notice,
  1051. // desc: RichTitle.normalTitle(systemInfo['evaluateList'],
  1052. // context, InfoType.Evaluation),
  1053. // updateAt: systemInfo['evaluateList'] == null
  1054. // ? ''
  1055. // : WebData().getLoginTime(
  1056. // context, systemInfo['evaluateList']['CreateTime']),
  1057. // unreadMsgCount: systemInfo['evaluateCount'],
  1058. // ),
  1059. // callback: () {
  1060. // setResNum(Constants.EvaluateCount);
  1061. // Navigator.of(context).push(
  1062. // new MaterialPageRoute(
  1063. // builder: (context) {
  1064. // return InfoListPage(
  1065. // title: I18n.of(context).evaluation_notice,
  1066. // type: 2,
  1067. // );
  1068. // },
  1069. // ),
  1070. // );
  1071. // },
  1072. // ),
  1073. // _ConversationItem(
  1074. // icon: 'assets/images/chat/icon5.png',
  1075. // bgColor: Constants.ParkGradient,
  1076. // conversation: Conversation(
  1077. // avatar: 'assets/images/ic_tx_news.png',
  1078. // title: I18n.of(context).appName,
  1079. // desc: RichTitle.normalTitle(
  1080. // systemInfo['parkList'], context, InfoType.System),
  1081. // updateAt: systemInfo['parkList'] == null
  1082. // ? ""
  1083. // : WebData().getLoginTime(
  1084. // context, systemInfo['parkList']['CreateTime']),
  1085. // unreadMsgCount: systemInfo['parkCount'],
  1086. // ),
  1087. // callback: () {
  1088. // setResNum(Constants.ParkCount);
  1089. // Navigator.of(context).push(
  1090. // new MaterialPageRoute(
  1091. // builder: (context) {
  1092. // return InfoListPage(
  1093. // title: I18n.of(context).appName,
  1094. // type: InfoType.System,
  1095. // );
  1096. // },
  1097. // ),
  1098. // );
  1099. // },
  1100. // )
  1101. // ],
  1102. // )
  1103. // ],
  1104. // controller: tabCtrl,
  1105. // )));
  1106. // }
  1107. //
  1108. // Widget _buildCreateButton() {
  1109. // List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  1110. // Widget _avatarIcon = ClipRRect(
  1111. // borderRadius: BorderRadius.circular(GroupRadius),
  1112. // child: Container(
  1113. // color: const Color(0xFFF2F2F2),
  1114. // height: AvatarSize,
  1115. // width: AvatarSize,
  1116. // child: Icon(
  1117. // IconData(0xe66f, fontFamily: Constants.IconFontFamily),
  1118. // color: Constants.BlueTextColor,
  1119. // size: 35,
  1120. // ),
  1121. // ));
  1122. //
  1123. // Widget _button = InkWell(
  1124. // onTap: () {
  1125. // Navigator.of(context).push(
  1126. // new MaterialPageRoute(
  1127. // builder: (context) {
  1128. // return CreateGroupPage(
  1129. // GroupOperatingPageType.CreateGroup, [], null);
  1130. // },
  1131. // ),
  1132. // );
  1133. // },
  1134. // child: Container(
  1135. // padding: EdgeInsets.only(top: 14, bottom: 14),
  1136. // color: Constants.GreyBackgroundColor,
  1137. // child: Container(
  1138. // height: ItemHeight,
  1139. // decoration: BoxDecoration(color: Colors.white),
  1140. // child: Row(
  1141. // children: <Widget>[
  1142. // SizedBox(width: LeftPadding),
  1143. // _avatarIcon,
  1144. // SizedBox(width: 14.0),
  1145. // Text(
  1146. // I18n.of(context).create_group_chat,
  1147. // textScaleFactor: 1.0,
  1148. // style: TextStyle(fontSize: 15.5),
  1149. // ),
  1150. // ],
  1151. // ),
  1152. // )));
  1153. //
  1154. // Widget tips = Container(
  1155. // alignment: Alignment.centerLeft,
  1156. // width: Screen.width,
  1157. // height: 33.5,
  1158. // padding: EdgeInsets.only(left: LeftPadding),
  1159. // decoration: BoxDecoration(
  1160. // color: Colors.white,
  1161. // border: Border(bottom: Constants.GreyBorderSide)),
  1162. // child: Text(
  1163. // I18n.of(context).group_chat + '(${groupList.length})',
  1164. // textScaleFactor: 1.0,
  1165. // ),
  1166. // );
  1167. //
  1168. // return Column(
  1169. // children: <Widget>[
  1170. // SizedBox(
  1171. // height: 10,
  1172. // ),
  1173. // CustomUI.buildSearchButton(context, () {
  1174. // Navigator.of(context).push(
  1175. // new MaterialPageRoute(
  1176. // builder: (context) {
  1177. // return GlobalSearchPage(
  1178. // type: GlobalSearchPageType.SearchGroup,
  1179. // );
  1180. // },
  1181. // ),
  1182. // );
  1183. // }, bottom: 10),
  1184. // _button,
  1185. // tips,
  1186. // ],
  1187. // );
  1188. // }
  1189. //
  1190. //// quitGroup(args) {
  1191. //// if (mounted) {
  1192. //// setState(() {
  1193. //// print('更新群列表');
  1194. //// });
  1195. //// }
  1196. //// }
  1197. ////
  1198. //// updateGroupLastMsg(args) async {
  1199. //// await GroupInfoMgr().sortGroupList();
  1200. //// if (mounted) {
  1201. //// setState(() {});
  1202. //// }
  1203. //// }
  1204. //}