Hibok
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 
 

1161 linhas
41 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. CustomUI.buildCircleIconButton(0xe659,
  256. onPressed: () => CustomUI().goScanPage(context))
  257. ],
  258. elevation: 0,
  259. bottom: PreferredSize(
  260. preferredSize: Size.fromHeight(28),
  261. child: Container(
  262. padding: EdgeInsets.only(left: 2),
  263. decoration: BoxDecoration(
  264. //color: Constants.LightGreyBackgroundColor,
  265. border:
  266. Border(bottom: BorderSide(color: Color(0xffeaeaea)))),
  267. alignment: Alignment.centerLeft,
  268. child: TabBar(
  269. isScrollable: true,
  270. indicatorPadding: EdgeInsets.only(left: 9, right: 9),
  271. tabs: <Widget>[
  272. UnreadDot(
  273. child: Container(
  274. margin: EdgeInsets.only(right: 4),
  275. child: Text(I18n.of(context).text_chat,
  276. textScaleFactor: 1.0),
  277. ),
  278. type: 1),
  279. UnreadDot(
  280. child: Container(
  281. margin: EdgeInsets.only(right: 4),
  282. child: Text(I18n.of(context).group_chat,
  283. textScaleFactor: 1.0),
  284. ),
  285. type: 4),
  286. UnreadDot(
  287. child: Container(
  288. margin: EdgeInsets.only(right: 4),
  289. child: Text(I18n.of(context).system_information,
  290. textScaleFactor: 1.0)),
  291. type: 2),
  292. ],
  293. controller: tabCtrl,
  294. ),
  295. )),
  296. ),
  297. body: SafeArea(
  298. child: TabBarView(
  299. children: <Widget>[
  300. LastChatPage(),
  301. ListView.builder(
  302. // controller: _scrollController,
  303. itemBuilder: (BuildContext context, int index) {
  304. if (index == 0) {
  305. return _buildCreateButton();
  306. } else {
  307. var info = groupList[index - 1];
  308. return GroupItem(ValueKey(info), groupInfoModel: info);
  309. }
  310. },
  311. itemCount: groupList.length + 1,
  312. ),
  313. ListView(
  314. children: <Widget>[
  315. SizedBox(height: 8.5),
  316. _ConversationItem(
  317. icon: 'assets/images/chat/icon1.png',
  318. bgColor: Constants.RadioGradient,
  319. conversation: Conversation(
  320. avatar: 'assets/images/ic_tx_news.png',
  321. title: I18n.of(context).radio_message,
  322. desc: RichTitle.normalTitle(
  323. systemInfo['castList'], context, InfoType.Radio),
  324. updateAt: systemInfo['castList'] == null
  325. ? ""
  326. : WebData().getLoginTime(
  327. context, systemInfo['castList']['CreateTime']),
  328. unreadMsgCount: systemInfo['castCount'],
  329. ),
  330. callback: () {
  331. setResNum(Constants.CastCount);
  332. Navigator.of(context).push(
  333. new MaterialPageRoute(
  334. builder: (context) {
  335. return InfoListPage(
  336. title: I18n.of(context).radio_message,
  337. type: InfoType.Radio,
  338. );
  339. },
  340. ),
  341. );
  342. },
  343. ),
  344. _ConversationItem(
  345. icon: 'assets/images/chat/icon4.png',
  346. bgColor: Constants.MoneyGradient,
  347. conversation: Conversation(
  348. avatar: 'assets/images/ic_tx_news.png',
  349. title: I18n.of(context).wallet_reminder,
  350. desc: RichTitle.normalTitle(systemInfo['walletList'],
  351. context, InfoType.IncomeMoney),
  352. updateAt: systemInfo['walletList'] == null
  353. ? ""
  354. : WebData().getLoginTime(
  355. context, systemInfo['walletList']['CreateTime']),
  356. unreadMsgCount: systemInfo['walletCount'],
  357. ),
  358. callback: () {
  359. setResNum(Constants.WalletCount);
  360. Navigator.of(context).push(
  361. new MaterialPageRoute(
  362. builder: (context) {
  363. return InfoListPage(
  364. title: I18n.of(context).wallet_reminder,
  365. type: InfoType.IncomeMoney,
  366. );
  367. },
  368. ),
  369. );
  370. },
  371. ),
  372. _ConversationItem(
  373. icon: 'assets/images/chat/icon3.png',
  374. iconSize: 27,
  375. bgColor: Constants.ApplyGradient,
  376. conversation: Conversation(
  377. avatar: 'assets/images/ic_tx_news.png',
  378. title: I18n.of(context).application_notice,
  379. desc: RichTitle.normalTitle(
  380. systemInfo['applyList'], context, InfoType.Apply),
  381. updateAt: systemInfo['applyList'] == null
  382. ? ""
  383. : WebData().getLoginTime(
  384. context, systemInfo['applyList']['CreatTime']),
  385. unreadMsgCount: systemInfo['applyCount'],
  386. ),
  387. callback: () {
  388. setResNum(Constants.ApplyCount);
  389. Navigator.of(context).push(
  390. new MaterialPageRoute(
  391. builder: (context) {
  392. return InfoListPage(
  393. title: I18n.of(context).application_notice,
  394. type: InfoType.Apply,
  395. );
  396. },
  397. ),
  398. );
  399. },
  400. ),
  401. _ConversationItem(
  402. icon: 'assets/images/chat/icon6.png',
  403. bgColor: Constants.EvaGradient,
  404. conversation: Conversation(
  405. avatar: 'assets/images/ic_tx_news.png',
  406. title: I18n.of(context).evaluation_notice,
  407. desc: RichTitle.normalTitle(systemInfo['evaluateList'],
  408. context, InfoType.Evaluation),
  409. updateAt: systemInfo['evaluateList'] == null
  410. ? ''
  411. : WebData().getLoginTime(
  412. context, systemInfo['evaluateList']['CreateTime']),
  413. unreadMsgCount: systemInfo['evaluateCount'],
  414. ),
  415. callback: () {
  416. setResNum(Constants.EvaluateCount);
  417. Navigator.of(context).push(
  418. new MaterialPageRoute(
  419. builder: (context) {
  420. return InfoListPage(
  421. title: I18n.of(context).evaluation_notice,
  422. type: 2,
  423. );
  424. },
  425. ),
  426. );
  427. },
  428. ),
  429. _ConversationItem(
  430. icon: 'assets/images/chat/icon5.png',
  431. bgColor: Constants.ParkGradient,
  432. conversation: Conversation(
  433. avatar: 'assets/images/ic_tx_news.png',
  434. title: I18n.of(context).appName,
  435. desc: RichTitle.normalTitle(
  436. systemInfo['parkList'], context, InfoType.System),
  437. updateAt: systemInfo['parkList'] == null
  438. ? ""
  439. : WebData().getLoginTime(
  440. context, systemInfo['parkList']['CreateTime']),
  441. unreadMsgCount: systemInfo['parkCount'],
  442. ),
  443. callback: () {
  444. setResNum(Constants.ParkCount);
  445. Navigator.of(context).push(
  446. new MaterialPageRoute(
  447. builder: (context) {
  448. return InfoListPage(
  449. title: I18n.of(context).appName,
  450. type: InfoType.System,
  451. );
  452. },
  453. ),
  454. );
  455. },
  456. )
  457. ],
  458. )
  459. ],
  460. controller: tabCtrl,
  461. )));
  462. }
  463. Widget _buildCreateButton() {
  464. List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  465. Widget _avatarIcon = ClipRRect(
  466. borderRadius: BorderRadius.circular(GroupRadius),
  467. child: Container(
  468. color: const Color(0xFFF2F2F2),
  469. height: AvatarSize,
  470. width: AvatarSize,
  471. child: Icon(
  472. IconData(0xe66f, fontFamily: Constants.IconFontFamily),
  473. color: Constants.BlueTextColor,
  474. size: 35,
  475. ),
  476. ));
  477. Widget _button = InkWell(
  478. onTap: () {
  479. Navigator.of(context).push(
  480. new MaterialPageRoute(
  481. builder: (context) {
  482. return CreateGroupPage(
  483. GroupOperatingPageType.CreateGroup, [], null);
  484. },
  485. ),
  486. );
  487. },
  488. child: Container(
  489. padding: EdgeInsets.only(top: 14, bottom: 14),
  490. color: Constants.GreyBackgroundColor,
  491. child: Container(
  492. height: ItemHeight,
  493. decoration: BoxDecoration(color: Colors.white),
  494. child: Row(
  495. children: <Widget>[
  496. SizedBox(width: LeftPadding),
  497. _avatarIcon,
  498. SizedBox(width: 14.0),
  499. Text(
  500. I18n.of(context).create_group_chat,
  501. style: TextStyle(fontSize: 15.5),
  502. ),
  503. ],
  504. ),
  505. )));
  506. Widget tips = Container(
  507. alignment: Alignment.centerLeft,
  508. width: Screen.width,
  509. height: 33.5,
  510. padding: EdgeInsets.only(left: LeftPadding),
  511. decoration: BoxDecoration(
  512. color: Colors.white,
  513. border: Border(bottom: Constants.GreyBorderSide)),
  514. child: Text(I18n.of(context).group_chat + '(${groupList.length})'),
  515. );
  516. return Column(
  517. children: <Widget>[
  518. SizedBox(
  519. height: 10,
  520. ),
  521. CustomUI.buildSearchButton(context, () {
  522. Navigator.of(context).push(
  523. new MaterialPageRoute(
  524. builder: (context) {
  525. return GlobalSearchPage(
  526. type: GlobalSearchPageType.SearchGroup,
  527. );
  528. },
  529. ),
  530. );
  531. }, bottom: 10),
  532. _button,
  533. tips,
  534. ],
  535. );
  536. }
  537. quitGroup(args) {
  538. if (mounted) {
  539. setState(() {
  540. print('更新群列表');
  541. });
  542. }
  543. }
  544. updateGroupLastMsg(args) async {
  545. await GroupInfoMgr().sortGroupList();
  546. if (mounted) {
  547. setState(() {});
  548. }
  549. }
  550. }
  551. // import 'package:chat/data/UserData.dart';
  552. // import 'package:chat/data/WebData.dart';
  553. // import 'package:chat/data/conversation.dart';
  554. // import 'package:chat/data/group_data_mgr.dart';
  555. // import 'package:chat/generated/i18n.dart';
  556. // import 'package:chat/home/InfoList.dart';
  557. // import 'package:chat/home/last_chat_record_widget.dart';
  558. // import 'package:chat/home/rich_title.dart';
  559. // import 'package:chat/home/unread_dot_widget.dart';
  560. // import 'package:chat/models/group_info_model.dart';
  561. // import 'package:chat/utils/CustomUI.dart';
  562. // import 'package:chat/utils/HttpUtil.dart';
  563. // import 'package:chat/utils/MessageMgr.dart';
  564. // import 'package:chat/utils/TokenMgr.dart';
  565. // import 'package:chat/utils/screen.dart';
  566. // import 'package:dio/dio.dart';
  567. // import 'package:flutter/cupertino.dart';
  568. // import 'package:flutter/material.dart';
  569. // import 'package:shared_preferences/shared_preferences.dart';
  570. // import '../data/constants.dart'
  571. // show
  572. // AppColors,
  573. // AppStyles,
  574. // Constants,
  575. // GlobalSearchPageType,
  576. // GroupOperatingPageType;
  577. // import 'package:cached_network_image/cached_network_image.dart';
  578. // import 'create_group_view.dart';
  579. // import 'global_search.dart';
  580. // import 'group_item_widget.dart';
  581. // class _ConversationItem extends StatelessWidget {
  582. // const _ConversationItem(
  583. // {Key key,
  584. // this.conversation,
  585. // this.callback,
  586. // this.icon,
  587. // this.bgColor,
  588. // this.iconSize = 20})
  589. // : assert(conversation != null),
  590. // super(key: key);
  591. // final icon;
  592. // final double iconSize;
  593. // final Conversation conversation;
  594. // final callback;
  595. // final bgColor;
  596. // @override
  597. // Widget build(BuildContext context) {
  598. // Widget avatar;
  599. // if (icon != null) {
  600. // avatar = Container(
  601. // height: 47.5,
  602. // width: 47.5,
  603. // margin: EdgeInsets.only(left: 6),
  604. // alignment: Alignment.center,
  605. // decoration: BoxDecoration(
  606. // gradient: bgColor,
  607. // borderRadius: BorderRadius.all(Radius.circular(50))),
  608. // child: Image.asset(
  609. // icon,
  610. // height: iconSize,
  611. // ));
  612. // } else if (conversation.isAvatarFromNet()) {
  613. // avatar = CachedNetworkImage(
  614. // imageUrl: conversation.avatar,
  615. // placeholder: CustomUI.buildImgLoding,
  616. // width: Constants.ConversationAvatarSize,
  617. // height: Constants.ConversationAvatarSize,
  618. // );
  619. // } else {
  620. // avatar = Image.asset(
  621. // conversation.avatar,
  622. // width: Constants.ConversationAvatarSize,
  623. // height: Constants.ConversationAvatarSize,
  624. // );
  625. // }
  626. // List<Widget> _rightArea = [
  627. // Container(
  628. // padding: EdgeInsets.only(top: 4),
  629. // alignment: Alignment.center,
  630. // child: Text(conversation.updateAt,
  631. // textScaleFactor: 1.0,
  632. // style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))),
  633. // )
  634. // ];
  635. // if (conversation.unreadMsgCount > 0) {
  636. // var countStr = conversation.unreadMsgCount.toString();
  637. // if (conversation.unreadMsgCount > 99) {
  638. // countStr = '99+';
  639. // }
  640. // // 未读消息角标
  641. // Widget unreadMsgCountText = Container(
  642. // width: Constants.UnReadMsgNotifyDotSize,
  643. // height: Constants.UnReadMsgNotifyDotSize,
  644. // alignment: Alignment.center,
  645. // decoration: BoxDecoration(
  646. // borderRadius:
  647. // BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0),
  648. // color: Color(0xFFFF5454),
  649. // ),
  650. // child: Text(countStr,
  651. // textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle),
  652. // );
  653. // _rightArea.add(Expanded(
  654. // child: Align(
  655. // alignment: Alignment.bottomCenter,
  656. // child: unreadMsgCountText,
  657. // )));
  658. // }
  659. // return InkWell(
  660. // child: Container(
  661. // padding: const EdgeInsets.all(10.0),
  662. // decoration: BoxDecoration(
  663. // color: Color(AppColors.ConversationItemBgColor),
  664. // ),
  665. // child: Row(
  666. // crossAxisAlignment: CrossAxisAlignment.center,
  667. // children: <Widget>[
  668. // avatar,
  669. // Container(width: 17.0),
  670. // Expanded(
  671. // child: Column(
  672. // crossAxisAlignment: CrossAxisAlignment.start,
  673. // children: <Widget>[
  674. // Text(conversation.title,
  675. // textScaleFactor: 1.0,
  676. // style: TextStyle(
  677. // color: Colors.black,
  678. // )),
  679. // SizedBox(
  680. // height: 5,
  681. // ),
  682. // Text(conversation.desc,
  683. // textScaleFactor: 1.0,
  684. // style: TextStyle(
  685. // fontSize: 12, color: const Color(0xFF9B9B9B)))
  686. // ],
  687. // ),
  688. // ),
  689. // // Container(width: 10.0),
  690. // SizedBox(
  691. // height: Constants.ConversationAvatarSize,
  692. // child: Column(
  693. // crossAxisAlignment: CrossAxisAlignment.end,
  694. // mainAxisAlignment: MainAxisAlignment.start,
  695. // children: _rightArea,
  696. // ),
  697. // )
  698. // ],
  699. // ),
  700. // ),
  701. // onTap: () {
  702. // callback();
  703. // },
  704. // );
  705. // }
  706. // }
  707. // class ConversActionPage extends StatefulWidget {
  708. // ConversActionPage({Key key}) : super(key: key);
  709. // _ConversActionPageState createState() => _ConversActionPageState();
  710. // }
  711. // Map systemInfo = {
  712. // 'applyList': null,
  713. // 'applyCount': 0,
  714. // 'evaluateList': null,
  715. // 'evaluateCount': 0,
  716. // 'parkList': null,
  717. // 'parkCount': 0,
  718. // 'castList': null,
  719. // 'castCount': 0,
  720. // 'walletList': null,
  721. // 'walletCount': 0,
  722. // };
  723. // int msgNum = 0;
  724. // bool isShowMsg() {
  725. // return msgNum > 0;
  726. // }
  727. // getAllResNum(prefs) {
  728. // getResNum(prefs, Constants.ApplyCount);
  729. // getResNum(prefs, Constants.EvaluateCount);
  730. // getResNum(prefs, Constants.ParkCount);
  731. // getResNum(prefs, Constants.CastCount);
  732. // getResNum(prefs, Constants.WalletCount);
  733. // }
  734. // getResNum(prefs, url) async {
  735. // var count = prefs.getInt(url + UserData().basicInfo.userId.toString());
  736. // systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count);
  737. // msgNum += systemInfo[url];
  738. // }
  739. // setResNum(url) async {
  740. // var localKey = url + UserData().basicInfo.userId.toString();
  741. // if (systemInfo[url] > 0) {
  742. // SharedPreferences prefs = await SharedPreferences.getInstance();
  743. // var count = prefs.getInt(localKey);
  744. // prefs.setInt(
  745. // localKey, count == null ? systemInfo[url] : (systemInfo[url] + count));
  746. // msgNum -= systemInfo[url];
  747. // systemInfo[url] = 0;
  748. // }
  749. // }
  750. // class _ConversActionPageState extends State<ConversActionPage>
  751. // with SingleTickerProviderStateMixin {
  752. // TabController tabCtrl;
  753. // void getSystemMsg(data) async {
  754. // Map data = {
  755. // "userId": UserData().basicInfo.userId,
  756. // "type": UserData().basicInfo.sex
  757. // };
  758. // data['sign'] = TokenMgr().getSign(data);
  759. // Response res = await HttpUtil().post('message/all/message', data: data);
  760. // if (res == null) {
  761. // return;
  762. // }
  763. // Map resData = res.data;
  764. // if (resData['code'] == 0) {
  765. // SharedPreferences prefs = await SharedPreferences.getInstance();
  766. // systemInfo = resData['data'];
  767. // msgNum = 0;
  768. // getAllResNum(prefs);
  769. // if (mounted) {
  770. // setState(() {});
  771. // }
  772. // }
  773. // }
  774. // @override
  775. // void initState() {
  776. // super.initState();
  777. // MessageMgr().on('update_system', getSystemMsg);
  778. // // MessageMgr().on('Quit Group', quitGroup);
  779. // //
  780. // // MessageMgr().on('Update Group List', updateGroupLastMsg);
  781. // getSystemMsg(null);
  782. // tabCtrl = TabController(length: 2, vsync: this);
  783. // }
  784. // @override
  785. // void dispose() {
  786. // tabCtrl.dispose();
  787. // MessageMgr().off('update_system', getSystemMsg);
  788. // super.dispose();
  789. // }
  790. // @override
  791. // Widget build(BuildContext context) {
  792. // // List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  793. // return Scaffold(
  794. // backgroundColor: Colors.white,
  795. // appBar: AppBar(
  796. // //backgroundColor: Constants.LightGreyBackgroundColor,
  797. // centerTitle: false,
  798. // title: Text(
  799. // I18n.of(context).message_center,
  800. // textScaleFactor: 1.0,
  801. // style: Constants.MainTitleStyle,
  802. // ),
  803. // actions: <Widget>[
  804. // CustomUI.buildCircleIconButton(0xe659,
  805. // onPressed: () => CustomUI().goScanPage(context))
  806. // ],
  807. // elevation: 0,
  808. // bottom: PreferredSize(
  809. // preferredSize: Size.fromHeight(28),
  810. // child: Container(
  811. // padding: EdgeInsets.only(left: 2),
  812. // decoration: BoxDecoration(
  813. // //color: Constants.LightGreyBackgroundColor,
  814. // border:
  815. // Border(bottom: BorderSide(color: Color(0xffeaeaea)))),
  816. // alignment: Alignment.centerLeft,
  817. // child: TabBar(
  818. // isScrollable: true,
  819. // indicatorPadding: EdgeInsets.only(left: 9, right: 9),
  820. // tabs: <Widget>[
  821. // UnreadDot(
  822. // child: Container(
  823. // margin: EdgeInsets.only(right: 4),
  824. // child: Text(I18n.of(context).text_chat,
  825. // textScaleFactor: 1.0),
  826. // ),
  827. // type: 1),
  828. // // UnreadDot(
  829. // // child: Container(
  830. // // margin: EdgeInsets.only(right: 4),
  831. // // child: Text(I18n.of(context).group_chat,
  832. // // textScaleFactor: 1.0),
  833. // // ),
  834. // // type: 4),
  835. // UnreadDot(
  836. // child: Container(
  837. // margin: EdgeInsets.only(right: 4),
  838. // child: Text(I18n.of(context).system_information,
  839. // textScaleFactor: 1.0)),
  840. // type: 2),
  841. // ],
  842. // controller: tabCtrl,
  843. // ),
  844. // )),
  845. // ),
  846. // body: SafeArea(
  847. // child: TabBarView(
  848. // children: <Widget>[
  849. // LastChatPage(),
  850. // // ListView.builder(
  851. // //// controller: _scrollController,
  852. // // itemBuilder: (BuildContext context, int index) {
  853. // // if (index == 0) {
  854. // // return _buildCreateButton();
  855. // // } else {
  856. // // var info = groupList[index - 1];
  857. // // return GroupItem(ValueKey(info), groupInfoModel: info);
  858. // // }
  859. // // },
  860. // // itemCount: groupList.length + 1,
  861. // // ),
  862. // ListView(
  863. // children: <Widget>[
  864. // SizedBox(height: 8.5),
  865. // _ConversationItem(
  866. // icon: 'assets/images/chat/icon1.png',
  867. // bgColor: Constants.RadioGradient,
  868. // conversation: Conversation(
  869. // avatar: 'assets/images/ic_tx_news.png',
  870. // title: I18n.of(context).radio_message,
  871. // desc: RichTitle.normalTitle(
  872. // systemInfo['castList'], context, InfoType.Radio),
  873. // updateAt: systemInfo['castList'] == null
  874. // ? ""
  875. // : WebData().getLoginTime(
  876. // context, systemInfo['castList']['CreateTime']),
  877. // unreadMsgCount: systemInfo['castCount'],
  878. // ),
  879. // callback: () {
  880. // setResNum(Constants.CastCount);
  881. // Navigator.of(context).push(
  882. // new MaterialPageRoute(
  883. // builder: (context) {
  884. // return InfoListPage(
  885. // title: I18n.of(context).radio_message,
  886. // type: InfoType.Radio,
  887. // );
  888. // },
  889. // ),
  890. // );
  891. // },
  892. // ),
  893. // _ConversationItem(
  894. // icon: 'assets/images/chat/icon4.png',
  895. // bgColor: Constants.MoneyGradient,
  896. // conversation: Conversation(
  897. // avatar: 'assets/images/ic_tx_news.png',
  898. // title: I18n.of(context).wallet_reminder,
  899. // desc: RichTitle.normalTitle(systemInfo['walletList'],
  900. // context, InfoType.IncomeMoney),
  901. // updateAt: systemInfo['walletList'] == null
  902. // ? ""
  903. // : WebData().getLoginTime(
  904. // context, systemInfo['walletList']['CreateTime']),
  905. // unreadMsgCount: systemInfo['walletCount'],
  906. // ),
  907. // callback: () {
  908. // setResNum(Constants.WalletCount);
  909. // Navigator.of(context).push(
  910. // new MaterialPageRoute(
  911. // builder: (context) {
  912. // return InfoListPage(
  913. // title: I18n.of(context).wallet_reminder,
  914. // type: InfoType.IncomeMoney,
  915. // );
  916. // },
  917. // ),
  918. // );
  919. // },
  920. // ),
  921. // _ConversationItem(
  922. // icon: 'assets/images/chat/icon3.png',
  923. // iconSize: 27,
  924. // bgColor: Constants.ApplyGradient,
  925. // conversation: Conversation(
  926. // avatar: 'assets/images/ic_tx_news.png',
  927. // title: I18n.of(context).application_notice,
  928. // desc: RichTitle.normalTitle(
  929. // systemInfo['applyList'], context, InfoType.Apply),
  930. // updateAt: systemInfo['applyList'] == null
  931. // ? ""
  932. // : WebData().getLoginTime(
  933. // context, systemInfo['applyList']['CreatTime']),
  934. // unreadMsgCount: systemInfo['applyCount'],
  935. // ),
  936. // callback: () {
  937. // setResNum(Constants.ApplyCount);
  938. // Navigator.of(context).push(
  939. // new MaterialPageRoute(
  940. // builder: (context) {
  941. // return InfoListPage(
  942. // title: I18n.of(context).application_notice,
  943. // type: InfoType.Apply,
  944. // );
  945. // },
  946. // ),
  947. // );
  948. // },
  949. // ),
  950. // _ConversationItem(
  951. // icon: 'assets/images/chat/icon6.png',
  952. // bgColor: Constants.EvaGradient,
  953. // conversation: Conversation(
  954. // avatar: 'assets/images/ic_tx_news.png',
  955. // title: I18n.of(context).evaluation_notice,
  956. // desc: RichTitle.normalTitle(systemInfo['evaluateList'],
  957. // context, InfoType.Evaluation),
  958. // updateAt: systemInfo['evaluateList'] == null
  959. // ? ''
  960. // : WebData().getLoginTime(
  961. // context, systemInfo['evaluateList']['CreateTime']),
  962. // unreadMsgCount: systemInfo['evaluateCount'],
  963. // ),
  964. // callback: () {
  965. // setResNum(Constants.EvaluateCount);
  966. // Navigator.of(context).push(
  967. // new MaterialPageRoute(
  968. // builder: (context) {
  969. // return InfoListPage(
  970. // title: I18n.of(context).evaluation_notice,
  971. // type: 2,
  972. // );
  973. // },
  974. // ),
  975. // );
  976. // },
  977. // ),
  978. // _ConversationItem(
  979. // icon: 'assets/images/chat/icon5.png',
  980. // bgColor: Constants.ParkGradient,
  981. // conversation: Conversation(
  982. // avatar: 'assets/images/ic_tx_news.png',
  983. // title: I18n.of(context).appName,
  984. // desc: RichTitle.normalTitle(
  985. // systemInfo['parkList'], context, InfoType.System),
  986. // updateAt: systemInfo['parkList'] == null
  987. // ? ""
  988. // : WebData().getLoginTime(
  989. // context, systemInfo['parkList']['CreateTime']),
  990. // unreadMsgCount: systemInfo['parkCount'],
  991. // ),
  992. // callback: () {
  993. // setResNum(Constants.ParkCount);
  994. // Navigator.of(context).push(
  995. // new MaterialPageRoute(
  996. // builder: (context) {
  997. // return InfoListPage(
  998. // title: I18n.of(context).appName,
  999. // type: InfoType.System,
  1000. // );
  1001. // },
  1002. // ),
  1003. // );
  1004. // },
  1005. // )
  1006. // ],
  1007. // )
  1008. // ],
  1009. // controller: tabCtrl,
  1010. // )));
  1011. // }
  1012. // Widget _buildCreateButton() {
  1013. // List<GroupInfoModel> groupList = GroupInfoMgr().groupInfoList;
  1014. // Widget _avatarIcon = ClipRRect(
  1015. // borderRadius: BorderRadius.circular(GroupRadius),
  1016. // child: Container(
  1017. // color: const Color(0xFFF2F2F2),
  1018. // height: AvatarSize,
  1019. // width: AvatarSize,
  1020. // child: Icon(
  1021. // IconData(0xe66f, fontFamily: Constants.IconFontFamily),
  1022. // color: Constants.BlueTextColor,
  1023. // size: 35,
  1024. // ),
  1025. // ));
  1026. // Widget _button = InkWell(
  1027. // onTap: () {
  1028. // Navigator.of(context).push(
  1029. // new MaterialPageRoute(
  1030. // builder: (context) {
  1031. // return CreateGroupPage(
  1032. // GroupOperatingPageType.CreateGroup, [], null);
  1033. // },
  1034. // ),
  1035. // );
  1036. // },
  1037. // child: Container(
  1038. // padding: EdgeInsets.only(top: 14, bottom: 14),
  1039. // color: Constants.GreyBackgroundColor,
  1040. // child: Container(
  1041. // height: ItemHeight,
  1042. // decoration: BoxDecoration(color: Colors.white),
  1043. // child: Row(
  1044. // children: <Widget>[
  1045. // SizedBox(width: LeftPadding),
  1046. // _avatarIcon,
  1047. // SizedBox(width: 14.0),
  1048. // Text(
  1049. // I18n.of(context).create_group_chat,
  1050. // textScaleFactor: 1.0,
  1051. // style: TextStyle(fontSize: 15.5),
  1052. // ),
  1053. // ],
  1054. // ),
  1055. // )));
  1056. // Widget tips = Container(
  1057. // alignment: Alignment.centerLeft,
  1058. // width: Screen.width,
  1059. // height: 33.5,
  1060. // padding: EdgeInsets.only(left: LeftPadding),
  1061. // decoration: BoxDecoration(
  1062. // color: Colors.white,
  1063. // border: Border(bottom: Constants.GreyBorderSide)),
  1064. // child: Text(
  1065. // I18n.of(context).group_chat + '(${groupList.length})',
  1066. // textScaleFactor: 1.0,
  1067. // ),
  1068. // );
  1069. // return Column(
  1070. // children: <Widget>[
  1071. // SizedBox(
  1072. // height: 10,
  1073. // ),
  1074. // CustomUI.buildSearchButton(context, () {
  1075. // Navigator.of(context).push(
  1076. // new MaterialPageRoute(
  1077. // builder: (context) {
  1078. // return GlobalSearchPage(
  1079. // type: GlobalSearchPageType.SearchGroup,
  1080. // );
  1081. // },
  1082. // ),
  1083. // );
  1084. // }, bottom: 10),
  1085. // _button,
  1086. // tips,
  1087. // ],
  1088. // );
  1089. // }
  1090. // // quitGroup(args) {
  1091. // // if (mounted) {
  1092. // // setState(() {
  1093. // // print('更新群列表');
  1094. // // });
  1095. // // }
  1096. // // }
  1097. // //
  1098. // // updateGroupLastMsg(args) async {
  1099. // // await GroupInfoMgr().sortGroupList();
  1100. // // if (mounted) {
  1101. // // setState(() {});
  1102. // // }
  1103. // // }
  1104. // }