From 2c1e8cd6915e734a056d45b9d87d6a0963cdfbc5 Mon Sep 17 00:00:00 2001 From: ZCM <772112648@qq.com> Date: Thu, 16 Apr 2020 18:45:56 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=AE=A4=E8=AF=81=E8=A7=86=E9=A2=91=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E5=B0=86=E8=AE=A4=E8=AF=81=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=88=B0=E6=9C=AC=E5=9C=B0=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E9=AB=98=E8=AE=BF=E9=97=AE=E6=95=88=E7=8E=87=202.=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E7=BE=A4=E8=81=8A=E7=82=B9=E5=8A=A0=E5=85=A5=E6=97=A0?= =?UTF-8?q?=E5=8F=8D=E5=BA=94=EF=BC=8C=E6=8C=89=E9=92=AE=E6=B2=A1=E5=8F=98?= =?UTF-8?q?=E8=89=B2=EF=BC=8C=E5=AE=9E=E9=99=85=E5=B7=B2=E7=BB=8F=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=203.=E5=8D=B8=E8=BD=BD=E9=87=8D=E8=A3=85=E5=90=8E?= =?UTF-8?q?=E5=8E=9F=E6=9C=AC=E6=B7=BB=E5=8A=A0=E8=BF=87=E5=BE=97=E5=A5=BD?= =?UTF-8?q?=E5=8F=8B=EF=BC=8C=E5=8F=88=E6=98=BE=E7=A4=BA=E5=9C=A8=E7=94=B3?= =?UTF-8?q?=E8=AF=B7=E5=88=97=E8=A1=A8=E4=B8=8A=20=E7=BD=91=E7=BB=9C?= =?UTF-8?q?=E5=BB=B6=E8=BF=9F=E4=B8=8B=E8=A7=A3=E9=94=81=E7=BA=A2=E5=8C=85?= =?UTF-8?q?=E7=85=A7=E7=89=87=E4=B8=A4=E6=AC=A1=E5=87=BA=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- i18n/vi-VN.json | 2 +- lib/chat/ChatPageItem.dart | 2 - lib/chat/group_chat_item.dart | 1 - lib/chat/msg_state_widge.dart | 1 - lib/chat/upload_item.dart | 1 - lib/data/UserData.dart | 15 + lib/data/constants.dart | 2 + lib/generated/i18n.dart | 4 +- lib/home/ConversActionPage.dart | 2334 +++++++++++++++--------------- lib/home/VerificationCenter.dart | 9 +- lib/home/VideoPage.dart | 66 +- lib/home/new_friends.dart | 1 - lib/utils/PicSwiper.dart | 2 +- lib/utils/upload_util.dart | 20 +- pubspec.yaml | 2 +- 15 files changed, 1223 insertions(+), 1239 deletions(-) diff --git a/i18n/vi-VN.json b/i18n/vi-VN.json index c8d970c..8928019 100644 --- a/i18n/vi-VN.json +++ b/i18n/vi-VN.json @@ -857,7 +857,7 @@ "has_get": "Đã nhận", "no_gift": "Hiện tại không có phần quà nào", "sent_gift": "Quà tặng", - "fill_tips": "Khi bạn điền thông tin thành công sẽ nhận được /s1H tề, không thể sửa đổi sau khi liên kết.", + "fill_tips": "Khi bạn nhập mã mời thành công sẽ nhận được /s1H coin, nhưng không thể sửa đổi sau khi liên kết.", "bind_code": "Liên kết mã mời", "invide_code": "Mã mời", "confirm_delete": "Xác nhận xóa", diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index 7ddc02d..96f62c0 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -13,7 +13,6 @@ import 'package:chat/chat/redbag_widget.dart'; import 'package:chat/chat/upload_item.dart'; import 'package:chat/chat/video_view.dart'; import 'package:chat/data/UserData.dart'; -import 'package:chat/data/chat_data_mgr.dart'; import 'package:chat/data/constants.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/models/ChatMsg.dart'; @@ -36,7 +35,6 @@ import 'package:chat/utils/sql_util.dart'; import 'package:chat/utils/upload_util.dart'; import 'package:chat/utils/video_anim.dart'; import 'package:chat/utils/wpop/w_popup_menu.dart'; -import 'package:dio/dio.dart'; import 'package:flutter/services.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 71f0e79..97f4b39 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -34,7 +34,6 @@ import 'package:chat/utils/screen.dart'; import 'package:chat/utils/sound_util.dart'; import 'package:chat/utils/upload_util.dart'; import 'package:chat/utils/video_anim.dart'; -import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; diff --git a/lib/chat/msg_state_widge.dart b/lib/chat/msg_state_widge.dart index d52e34e..ff9c1c3 100644 --- a/lib/chat/msg_state_widge.dart +++ b/lib/chat/msg_state_widge.dart @@ -1,5 +1,4 @@ import 'package:chat/models/ChatMsg.dart'; -import 'package:chat/proto/chat.pbserver.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/upload_util.dart'; diff --git a/lib/chat/upload_item.dart b/lib/chat/upload_item.dart index 9da7225..1b54ef5 100644 --- a/lib/chat/upload_item.dart +++ b/lib/chat/upload_item.dart @@ -4,7 +4,6 @@ import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/screen.dart'; import 'package:chat/utils/sql_util.dart'; import 'package:chat/utils/upload_util.dart'; -import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:percent_indicator/percent_indicator.dart'; diff --git a/lib/data/UserData.dart b/lib/data/UserData.dart index 835a38c..9039d3d 100644 --- a/lib/data/UserData.dart +++ b/lib/data/UserData.dart @@ -4,6 +4,8 @@ import 'dart:convert'; import 'package:amap_location/amap_location.dart'; import 'package:chat/data/constants.dart'; import 'package:chat/utils/HttpUtil.dart'; +import 'package:chat/utils/LoadingDialog.dart'; +import 'package:chat/utils/upload_util.dart'; import 'package:crclib/crclib.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:vibration/vibration.dart'; @@ -252,4 +254,17 @@ class UserData { }); } } + + Future getLoaclVideoPath(String url) async { + var key = Constants.LocalCertifiedvideo + basicInfo.userId.toString(); + SharedPreferences spf = await SharedPreferences.getInstance(); + var path = spf.get(key); + if (path == null) { + LoadingManage().showLoading(); + path = await UploadUtil() + .downloadCertifiedvideo(url, () => LoadingManage().closeLoading()); + spf.setString(key, path); + } + return path; + } } diff --git a/lib/data/constants.dart b/lib/data/constants.dart index 36c981e..04e9d7a 100644 --- a/lib/data/constants.dart +++ b/lib/data/constants.dart @@ -287,6 +287,8 @@ class Constants { static const GroupAlterKey = 'GroupAlterKey'; //群@ + static const LocalCertifiedvideo = 'LocalCertifiedvideo'; //本地认证视频 + /// currentGoodsId+'@'+receipt+'@'+purchaseToken static final vipIcon = Image.asset( diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index 101d78e..f9ef2e2 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -5137,9 +5137,9 @@ class _I18n_vi_VN extends I18n { /// "Quà tặng" @override String get sent_gift => "Quà tặng"; - /// "Khi bạn điền thông tin thành công sẽ nhận được /s1H tề, không thể sửa đổi sau khi liên kết." + /// "Khi bạn nhập mã mời thành công sẽ nhận được /s1H coin, nhưng không thể sửa đổi sau khi liên kết." @override - String get fill_tips => "Khi bạn điền thông tin thành công sẽ nhận được /s1H tề, không thể sửa đổi sau khi liên kết."; + String get fill_tips => "Khi bạn nhập mã mời thành công sẽ nhận được /s1H coin, nhưng không thể sửa đổi sau khi liên kết."; /// "Liên kết mã mời" @override String get bind_code => "Liên kết mã mời"; diff --git a/lib/home/ConversActionPage.dart b/lib/home/ConversActionPage.dart index 3d646f3..ab0f3dc 100644 --- a/lib/home/ConversActionPage.dart +++ b/lib/home/ConversActionPage.dart @@ -1,620 +1,3 @@ -//import 'package:chat/data/UserData.dart'; -//import 'package:chat/data/WebData.dart'; -//import 'package:chat/data/conversation.dart'; -//import 'package:chat/data/group_data_mgr.dart'; -//import 'package:chat/generated/i18n.dart'; -//import 'package:chat/home/InfoList.dart'; -//import 'package:chat/home/last_chat_record_widget.dart'; -//import 'package:chat/home/rich_title.dart'; -//import 'package:chat/home/unread_dot_widget.dart'; -//import 'package:chat/models/group_info_model.dart'; -//import 'package:chat/utils/CustomUI.dart'; -//import 'package:chat/utils/HttpUtil.dart'; -//import 'package:chat/utils/MessageMgr.dart'; -//import 'package:chat/utils/TokenMgr.dart'; -//import 'package:chat/utils/screen.dart'; -//import 'package:dio/dio.dart'; -//import 'package:flutter/cupertino.dart'; -//import 'package:flutter/material.dart'; -//import 'package:shared_preferences/shared_preferences.dart'; -//import '../data/constants.dart' -// show -// AppColors, -// AppStyles, -// Constants, -// GlobalSearchPageType, -// GroupOperatingPageType; -//import 'package:cached_network_image/cached_network_image.dart'; -// -//import 'create_group_view.dart'; -//import 'global_search.dart'; -//import 'group_item_widget.dart'; -// -//class _ConversationItem extends StatelessWidget { -// const _ConversationItem( -// {Key key, -// this.conversation, -// this.callback, -// this.icon, -// this.bgColor, -// this.iconSize = 20}) -// : assert(conversation != null), -// super(key: key); -// final icon; -// final double iconSize; -// final Conversation conversation; -// final callback; -// final bgColor; -// -// @override -// Widget build(BuildContext context) { -// Widget avatar; -// if (icon != null) { -// avatar = Container( -// height: 47.5, -// width: 47.5, -// margin: EdgeInsets.only(left: 6), -// alignment: Alignment.center, -// decoration: BoxDecoration( -// gradient: bgColor, -// borderRadius: BorderRadius.all(Radius.circular(50))), -// child: Image.asset( -// icon, -// height: iconSize, -// )); -// } else if (conversation.isAvatarFromNet()) { -// avatar = CachedNetworkImage( -// imageUrl: conversation.avatar, -// placeholder: CustomUI.buildImgLoding, -// width: Constants.ConversationAvatarSize, -// height: Constants.ConversationAvatarSize, -// ); -// } else { -// avatar = Image.asset( -// conversation.avatar, -// width: Constants.ConversationAvatarSize, -// height: Constants.ConversationAvatarSize, -// ); -// } -// List _rightArea = [ -// Container( -// padding: EdgeInsets.only(top: 4), -// alignment: Alignment.center, -// child: Text(conversation.updateAt, -// textScaleFactor: 1.0, -// style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))), -// ) -// ]; -// if (conversation.unreadMsgCount > 0) { -// var countStr = conversation.unreadMsgCount.toString(); -// if (conversation.unreadMsgCount > 99) { -// countStr = '99+'; -// } -// // 未读消息角标 -// Widget unreadMsgCountText = Container( -// width: Constants.UnReadMsgNotifyDotSize, -// height: Constants.UnReadMsgNotifyDotSize, -// alignment: Alignment.center, -// decoration: BoxDecoration( -// borderRadius: -// BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0), -// color: Color(0xFFFF5454), -// ), -// child: Text(countStr, -// textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle), -// ); -// _rightArea.add(Expanded( -// child: Align( -// alignment: Alignment.bottomCenter, -// child: unreadMsgCountText, -// ))); -// } -// -// return InkWell( -// child: Container( -// padding: const EdgeInsets.all(10.0), -// decoration: BoxDecoration( -// color: Color(AppColors.ConversationItemBgColor), -// ), -// child: Row( -// crossAxisAlignment: CrossAxisAlignment.center, -// children: [ -// avatar, -// Container(width: 17.0), -// Expanded( -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.start, -// children: [ -// Text(conversation.title, -// textScaleFactor: 1.0, -// style: TextStyle( -// color: Colors.black, -// )), -// SizedBox( -// height: 5, -// ), -// Text(conversation.desc, -// textScaleFactor: 1.0, -// style: TextStyle( -// fontSize: 12, color: const Color(0xFF9B9B9B))) -// ], -// ), -// ), -// // Container(width: 10.0), -// SizedBox( -// height: Constants.ConversationAvatarSize, -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.end, -// mainAxisAlignment: MainAxisAlignment.start, -// children: _rightArea, -// ), -// ) -// ], -// ), -// ), -// onTap: () { -// callback(); -// }, -// ); -// } -//} -// -//class ConversActionPage extends StatefulWidget { -// ConversActionPage({Key key}) : super(key: key); -// -// _ConversActionPageState createState() => _ConversActionPageState(); -//} -// -//Map systemInfo = { -// 'applyList': null, -// 'applyCount': 0, -// 'evaluateList': null, -// 'evaluateCount': 0, -// 'parkList': null, -// 'parkCount': 0, -// 'castList': null, -// 'castCount': 0, -// 'walletList': null, -// 'walletCount': 0, -//}; -// -//int msgNum = 0; -//bool isShowMsg() { -// return msgNum > 0; -//} -// -//getAllResNum(prefs) { -// getResNum(prefs, Constants.ApplyCount); -// getResNum(prefs, Constants.EvaluateCount); -// getResNum(prefs, Constants.ParkCount); -// getResNum(prefs, Constants.CastCount); -// getResNum(prefs, Constants.WalletCount); -//} -// -//getResNum(prefs, url) async { -// var count = prefs.getInt(url + UserData().basicInfo.userId.toString()); -// systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count); -// -// msgNum += systemInfo[url]; -//} -// -//setResNum(url) async { -// var localKey = url + UserData().basicInfo.userId.toString(); -// if (systemInfo[url] > 0) { -// SharedPreferences prefs = await SharedPreferences.getInstance(); -// var count = prefs.getInt(localKey); -// prefs.setInt( -// localKey, count == null ? systemInfo[url] : (systemInfo[url] + count)); -// msgNum -= systemInfo[url]; -// systemInfo[url] = 0; -// } -//} -// -//class _ConversActionPageState extends State -// with SingleTickerProviderStateMixin { -// TabController tabCtrl; -// -// void getSystemMsg(data) async { -// Map data = { -// "userId": UserData().basicInfo.userId, -// "type": UserData().basicInfo.sex -// }; -// data['sign'] = TokenMgr().getSign(data); -// -// Response res = await HttpUtil().post('message/all/message', data: data); -// if (res == null) { -// return; -// } -// Map resData = res.data; -// if (resData['code'] == 0) { -// SharedPreferences prefs = await SharedPreferences.getInstance(); -// systemInfo = resData['data']; -// msgNum = 0; -// getAllResNum(prefs); -// if (mounted) { -// setState(() {}); -// } -// } -// } -// -// @override -// void initState() { -// super.initState(); -// -// MessageMgr().on('update_system', getSystemMsg); -// MessageMgr().on('Quit Group', quitGroup); -// -// MessageMgr().on('Update Group List', updateGroupLastMsg); -// getSystemMsg(null); -// -// tabCtrl = TabController(length: 3, vsync: this); -// } -// -// @override -// void dispose() { -// tabCtrl.dispose(); -// MessageMgr().off('update_system', getSystemMsg); -// super.dispose(); -// MessageMgr().off('Quit Group', quitGroup); -// -// MessageMgr().off('Update Group List', updateGroupLastMsg); -// } -// -// @override -// Widget build(BuildContext context) { -// List groupList = GroupInfoMgr().groupInfoList; -// -// return Scaffold( -// backgroundColor: Colors.white, -// appBar: AppBar( -// //backgroundColor: Constants.LightGreyBackgroundColor, -// centerTitle: false, -// title: Text( -// I18n.of(context).message_center, -// textScaleFactor: 1.0, -// style: Constants.MainTitleStyle, -// ), -// actions: [ -// Container( -// child: IconButton( -// icon: CircleAvatar( -// backgroundColor: Constants.GreyBackgroundColor, -// radius: 13.75, -// child: Padding( -// padding: EdgeInsets.only(bottom: 1.5), -// child: Icon( -// IconData(0xe659, -// fontFamily: Constants.IconFontFamily), -// color: Constants.BlackTextColor, -// size: 21, -// ))), -// onPressed: () { -// CustomUI().goScanPage(context); -// }, -// ), -// ), -// // InkWell( -// // onTap: () { -// // Navigator.of(context).push( -// // new MaterialPageRoute( -// // builder: (context) { -// // return MessagePushPage(); -// // }, -// // ), -// // ); -// // }, -// // child: Padding( -// // padding: EdgeInsets.only(right: 10), -// // child: CircleAvatar( -// // backgroundColor: Constants.GreyBackgroundColor, -// // radius: 13.75, -// // child: Icon( -// // Icons.settings, -// // color: Constants.BlackTextColor, -// // size: 22, -// // )), -// // )), -// ], -// elevation: 0, -// bottom: PreferredSize( -// preferredSize: Size.fromHeight(28), -// child: Container( -// padding: EdgeInsets.only(left: 2), -// decoration: BoxDecoration( -// //color: Constants.LightGreyBackgroundColor, -// border: -// Border(bottom: BorderSide(color: Color(0xffeaeaea)))), -// alignment: Alignment.centerLeft, -// child: TabBar( -// isScrollable: true, -// indicatorPadding: EdgeInsets.only(left: 9, right: 9), -// tabs: [ -// UnreadDot( -// child: Container( -// margin: EdgeInsets.only(right: 4), -// child: Text(I18n.of(context).text_chat, -// textScaleFactor: 1.0), -// ), -// type: 1), -// UnreadDot( -// child: Container( -// margin: EdgeInsets.only(right: 4), -// child: Text(I18n.of(context).group_chat, -// textScaleFactor: 1.0), -// ), -// type: 4), -// UnreadDot( -// child: Container( -// margin: EdgeInsets.only(right: 4), -// child: Text(I18n.of(context).system_information, -// textScaleFactor: 1.0)), -// type: 2), -// ], -// controller: tabCtrl, -// ), -// )), -// ), -// body: SafeArea( -// child: TabBarView( -// children: [ -// LastChatPage(), -// ListView.builder( -//// controller: _scrollController, -// itemBuilder: (BuildContext context, int index) { -// if (index == 0) { -// return _buildCreateButton(); -// } else { -// var info = groupList[index - 1]; -// return GroupItem(ValueKey(info), groupInfoModel: info); -// } -// }, -// itemCount: groupList.length + 1, -// ), -// ListView( -// children: [ -// SizedBox(height: 8.5), -// _ConversationItem( -// icon: 'assets/images/chat/icon1.png', -// bgColor: Constants.RadioGradient, -// conversation: Conversation( -// avatar: 'assets/images/ic_tx_news.png', -// title: I18n.of(context).radio_message, -// desc: RichTitle.normalTitle( -// systemInfo['castList'], context, InfoType.Radio), -// updateAt: systemInfo['castList'] == null -// ? "" -// : WebData().getLoginTime( -// context, systemInfo['castList']['CreateTime']), -// unreadMsgCount: systemInfo['castCount'], -// ), -// callback: () { -// setResNum(Constants.CastCount); -// Navigator.of(context).push( -// new MaterialPageRoute( -// builder: (context) { -// return InfoListPage( -// title: I18n.of(context).radio_message, -// type: InfoType.Radio, -// ); -// }, -// ), -// ); -// }, -// ), -// _ConversationItem( -// icon: 'assets/images/chat/icon4.png', -// bgColor: Constants.MoneyGradient, -// conversation: Conversation( -// avatar: 'assets/images/ic_tx_news.png', -// title: I18n.of(context).wallet_reminder, -// desc: RichTitle.normalTitle( -// systemInfo['walletList'], context, InfoType.IncomeMoney), -// updateAt: systemInfo['walletList'] == null -// ? "" -// : WebData().getLoginTime( -// context, systemInfo['walletList']['CreateTime']), -// unreadMsgCount: systemInfo['walletCount'], -// ), -// callback: () { -// setResNum(Constants.WalletCount); -// Navigator.of(context).push( -// new MaterialPageRoute( -// builder: (context) { -// return InfoListPage( -// title: I18n.of(context).wallet_reminder, -// type: InfoType.IncomeMoney, -// ); -// }, -// ), -// ); -// }, -// ), -// _ConversationItem( -// icon: 'assets/images/chat/icon3.png', -// iconSize: 27, -// bgColor: Constants.ApplyGradient, -// conversation: Conversation( -// avatar: 'assets/images/ic_tx_news.png', -// title: I18n.of(context).application_notice, -// desc: RichTitle.normalTitle( -// systemInfo['applyList'], context, InfoType.Apply), -// updateAt: systemInfo['applyList'] == null -// ? "" -// : WebData().getLoginTime( -// context, systemInfo['applyList']['CreatTime']), -// unreadMsgCount: systemInfo['applyCount'], -// ), -// callback: () { -// setResNum(Constants.ApplyCount); -// Navigator.of(context).push( -// new MaterialPageRoute( -// builder: (context) { -// return InfoListPage( -// title: I18n.of(context).application_notice, -// type: InfoType.Apply, -// ); -// }, -// ), -// ); -// }, -// ), -// _ConversationItem( -// icon: 'assets/images/chat/icon6.png', -// bgColor: Constants.EvaGradient, -// conversation: Conversation( -// avatar: 'assets/images/ic_tx_news.png', -// title: I18n.of(context).evaluation_notice, -// desc: RichTitle.normalTitle(systemInfo['evaluateList'], -// context, InfoType.Evaluation), -// updateAt: systemInfo['evaluateList'] == null -// ? '' -// : WebData().getLoginTime( -// context, systemInfo['evaluateList']['CreateTime']), -// unreadMsgCount: systemInfo['evaluateCount'], -// ), -// callback: () { -// setResNum(Constants.EvaluateCount); -// Navigator.of(context).push( -// new MaterialPageRoute( -// builder: (context) { -// return InfoListPage( -// title: I18n.of(context).evaluation_notice, -// type: 2, -// ); -// }, -// ), -// ); -// }, -// ), -// _ConversationItem( -// icon: 'assets/images/chat/icon5.png', -// bgColor: Constants.ParkGradient, -// conversation: Conversation( -// avatar: 'assets/images/ic_tx_news.png', -// title: I18n.of(context).appName, -// desc: RichTitle.normalTitle( -// systemInfo['parkList'], context, InfoType.System), -// updateAt: systemInfo['parkList'] == null -// ? "" -// : WebData().getLoginTime( -// context, systemInfo['parkList']['CreateTime']), -// unreadMsgCount: systemInfo['parkCount'], -// ), -// callback: () { -// setResNum(Constants.ParkCount); -// Navigator.of(context).push( -// new MaterialPageRoute( -// builder: (context) { -// return InfoListPage( -// title: I18n.of(context).appName, -// type: InfoType.System, -// ); -// }, -// ), -// ); -// }, -// ) -// ], -// ) -// ], -// controller: tabCtrl, -// ))); -// } -// -// Widget _buildCreateButton() { -// List groupList = GroupInfoMgr().groupInfoList; -// Widget _avatarIcon = ClipRRect( -// borderRadius: BorderRadius.circular(GroupRadius), -// child: Container( -// color: const Color(0xFFF2F2F2), -// height: AvatarSize, -// width: AvatarSize, -// child: Icon( -// IconData(0xe66f, fontFamily: Constants.IconFontFamily), -// color: Constants.BlueTextColor, -// size: 35, -// ), -// )); -// -// Widget _button = InkWell( -// onTap: () { -// Navigator.of(context).push( -// new MaterialPageRoute( -// builder: (context) { -// return CreateGroupPage( -// GroupOperatingPageType.CreateGroup, [], null); -// }, -// ), -// ); -// }, -// child: Container( -// padding: EdgeInsets.only(top: 14, bottom: 14), -// color: Constants.GreyBackgroundColor, -// child: Container( -// height: ItemHeight, -// decoration: BoxDecoration(color: Colors.white), -// child: Row( -// children: [ -// SizedBox(width: LeftPadding), -// _avatarIcon, -// SizedBox(width: 14.0), -// Text( -// I18n.of(context).create_group_chat, -// style: TextStyle(fontSize: 15.5), -// ), -// ], -// ), -// ))); -// -// Widget tips = Container( -// alignment: Alignment.centerLeft, -// width: Screen.width, -// height: 33.5, -// padding: EdgeInsets.only(left: LeftPadding), -// decoration: BoxDecoration( -// color: Colors.white, -// border: Border(bottom: Constants.GreyBorderSide)), -// child: Text(I18n.of(context).group_chat + '(${groupList.length})'), -// ); -// -// return Column( -// children: [ -// SizedBox( -// height: 10, -// ), -// CustomUI.buildSearchButton(context, () { -// Navigator.of(context).push( -// new MaterialPageRoute( -// builder: (context) { -// return GlobalSearchPage( -// type: GlobalSearchPageType.SearchGroup, -// ); -// }, -// ), -// ); -// }, bottom: 10), -// _button, -// tips, -// ], -// ); -// } -// -// quitGroup(args) { -// if (mounted) { -// setState(() { -// print('更新群列表'); -// }); -// } -// } -// -// updateGroupLastMsg(args) async { -// await GroupInfoMgr().sortGroupList(); -// if (mounted) { -// setState(() {}); -// } -// } -//} - import 'package:chat/data/UserData.dart'; import 'package:chat/data/WebData.dart'; import 'package:chat/data/conversation.dart'; @@ -635,12 +18,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import '../data/constants.dart' - show - AppColors, - AppStyles, - Constants, - GlobalSearchPageType, - GroupOperatingPageType; + show + AppColors, + AppStyles, + Constants, + GlobalSearchPageType, + GroupOperatingPageType; import 'package:cached_network_image/cached_network_image.dart'; import 'create_group_view.dart'; @@ -648,587 +31,1204 @@ import 'global_search.dart'; import 'group_item_widget.dart'; class _ConversationItem extends StatelessWidget { - const _ConversationItem( - {Key key, - this.conversation, - this.callback, - this.icon, - this.bgColor, - this.iconSize = 20}) - : assert(conversation != null), - super(key: key); - final icon; - final double iconSize; - final Conversation conversation; - final callback; - final bgColor; + const _ConversationItem( + {Key key, + this.conversation, + this.callback, + this.icon, + this.bgColor, + this.iconSize = 20}) + : assert(conversation != null), + super(key: key); + final icon; + final double iconSize; + final Conversation conversation; + final callback; + final bgColor; - @override - Widget build(BuildContext context) { - Widget avatar; - if (icon != null) { - avatar = Container( - height: 47.5, - width: 47.5, - margin: EdgeInsets.only(left: 6), - alignment: Alignment.center, - decoration: BoxDecoration( - gradient: bgColor, - borderRadius: BorderRadius.all(Radius.circular(50))), - child: Image.asset( - icon, - height: iconSize, - )); - } else if (conversation.isAvatarFromNet()) { - avatar = CachedNetworkImage( - imageUrl: conversation.avatar, - placeholder: CustomUI.buildImgLoding, - width: Constants.ConversationAvatarSize, - height: Constants.ConversationAvatarSize, - ); - } else { - avatar = Image.asset( - conversation.avatar, - width: Constants.ConversationAvatarSize, - height: Constants.ConversationAvatarSize, - ); - } - List _rightArea = [ - Container( - padding: EdgeInsets.only(top: 4), - alignment: Alignment.center, - child: Text(conversation.updateAt, - textScaleFactor: 1.0, - style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))), - ) - ]; - if (conversation.unreadMsgCount > 0) { - var countStr = conversation.unreadMsgCount.toString(); - if (conversation.unreadMsgCount > 99) { - countStr = '99+'; - } - // 未读消息角标 - Widget unreadMsgCountText = Container( - width: Constants.UnReadMsgNotifyDotSize, - height: Constants.UnReadMsgNotifyDotSize, - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: - BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0), - color: Color(0xFFFF5454), - ), - child: Text(countStr, - textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle), - ); - _rightArea.add(Expanded( - child: Align( - alignment: Alignment.bottomCenter, - child: unreadMsgCountText, - ))); - } + @override + Widget build(BuildContext context) { + Widget avatar; + if (icon != null) { + avatar = Container( + height: 47.5, + width: 47.5, + margin: EdgeInsets.only(left: 6), + alignment: Alignment.center, + decoration: BoxDecoration( + gradient: bgColor, + borderRadius: BorderRadius.all(Radius.circular(50))), + child: Image.asset( + icon, + height: iconSize, + )); + } else if (conversation.isAvatarFromNet()) { + avatar = CachedNetworkImage( + imageUrl: conversation.avatar, + placeholder: CustomUI.buildImgLoding, + width: Constants.ConversationAvatarSize, + height: Constants.ConversationAvatarSize, + ); + } else { + avatar = Image.asset( + conversation.avatar, + width: Constants.ConversationAvatarSize, + height: Constants.ConversationAvatarSize, + ); + } + List _rightArea = [ + Container( + padding: EdgeInsets.only(top: 4), + alignment: Alignment.center, + child: Text(conversation.updateAt, + textScaleFactor: 1.0, + style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))), + ) + ]; + if (conversation.unreadMsgCount > 0) { + var countStr = conversation.unreadMsgCount.toString(); + if (conversation.unreadMsgCount > 99) { + countStr = '99+'; + } + // 未读消息角标 + Widget unreadMsgCountText = Container( + width: Constants.UnReadMsgNotifyDotSize, + height: Constants.UnReadMsgNotifyDotSize, + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: + BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0), + color: Color(0xFFFF5454), + ), + child: Text(countStr, + textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle), + ); + _rightArea.add(Expanded( + child: Align( + alignment: Alignment.bottomCenter, + child: unreadMsgCountText, + ))); + } - return InkWell( - child: Container( - padding: const EdgeInsets.all(10.0), - decoration: BoxDecoration( - color: Color(AppColors.ConversationItemBgColor), - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - avatar, - Container(width: 17.0), - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(conversation.title, - textScaleFactor: 1.0, - style: TextStyle( - color: Colors.black, - )), - SizedBox( - height: 5, - ), - Text(conversation.desc, - textScaleFactor: 1.0, - style: TextStyle( - fontSize: 12, color: const Color(0xFF9B9B9B))) - ], - ), - ), - // Container(width: 10.0), - SizedBox( - height: Constants.ConversationAvatarSize, - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.start, - children: _rightArea, - ), - ) - ], - ), - ), - onTap: () { - callback(); - }, - ); - } + return InkWell( + child: Container( + padding: const EdgeInsets.all(10.0), + decoration: BoxDecoration( + color: Color(AppColors.ConversationItemBgColor), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + avatar, + Container(width: 17.0), + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(conversation.title, + textScaleFactor: 1.0, + style: TextStyle( + color: Colors.black, + )), + SizedBox( + height: 5, + ), + Text(conversation.desc, + textScaleFactor: 1.0, + style: TextStyle( + fontSize: 12, color: const Color(0xFF9B9B9B))) + ], + ), + ), + // Container(width: 10.0), + SizedBox( + height: Constants.ConversationAvatarSize, + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisAlignment: MainAxisAlignment.start, + children: _rightArea, + ), + ) + ], + ), + ), + onTap: () { + callback(); + }, + ); + } } class ConversActionPage extends StatefulWidget { - ConversActionPage({Key key}) : super(key: key); + ConversActionPage({Key key}) : super(key: key); - _ConversActionPageState createState() => _ConversActionPageState(); + _ConversActionPageState createState() => _ConversActionPageState(); } Map systemInfo = { - 'applyList': null, - 'applyCount': 0, - 'evaluateList': null, - 'evaluateCount': 0, - 'parkList': null, - 'parkCount': 0, - 'castList': null, - 'castCount': 0, - 'walletList': null, - 'walletCount': 0, + 'applyList': null, + 'applyCount': 0, + 'evaluateList': null, + 'evaluateCount': 0, + 'parkList': null, + 'parkCount': 0, + 'castList': null, + 'castCount': 0, + 'walletList': null, + 'walletCount': 0, }; int msgNum = 0; bool isShowMsg() { - return msgNum > 0; + return msgNum > 0; } getAllResNum(prefs) { - getResNum(prefs, Constants.ApplyCount); - getResNum(prefs, Constants.EvaluateCount); - getResNum(prefs, Constants.ParkCount); - getResNum(prefs, Constants.CastCount); - getResNum(prefs, Constants.WalletCount); + getResNum(prefs, Constants.ApplyCount); + getResNum(prefs, Constants.EvaluateCount); + getResNum(prefs, Constants.ParkCount); + getResNum(prefs, Constants.CastCount); + getResNum(prefs, Constants.WalletCount); } getResNum(prefs, url) async { - var count = prefs.getInt(url + UserData().basicInfo.userId.toString()); - systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count); + var count = prefs.getInt(url + UserData().basicInfo.userId.toString()); + systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count); - msgNum += systemInfo[url]; + msgNum += systemInfo[url]; } setResNum(url) async { - var localKey = url + UserData().basicInfo.userId.toString(); - if (systemInfo[url] > 0) { - SharedPreferences prefs = await SharedPreferences.getInstance(); - var count = prefs.getInt(localKey); - prefs.setInt( - localKey, count == null ? systemInfo[url] : (systemInfo[url] + count)); - msgNum -= systemInfo[url]; - systemInfo[url] = 0; - } + var localKey = url + UserData().basicInfo.userId.toString(); + if (systemInfo[url] > 0) { + SharedPreferences prefs = await SharedPreferences.getInstance(); + var count = prefs.getInt(localKey); + prefs.setInt( + localKey, count == null ? systemInfo[url] : (systemInfo[url] + count)); + msgNum -= systemInfo[url]; + systemInfo[url] = 0; + } } class _ConversActionPageState extends State - with SingleTickerProviderStateMixin { - TabController tabCtrl; + with SingleTickerProviderStateMixin { + TabController tabCtrl; + + void getSystemMsg(data) async { + Map data = { + "userId": UserData().basicInfo.userId, + "type": UserData().basicInfo.sex + }; + data['sign'] = TokenMgr().getSign(data); + + Response res = await HttpUtil().post('message/all/message', data: data); + if (res == null) { + return; + } + Map resData = res.data; + if (resData['code'] == 0) { + SharedPreferences prefs = await SharedPreferences.getInstance(); + systemInfo = resData['data']; + msgNum = 0; + getAllResNum(prefs); + if (mounted) { + setState(() {}); + } + } + } + + @override + void initState() { + super.initState(); - void getSystemMsg(data) async { - Map data = { - "userId": UserData().basicInfo.userId, - "type": UserData().basicInfo.sex - }; - data['sign'] = TokenMgr().getSign(data); + MessageMgr().on('update_system', getSystemMsg); + MessageMgr().on('Quit Group', quitGroup); - Response res = await HttpUtil().post('message/all/message', data: data); - if (res == null) { - return; - } - Map resData = res.data; - if (resData['code'] == 0) { - SharedPreferences prefs = await SharedPreferences.getInstance(); - systemInfo = resData['data']; - msgNum = 0; - getAllResNum(prefs); - if (mounted) { - setState(() {}); - } - } - } + MessageMgr().on('Update Group List', updateGroupLastMsg); + getSystemMsg(null); - @override - void initState() { - super.initState(); + tabCtrl = TabController(length: 3, vsync: this); + } - MessageMgr().on('update_system', getSystemMsg); -// MessageMgr().on('Quit Group', quitGroup); -// -// MessageMgr().on('Update Group List', updateGroupLastMsg); - getSystemMsg(null); + @override + void dispose() { + tabCtrl.dispose(); + MessageMgr().off('update_system', getSystemMsg); + super.dispose(); + MessageMgr().off('Quit Group', quitGroup); - tabCtrl = TabController(length: 2, vsync: this); - } + MessageMgr().off('Update Group List', updateGroupLastMsg); + } - @override - void dispose() { - tabCtrl.dispose(); - MessageMgr().off('update_system', getSystemMsg); - super.dispose(); - } + @override + Widget build(BuildContext context) { + List groupList = GroupInfoMgr().groupInfoList; - @override - Widget build(BuildContext context) { -// List groupList = GroupInfoMgr().groupInfoList; + return Scaffold( + backgroundColor: Colors.white, + appBar: AppBar( + //backgroundColor: Constants.LightGreyBackgroundColor, + centerTitle: false, + title: Text( + I18n.of(context).message_center, + textScaleFactor: 1.0, + style: Constants.MainTitleStyle, + ), + actions: [ + Container( + child: IconButton( + icon: CircleAvatar( + backgroundColor: Constants.GreyBackgroundColor, + radius: 13.75, + child: Padding( + padding: EdgeInsets.only(bottom: 1.5), + child: Icon( + IconData(0xe659, + fontFamily: Constants.IconFontFamily), + color: Constants.BlackTextColor, + size: 21, + ))), + onPressed: () { + CustomUI().goScanPage(context); + }, + ), + ), + // InkWell( + // onTap: () { + // Navigator.of(context).push( + // new MaterialPageRoute( + // builder: (context) { + // return MessagePushPage(); + // }, + // ), + // ); + // }, + // child: Padding( + // padding: EdgeInsets.only(right: 10), + // child: CircleAvatar( + // backgroundColor: Constants.GreyBackgroundColor, + // radius: 13.75, + // child: Icon( + // Icons.settings, + // color: Constants.BlackTextColor, + // size: 22, + // )), + // )), + ], + elevation: 0, + bottom: PreferredSize( + preferredSize: Size.fromHeight(28), + child: Container( + padding: EdgeInsets.only(left: 2), + decoration: BoxDecoration( + //color: Constants.LightGreyBackgroundColor, + border: + Border(bottom: BorderSide(color: Color(0xffeaeaea)))), + alignment: Alignment.centerLeft, + child: TabBar( + isScrollable: true, + indicatorPadding: EdgeInsets.only(left: 9, right: 9), + tabs: [ + UnreadDot( + child: Container( + margin: EdgeInsets.only(right: 4), + child: Text(I18n.of(context).text_chat, + textScaleFactor: 1.0), + ), + type: 1), + UnreadDot( + child: Container( + margin: EdgeInsets.only(right: 4), + child: Text(I18n.of(context).group_chat, + textScaleFactor: 1.0), + ), + type: 4), + UnreadDot( + child: Container( + margin: EdgeInsets.only(right: 4), + child: Text(I18n.of(context).system_information, + textScaleFactor: 1.0)), + type: 2), + ], + controller: tabCtrl, + ), + )), + ), + body: SafeArea( + child: TabBarView( + children: [ + LastChatPage(), + ListView.builder( +// controller: _scrollController, + itemBuilder: (BuildContext context, int index) { + if (index == 0) { + return _buildCreateButton(); + } else { + var info = groupList[index - 1]; + return GroupItem(ValueKey(info), groupInfoModel: info); + } + }, + itemCount: groupList.length + 1, + ), + ListView( + children: [ + SizedBox(height: 8.5), + _ConversationItem( + icon: 'assets/images/chat/icon1.png', + bgColor: Constants.RadioGradient, + conversation: Conversation( + avatar: 'assets/images/ic_tx_news.png', + title: I18n.of(context).radio_message, + desc: RichTitle.normalTitle( + systemInfo['castList'], context, InfoType.Radio), + updateAt: systemInfo['castList'] == null + ? "" + : WebData().getLoginTime( + context, systemInfo['castList']['CreateTime']), + unreadMsgCount: systemInfo['castCount'], + ), + callback: () { + setResNum(Constants.CastCount); + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return InfoListPage( + title: I18n.of(context).radio_message, + type: InfoType.Radio, + ); + }, + ), + ); + }, + ), + _ConversationItem( + icon: 'assets/images/chat/icon4.png', + bgColor: Constants.MoneyGradient, + conversation: Conversation( + avatar: 'assets/images/ic_tx_news.png', + title: I18n.of(context).wallet_reminder, + desc: RichTitle.normalTitle( + systemInfo['walletList'], context, InfoType.IncomeMoney), + updateAt: systemInfo['walletList'] == null + ? "" + : WebData().getLoginTime( + context, systemInfo['walletList']['CreateTime']), + unreadMsgCount: systemInfo['walletCount'], + ), + callback: () { + setResNum(Constants.WalletCount); + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return InfoListPage( + title: I18n.of(context).wallet_reminder, + type: InfoType.IncomeMoney, + ); + }, + ), + ); + }, + ), + _ConversationItem( + icon: 'assets/images/chat/icon3.png', + iconSize: 27, + bgColor: Constants.ApplyGradient, + conversation: Conversation( + avatar: 'assets/images/ic_tx_news.png', + title: I18n.of(context).application_notice, + desc: RichTitle.normalTitle( + systemInfo['applyList'], context, InfoType.Apply), + updateAt: systemInfo['applyList'] == null + ? "" + : WebData().getLoginTime( + context, systemInfo['applyList']['CreatTime']), + unreadMsgCount: systemInfo['applyCount'], + ), + callback: () { + setResNum(Constants.ApplyCount); + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return InfoListPage( + title: I18n.of(context).application_notice, + type: InfoType.Apply, + ); + }, + ), + ); + }, + ), + _ConversationItem( + icon: 'assets/images/chat/icon6.png', + bgColor: Constants.EvaGradient, + conversation: Conversation( + avatar: 'assets/images/ic_tx_news.png', + title: I18n.of(context).evaluation_notice, + desc: RichTitle.normalTitle(systemInfo['evaluateList'], + context, InfoType.Evaluation), + updateAt: systemInfo['evaluateList'] == null + ? '' + : WebData().getLoginTime( + context, systemInfo['evaluateList']['CreateTime']), + unreadMsgCount: systemInfo['evaluateCount'], + ), + callback: () { + setResNum(Constants.EvaluateCount); + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return InfoListPage( + title: I18n.of(context).evaluation_notice, + type: 2, + ); + }, + ), + ); + }, + ), + _ConversationItem( + icon: 'assets/images/chat/icon5.png', + bgColor: Constants.ParkGradient, + conversation: Conversation( + avatar: 'assets/images/ic_tx_news.png', + title: I18n.of(context).appName, + desc: RichTitle.normalTitle( + systemInfo['parkList'], context, InfoType.System), + updateAt: systemInfo['parkList'] == null + ? "" + : WebData().getLoginTime( + context, systemInfo['parkList']['CreateTime']), + unreadMsgCount: systemInfo['parkCount'], + ), + callback: () { + setResNum(Constants.ParkCount); + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return InfoListPage( + title: I18n.of(context).appName, + type: InfoType.System, + ); + }, + ), + ); + }, + ) + ], + ) + ], + controller: tabCtrl, + ))); + } - return Scaffold( - backgroundColor: Colors.white, - appBar: AppBar( - //backgroundColor: Constants.LightGreyBackgroundColor, - centerTitle: false, - title: Text( - I18n.of(context).message_center, - textScaleFactor: 1.0, - style: Constants.MainTitleStyle, - ), - actions: [ - Container( - child: IconButton( - icon: CircleAvatar( - backgroundColor: Constants.GreyBackgroundColor, - radius: 13.75, - child: Padding( - padding: EdgeInsets.only(bottom: 1.5), - child: Icon( - IconData(0xe659, - fontFamily: Constants.IconFontFamily), - color: Constants.BlackTextColor, - size: 21, - ))), - onPressed: () { - CustomUI().goScanPage(context); - }, - ), - ), - // InkWell( - // onTap: () { - // Navigator.of(context).push( - // new MaterialPageRoute( - // builder: (context) { - // return MessagePushPage(); - // }, - // ), - // ); - // }, - // child: Padding( - // padding: EdgeInsets.only(right: 10), - // child: CircleAvatar( - // backgroundColor: Constants.GreyBackgroundColor, - // radius: 13.75, - // child: Icon( - // Icons.settings, - // color: Constants.BlackTextColor, - // size: 22, - // )), - // )), - ], - elevation: 0, - bottom: PreferredSize( - preferredSize: Size.fromHeight(28), - child: Container( - padding: EdgeInsets.only(left: 2), - decoration: BoxDecoration( - //color: Constants.LightGreyBackgroundColor, - border: - Border(bottom: BorderSide(color: Color(0xffeaeaea)))), - alignment: Alignment.centerLeft, - child: TabBar( - isScrollable: true, - indicatorPadding: EdgeInsets.only(left: 9, right: 9), - tabs: [ - UnreadDot( - child: Container( - margin: EdgeInsets.only(right: 4), - child: Text(I18n.of(context).text_chat, - textScaleFactor: 1.0), - ), - type: 1), -// UnreadDot( -// child: Container( -// margin: EdgeInsets.only(right: 4), -// child: Text(I18n.of(context).group_chat, -// textScaleFactor: 1.0), -// ), -// type: 4), - UnreadDot( - child: Container( - margin: EdgeInsets.only(right: 4), - child: Text(I18n.of(context).system_information, - textScaleFactor: 1.0)), - type: 2), - ], - controller: tabCtrl, - ), - )), - ), - body: SafeArea( - child: TabBarView( - children: [ - LastChatPage(), -// ListView.builder( -//// controller: _scrollController, -// itemBuilder: (BuildContext context, int index) { -// if (index == 0) { -// return _buildCreateButton(); -// } else { -// var info = groupList[index - 1]; -// return GroupItem(ValueKey(info), groupInfoModel: info); -// } -// }, -// itemCount: groupList.length + 1, -// ), - ListView( - children: [ - SizedBox(height: 8.5), - _ConversationItem( - icon: 'assets/images/chat/icon1.png', - bgColor: Constants.RadioGradient, - conversation: Conversation( - avatar: 'assets/images/ic_tx_news.png', - title: I18n.of(context).radio_message, - desc: RichTitle.normalTitle( - systemInfo['castList'], context, InfoType.Radio), - updateAt: systemInfo['castList'] == null - ? "" - : WebData().getLoginTime( - context, systemInfo['castList']['CreateTime']), - unreadMsgCount: systemInfo['castCount'], - ), - callback: () { - setResNum(Constants.CastCount); - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return InfoListPage( - title: I18n.of(context).radio_message, - type: InfoType.Radio, - ); - }, - ), - ); - }, - ), - _ConversationItem( - icon: 'assets/images/chat/icon4.png', - bgColor: Constants.MoneyGradient, - conversation: Conversation( - avatar: 'assets/images/ic_tx_news.png', - title: I18n.of(context).wallet_reminder, - desc: RichTitle.normalTitle(systemInfo['walletList'], - context, InfoType.IncomeMoney), - updateAt: systemInfo['walletList'] == null - ? "" - : WebData().getLoginTime( - context, systemInfo['walletList']['CreateTime']), - unreadMsgCount: systemInfo['walletCount'], - ), - callback: () { - setResNum(Constants.WalletCount); - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return InfoListPage( - title: I18n.of(context).wallet_reminder, - type: InfoType.IncomeMoney, - ); - }, - ), - ); - }, - ), - _ConversationItem( - icon: 'assets/images/chat/icon3.png', - iconSize: 27, - bgColor: Constants.ApplyGradient, - conversation: Conversation( - avatar: 'assets/images/ic_tx_news.png', - title: I18n.of(context).application_notice, - desc: RichTitle.normalTitle( - systemInfo['applyList'], context, InfoType.Apply), - updateAt: systemInfo['applyList'] == null - ? "" - : WebData().getLoginTime( - context, systemInfo['applyList']['CreatTime']), - unreadMsgCount: systemInfo['applyCount'], - ), - callback: () { - setResNum(Constants.ApplyCount); - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return InfoListPage( - title: I18n.of(context).application_notice, - type: InfoType.Apply, - ); - }, - ), - ); - }, - ), - _ConversationItem( - icon: 'assets/images/chat/icon6.png', - bgColor: Constants.EvaGradient, - conversation: Conversation( - avatar: 'assets/images/ic_tx_news.png', - title: I18n.of(context).evaluation_notice, - desc: RichTitle.normalTitle(systemInfo['evaluateList'], - context, InfoType.Evaluation), - updateAt: systemInfo['evaluateList'] == null - ? '' - : WebData().getLoginTime( - context, systemInfo['evaluateList']['CreateTime']), - unreadMsgCount: systemInfo['evaluateCount'], - ), - callback: () { - setResNum(Constants.EvaluateCount); - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return InfoListPage( - title: I18n.of(context).evaluation_notice, - type: 2, - ); - }, - ), - ); - }, - ), - _ConversationItem( - icon: 'assets/images/chat/icon5.png', - bgColor: Constants.ParkGradient, - conversation: Conversation( - avatar: 'assets/images/ic_tx_news.png', - title: I18n.of(context).appName, - desc: RichTitle.normalTitle( - systemInfo['parkList'], context, InfoType.System), - updateAt: systemInfo['parkList'] == null - ? "" - : WebData().getLoginTime( - context, systemInfo['parkList']['CreateTime']), - unreadMsgCount: systemInfo['parkCount'], - ), - callback: () { - setResNum(Constants.ParkCount); - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return InfoListPage( - title: I18n.of(context).appName, - type: InfoType.System, - ); - }, - ), - ); - }, - ) - ], - ) - ], - controller: tabCtrl, - ))); - } + Widget _buildCreateButton() { + List groupList = GroupInfoMgr().groupInfoList; + Widget _avatarIcon = ClipRRect( + borderRadius: BorderRadius.circular(GroupRadius), + child: Container( + color: const Color(0xFFF2F2F2), + height: AvatarSize, + width: AvatarSize, + child: Icon( + IconData(0xe66f, fontFamily: Constants.IconFontFamily), + color: Constants.BlueTextColor, + size: 35, + ), + )); - Widget _buildCreateButton() { - List groupList = GroupInfoMgr().groupInfoList; - Widget _avatarIcon = ClipRRect( - borderRadius: BorderRadius.circular(GroupRadius), - child: Container( - color: const Color(0xFFF2F2F2), - height: AvatarSize, - width: AvatarSize, - child: Icon( - IconData(0xe66f, fontFamily: Constants.IconFontFamily), - color: Constants.BlueTextColor, - size: 35, - ), - )); + Widget _button = InkWell( + onTap: () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return CreateGroupPage( + GroupOperatingPageType.CreateGroup, [], null); + }, + ), + ); + }, + child: Container( + padding: EdgeInsets.only(top: 14, bottom: 14), + color: Constants.GreyBackgroundColor, + child: Container( + height: ItemHeight, + decoration: BoxDecoration(color: Colors.white), + child: Row( + children: [ + SizedBox(width: LeftPadding), + _avatarIcon, + SizedBox(width: 14.0), + Text( + I18n.of(context).create_group_chat, + style: TextStyle(fontSize: 15.5), + ), + ], + ), + ))); - Widget _button = InkWell( - onTap: () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return CreateGroupPage( - GroupOperatingPageType.CreateGroup, [], null); - }, - ), - ); - }, - child: Container( - padding: EdgeInsets.only(top: 14, bottom: 14), - color: Constants.GreyBackgroundColor, - child: Container( - height: ItemHeight, - decoration: BoxDecoration(color: Colors.white), - child: Row( - children: [ - SizedBox(width: LeftPadding), - _avatarIcon, - SizedBox(width: 14.0), - Text( - I18n.of(context).create_group_chat, - textScaleFactor: 1.0, - style: TextStyle(fontSize: 15.5), - ), - ], - ), - ))); + Widget tips = Container( + alignment: Alignment.centerLeft, + width: Screen.width, + height: 33.5, + padding: EdgeInsets.only(left: LeftPadding), + decoration: BoxDecoration( + color: Colors.white, + border: Border(bottom: Constants.GreyBorderSide)), + child: Text(I18n.of(context).group_chat + '(${groupList.length})'), + ); - Widget tips = Container( - alignment: Alignment.centerLeft, - width: Screen.width, - height: 33.5, - padding: EdgeInsets.only(left: LeftPadding), - decoration: BoxDecoration( - color: Colors.white, - border: Border(bottom: Constants.GreyBorderSide)), - child: Text( - I18n.of(context).group_chat + '(${groupList.length})', - textScaleFactor: 1.0, - ), - ); + return Column( + children: [ + SizedBox( + height: 10, + ), + CustomUI.buildSearchButton(context, () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return GlobalSearchPage( + type: GlobalSearchPageType.SearchGroup, + ); + }, + ), + ); + }, bottom: 10), + _button, + tips, + ], + ); + } - return Column( - children: [ - SizedBox( - height: 10, - ), - CustomUI.buildSearchButton(context, () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return GlobalSearchPage( - type: GlobalSearchPageType.SearchGroup, - ); - }, - ), - ); - }, bottom: 10), - _button, - tips, - ], - ); - } + quitGroup(args) { + if (mounted) { + setState(() { + print('更新群列表'); + }); + } + } -// quitGroup(args) { -// if (mounted) { -// setState(() { -// print('更新群列表'); -// }); -// } -// } -// -// updateGroupLastMsg(args) async { -// await GroupInfoMgr().sortGroupList(); -// if (mounted) { -// setState(() {}); -// } -// } + updateGroupLastMsg(args) async { + await GroupInfoMgr().sortGroupList(); + if (mounted) { + setState(() {}); + } + } } + +// import 'package:chat/data/UserData.dart'; +// import 'package:chat/data/WebData.dart'; +// import 'package:chat/data/conversation.dart'; +// import 'package:chat/data/group_data_mgr.dart'; +// import 'package:chat/generated/i18n.dart'; +// import 'package:chat/home/InfoList.dart'; +// import 'package:chat/home/last_chat_record_widget.dart'; +// import 'package:chat/home/rich_title.dart'; +// import 'package:chat/home/unread_dot_widget.dart'; +// import 'package:chat/models/group_info_model.dart'; +// import 'package:chat/utils/CustomUI.dart'; +// import 'package:chat/utils/HttpUtil.dart'; +// import 'package:chat/utils/MessageMgr.dart'; +// import 'package:chat/utils/TokenMgr.dart'; +// import 'package:chat/utils/screen.dart'; +// import 'package:dio/dio.dart'; +// import 'package:flutter/cupertino.dart'; +// import 'package:flutter/material.dart'; +// import 'package:shared_preferences/shared_preferences.dart'; +// import '../data/constants.dart' +// show +// AppColors, +// AppStyles, +// Constants, +// GlobalSearchPageType, +// GroupOperatingPageType; +// import 'package:cached_network_image/cached_network_image.dart'; + +// import 'create_group_view.dart'; +// import 'global_search.dart'; +// import 'group_item_widget.dart'; + +// class _ConversationItem extends StatelessWidget { +// const _ConversationItem( +// {Key key, +// this.conversation, +// this.callback, +// this.icon, +// this.bgColor, +// this.iconSize = 20}) +// : assert(conversation != null), +// super(key: key); +// final icon; +// final double iconSize; +// final Conversation conversation; +// final callback; +// final bgColor; + +// @override +// Widget build(BuildContext context) { +// Widget avatar; +// if (icon != null) { +// avatar = Container( +// height: 47.5, +// width: 47.5, +// margin: EdgeInsets.only(left: 6), +// alignment: Alignment.center, +// decoration: BoxDecoration( +// gradient: bgColor, +// borderRadius: BorderRadius.all(Radius.circular(50))), +// child: Image.asset( +// icon, +// height: iconSize, +// )); +// } else if (conversation.isAvatarFromNet()) { +// avatar = CachedNetworkImage( +// imageUrl: conversation.avatar, +// placeholder: CustomUI.buildImgLoding, +// width: Constants.ConversationAvatarSize, +// height: Constants.ConversationAvatarSize, +// ); +// } else { +// avatar = Image.asset( +// conversation.avatar, +// width: Constants.ConversationAvatarSize, +// height: Constants.ConversationAvatarSize, +// ); +// } +// List _rightArea = [ +// Container( +// padding: EdgeInsets.only(top: 4), +// alignment: Alignment.center, +// child: Text(conversation.updateAt, +// textScaleFactor: 1.0, +// style: TextStyle(fontSize: 11, color: const Color(0xFFC6C6C6))), +// ) +// ]; +// if (conversation.unreadMsgCount > 0) { +// var countStr = conversation.unreadMsgCount.toString(); +// if (conversation.unreadMsgCount > 99) { +// countStr = '99+'; +// } +// // 未读消息角标 +// Widget unreadMsgCountText = Container( +// width: Constants.UnReadMsgNotifyDotSize, +// height: Constants.UnReadMsgNotifyDotSize, +// alignment: Alignment.center, +// decoration: BoxDecoration( +// borderRadius: +// BorderRadius.circular(Constants.UnReadMsgNotifyDotSize / 2.0), +// color: Color(0xFFFF5454), +// ), +// child: Text(countStr, +// textScaleFactor: 1.0, style: AppStyles.UnreadMsgCountDotStyle), +// ); +// _rightArea.add(Expanded( +// child: Align( +// alignment: Alignment.bottomCenter, +// child: unreadMsgCountText, +// ))); +// } + +// return InkWell( +// child: Container( +// padding: const EdgeInsets.all(10.0), +// decoration: BoxDecoration( +// color: Color(AppColors.ConversationItemBgColor), +// ), +// child: Row( +// crossAxisAlignment: CrossAxisAlignment.center, +// children: [ +// avatar, +// Container(width: 17.0), +// Expanded( +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.start, +// children: [ +// Text(conversation.title, +// textScaleFactor: 1.0, +// style: TextStyle( +// color: Colors.black, +// )), +// SizedBox( +// height: 5, +// ), +// Text(conversation.desc, +// textScaleFactor: 1.0, +// style: TextStyle( +// fontSize: 12, color: const Color(0xFF9B9B9B))) +// ], +// ), +// ), +// // Container(width: 10.0), +// SizedBox( +// height: Constants.ConversationAvatarSize, +// child: Column( +// crossAxisAlignment: CrossAxisAlignment.end, +// mainAxisAlignment: MainAxisAlignment.start, +// children: _rightArea, +// ), +// ) +// ], +// ), +// ), +// onTap: () { +// callback(); +// }, +// ); +// } +// } + +// class ConversActionPage extends StatefulWidget { +// ConversActionPage({Key key}) : super(key: key); + +// _ConversActionPageState createState() => _ConversActionPageState(); +// } + +// Map systemInfo = { +// 'applyList': null, +// 'applyCount': 0, +// 'evaluateList': null, +// 'evaluateCount': 0, +// 'parkList': null, +// 'parkCount': 0, +// 'castList': null, +// 'castCount': 0, +// 'walletList': null, +// 'walletCount': 0, +// }; + +// int msgNum = 0; +// bool isShowMsg() { +// return msgNum > 0; +// } + +// getAllResNum(prefs) { +// getResNum(prefs, Constants.ApplyCount); +// getResNum(prefs, Constants.EvaluateCount); +// getResNum(prefs, Constants.ParkCount); +// getResNum(prefs, Constants.CastCount); +// getResNum(prefs, Constants.WalletCount); +// } + +// getResNum(prefs, url) async { +// var count = prefs.getInt(url + UserData().basicInfo.userId.toString()); +// systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count); + +// msgNum += systemInfo[url]; +// } + +// setResNum(url) async { +// var localKey = url + UserData().basicInfo.userId.toString(); +// if (systemInfo[url] > 0) { +// SharedPreferences prefs = await SharedPreferences.getInstance(); +// var count = prefs.getInt(localKey); +// prefs.setInt( +// localKey, count == null ? systemInfo[url] : (systemInfo[url] + count)); +// msgNum -= systemInfo[url]; +// systemInfo[url] = 0; +// } +// } + +// class _ConversActionPageState extends State +// with SingleTickerProviderStateMixin { +// TabController tabCtrl; + +// void getSystemMsg(data) async { +// Map data = { +// "userId": UserData().basicInfo.userId, +// "type": UserData().basicInfo.sex +// }; +// data['sign'] = TokenMgr().getSign(data); + +// Response res = await HttpUtil().post('message/all/message', data: data); +// if (res == null) { +// return; +// } +// Map resData = res.data; +// if (resData['code'] == 0) { +// SharedPreferences prefs = await SharedPreferences.getInstance(); +// systemInfo = resData['data']; +// msgNum = 0; +// getAllResNum(prefs); +// if (mounted) { +// setState(() {}); +// } +// } +// } + +// @override +// void initState() { +// super.initState(); + +// MessageMgr().on('update_system', getSystemMsg); +// // MessageMgr().on('Quit Group', quitGroup); +// // +// // MessageMgr().on('Update Group List', updateGroupLastMsg); +// getSystemMsg(null); + +// tabCtrl = TabController(length: 2, vsync: this); +// } + +// @override +// void dispose() { +// tabCtrl.dispose(); +// MessageMgr().off('update_system', getSystemMsg); +// super.dispose(); +// } + +// @override +// Widget build(BuildContext context) { +// // List groupList = GroupInfoMgr().groupInfoList; + +// return Scaffold( +// backgroundColor: Colors.white, +// appBar: AppBar( +// //backgroundColor: Constants.LightGreyBackgroundColor, +// centerTitle: false, +// title: Text( +// I18n.of(context).message_center, +// textScaleFactor: 1.0, +// style: Constants.MainTitleStyle, +// ), +// actions: [ +// Container( +// child: IconButton( +// icon: CircleAvatar( +// backgroundColor: Constants.GreyBackgroundColor, +// radius: 13.75, +// child: Padding( +// padding: EdgeInsets.only(bottom: 1.5), +// child: Icon( +// IconData(0xe659, +// fontFamily: Constants.IconFontFamily), +// color: Constants.BlackTextColor, +// size: 21, +// ))), +// onPressed: () { +// CustomUI().goScanPage(context); +// }, +// ), +// ), +// // InkWell( +// // onTap: () { +// // Navigator.of(context).push( +// // new MaterialPageRoute( +// // builder: (context) { +// // return MessagePushPage(); +// // }, +// // ), +// // ); +// // }, +// // child: Padding( +// // padding: EdgeInsets.only(right: 10), +// // child: CircleAvatar( +// // backgroundColor: Constants.GreyBackgroundColor, +// // radius: 13.75, +// // child: Icon( +// // Icons.settings, +// // color: Constants.BlackTextColor, +// // size: 22, +// // )), +// // )), +// ], +// elevation: 0, +// bottom: PreferredSize( +// preferredSize: Size.fromHeight(28), +// child: Container( +// padding: EdgeInsets.only(left: 2), +// decoration: BoxDecoration( +// //color: Constants.LightGreyBackgroundColor, +// border: +// Border(bottom: BorderSide(color: Color(0xffeaeaea)))), +// alignment: Alignment.centerLeft, +// child: TabBar( +// isScrollable: true, +// indicatorPadding: EdgeInsets.only(left: 9, right: 9), +// tabs: [ +// UnreadDot( +// child: Container( +// margin: EdgeInsets.only(right: 4), +// child: Text(I18n.of(context).text_chat, +// textScaleFactor: 1.0), +// ), +// type: 1), +// // UnreadDot( +// // child: Container( +// // margin: EdgeInsets.only(right: 4), +// // child: Text(I18n.of(context).group_chat, +// // textScaleFactor: 1.0), +// // ), +// // type: 4), +// UnreadDot( +// child: Container( +// margin: EdgeInsets.only(right: 4), +// child: Text(I18n.of(context).system_information, +// textScaleFactor: 1.0)), +// type: 2), +// ], +// controller: tabCtrl, +// ), +// )), +// ), +// body: SafeArea( +// child: TabBarView( +// children: [ +// LastChatPage(), +// // ListView.builder( +// //// controller: _scrollController, +// // itemBuilder: (BuildContext context, int index) { +// // if (index == 0) { +// // return _buildCreateButton(); +// // } else { +// // var info = groupList[index - 1]; +// // return GroupItem(ValueKey(info), groupInfoModel: info); +// // } +// // }, +// // itemCount: groupList.length + 1, +// // ), +// ListView( +// children: [ +// SizedBox(height: 8.5), +// _ConversationItem( +// icon: 'assets/images/chat/icon1.png', +// bgColor: Constants.RadioGradient, +// conversation: Conversation( +// avatar: 'assets/images/ic_tx_news.png', +// title: I18n.of(context).radio_message, +// desc: RichTitle.normalTitle( +// systemInfo['castList'], context, InfoType.Radio), +// updateAt: systemInfo['castList'] == null +// ? "" +// : WebData().getLoginTime( +// context, systemInfo['castList']['CreateTime']), +// unreadMsgCount: systemInfo['castCount'], +// ), +// callback: () { +// setResNum(Constants.CastCount); +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return InfoListPage( +// title: I18n.of(context).radio_message, +// type: InfoType.Radio, +// ); +// }, +// ), +// ); +// }, +// ), +// _ConversationItem( +// icon: 'assets/images/chat/icon4.png', +// bgColor: Constants.MoneyGradient, +// conversation: Conversation( +// avatar: 'assets/images/ic_tx_news.png', +// title: I18n.of(context).wallet_reminder, +// desc: RichTitle.normalTitle(systemInfo['walletList'], +// context, InfoType.IncomeMoney), +// updateAt: systemInfo['walletList'] == null +// ? "" +// : WebData().getLoginTime( +// context, systemInfo['walletList']['CreateTime']), +// unreadMsgCount: systemInfo['walletCount'], +// ), +// callback: () { +// setResNum(Constants.WalletCount); +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return InfoListPage( +// title: I18n.of(context).wallet_reminder, +// type: InfoType.IncomeMoney, +// ); +// }, +// ), +// ); +// }, +// ), +// _ConversationItem( +// icon: 'assets/images/chat/icon3.png', +// iconSize: 27, +// bgColor: Constants.ApplyGradient, +// conversation: Conversation( +// avatar: 'assets/images/ic_tx_news.png', +// title: I18n.of(context).application_notice, +// desc: RichTitle.normalTitle( +// systemInfo['applyList'], context, InfoType.Apply), +// updateAt: systemInfo['applyList'] == null +// ? "" +// : WebData().getLoginTime( +// context, systemInfo['applyList']['CreatTime']), +// unreadMsgCount: systemInfo['applyCount'], +// ), +// callback: () { +// setResNum(Constants.ApplyCount); +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return InfoListPage( +// title: I18n.of(context).application_notice, +// type: InfoType.Apply, +// ); +// }, +// ), +// ); +// }, +// ), +// _ConversationItem( +// icon: 'assets/images/chat/icon6.png', +// bgColor: Constants.EvaGradient, +// conversation: Conversation( +// avatar: 'assets/images/ic_tx_news.png', +// title: I18n.of(context).evaluation_notice, +// desc: RichTitle.normalTitle(systemInfo['evaluateList'], +// context, InfoType.Evaluation), +// updateAt: systemInfo['evaluateList'] == null +// ? '' +// : WebData().getLoginTime( +// context, systemInfo['evaluateList']['CreateTime']), +// unreadMsgCount: systemInfo['evaluateCount'], +// ), +// callback: () { +// setResNum(Constants.EvaluateCount); +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return InfoListPage( +// title: I18n.of(context).evaluation_notice, +// type: 2, +// ); +// }, +// ), +// ); +// }, +// ), +// _ConversationItem( +// icon: 'assets/images/chat/icon5.png', +// bgColor: Constants.ParkGradient, +// conversation: Conversation( +// avatar: 'assets/images/ic_tx_news.png', +// title: I18n.of(context).appName, +// desc: RichTitle.normalTitle( +// systemInfo['parkList'], context, InfoType.System), +// updateAt: systemInfo['parkList'] == null +// ? "" +// : WebData().getLoginTime( +// context, systemInfo['parkList']['CreateTime']), +// unreadMsgCount: systemInfo['parkCount'], +// ), +// callback: () { +// setResNum(Constants.ParkCount); +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return InfoListPage( +// title: I18n.of(context).appName, +// type: InfoType.System, +// ); +// }, +// ), +// ); +// }, +// ) +// ], +// ) +// ], +// controller: tabCtrl, +// ))); +// } + +// Widget _buildCreateButton() { +// List groupList = GroupInfoMgr().groupInfoList; +// Widget _avatarIcon = ClipRRect( +// borderRadius: BorderRadius.circular(GroupRadius), +// child: Container( +// color: const Color(0xFFF2F2F2), +// height: AvatarSize, +// width: AvatarSize, +// child: Icon( +// IconData(0xe66f, fontFamily: Constants.IconFontFamily), +// color: Constants.BlueTextColor, +// size: 35, +// ), +// )); + +// Widget _button = InkWell( +// onTap: () { +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return CreateGroupPage( +// GroupOperatingPageType.CreateGroup, [], null); +// }, +// ), +// ); +// }, +// child: Container( +// padding: EdgeInsets.only(top: 14, bottom: 14), +// color: Constants.GreyBackgroundColor, +// child: Container( +// height: ItemHeight, +// decoration: BoxDecoration(color: Colors.white), +// child: Row( +// children: [ +// SizedBox(width: LeftPadding), +// _avatarIcon, +// SizedBox(width: 14.0), +// Text( +// I18n.of(context).create_group_chat, +// textScaleFactor: 1.0, +// style: TextStyle(fontSize: 15.5), +// ), +// ], +// ), +// ))); + +// Widget tips = Container( +// alignment: Alignment.centerLeft, +// width: Screen.width, +// height: 33.5, +// padding: EdgeInsets.only(left: LeftPadding), +// decoration: BoxDecoration( +// color: Colors.white, +// border: Border(bottom: Constants.GreyBorderSide)), +// child: Text( +// I18n.of(context).group_chat + '(${groupList.length})', +// textScaleFactor: 1.0, +// ), +// ); + +// return Column( +// children: [ +// SizedBox( +// height: 10, +// ), +// CustomUI.buildSearchButton(context, () { +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return GlobalSearchPage( +// type: GlobalSearchPageType.SearchGroup, +// ); +// }, +// ), +// ); +// }, bottom: 10), +// _button, +// tips, +// ], +// ); +// } + +// // quitGroup(args) { +// // if (mounted) { +// // setState(() { +// // print('更新群列表'); +// // }); +// // } +// // } +// // +// // updateGroupLastMsg(args) async { +// // await GroupInfoMgr().sortGroupList(); +// // if (mounted) { +// // setState(() {}); +// // } +// // } +// } diff --git a/lib/home/VerificationCenter.dart b/lib/home/VerificationCenter.dart index 4a2bc7c..6f0ae14 100644 --- a/lib/home/VerificationCenter.dart +++ b/lib/home/VerificationCenter.dart @@ -4,6 +4,7 @@ import 'package:chat/data/constants.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/LoadingDialog.dart'; +import 'package:chat/utils/sp_utils.dart'; import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; @@ -68,7 +69,8 @@ class _VerificationCenterPageState extends State { if (state == 0 || state == 1) { isPostVideo = true; videoUrl = resData['data']['AttestationValue']; - _controller = VideoPlayerController.network(videoUrl) + var path = await UserData().getLoaclVideoPath(videoUrl); + _controller = VideoPlayerController.file(new File(path)) ..initialize().then((_) { setState(() { isLoadingVideoFinish = true; @@ -338,9 +340,14 @@ class _VerificationCenterPageState extends State { isShowLoading: true); var resData = res.data; if (resData['code'] == 0) { + SPUtils.saveString( + Constants.LocalCertifiedvideo + + UserData().basicInfo.userId.toString(), + videoFile.path); showToast(I18n.of(context).success); videoUrl = resData['msg']; isPostVideo = true; + isLoadingVideoFinish = true; _controller = VideoPlayerController.file(videoFile) ..initialize().then((_) { // Ensure the first frame is shown after the video is initialized, even before the play button has been pressed. diff --git a/lib/home/VideoPage.dart b/lib/home/VideoPage.dart index 1917165..933b9f5 100644 --- a/lib/home/VideoPage.dart +++ b/lib/home/VideoPage.dart @@ -1,3 +1,6 @@ +import 'dart:io'; + +import 'package:chat/data/UserData.dart'; import 'package:chat/data/constants.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/utils/CustomUI.dart'; @@ -8,7 +11,6 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_ijkplayer/flutter_ijkplayer.dart'; -import 'package:video_player/video_player.dart'; class VideoPage extends StatefulWidget { final userId; @@ -18,7 +20,6 @@ class VideoPage extends StatefulWidget { } class _VideoPageState extends State { - VideoPlayerController _controller; bool isShowPlayButton = true; bool isLoadingFish = false; @@ -35,7 +36,7 @@ class _VideoPageState extends State { @override void dispose() { SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); - _controller.dispose(); + controller.dispose(); super.dispose(); } @@ -52,26 +53,15 @@ class _VideoPageState extends State { if (resData['code'] == 0) { var videoUrl = resData['data']['AttestationValue']; if (videoUrl != '' && videoUrl != null) { -// _controller = VideoPlayerController.network(videoUrl) -// ..initialize().then((_) { -// isLoadingFish = true; -// setState(() {}); -// }); -// _controller.addListener(() { -// if (_controller.value.position >= _controller.value.duration) { -// isShowPlayButton = true; -// setState(() {}); -// } -// }); isLoadingFish = true; + var filePath = await UserData().getLoaclVideoPath(videoUrl); + controller.setFileDataSource(File(filePath), autoPlay: false); setState(() {}); - WidgetsBinding.instance.addPostFrameCallback((_) { - controller.setNetworkDataSource(videoUrl, autoPlay: false); - }); } } } + @override Widget build(BuildContext context) { Widget appBar = new AppBar( @@ -111,47 +101,5 @@ class _VideoPageState extends State { }, mediaController: controller, ); - -// Widget stack = Stack( -// alignment: Alignment.center, -// children: [ -// -// Container( -// width: Screen.width, -// child: _controller != null && _controller.value.initialized -// ? AspectRatio( -// aspectRatio: _controller.value.aspectRatio, -// child: VideoPlayer(_controller), -// ) -// : Container(), -// ), -// InkWell( -// highlightColor: Colors.transparent, -// radius: 0, -// onTap: () { -// setState(() { -// if (!_controller.value.isPlaying) { -// _controller.seekTo(Duration()); -// _controller.play(); -// isShowPlayButton = false; -// setState(() {}); -// } -// }); -// }, -// child: Container( -// height: MediaQuery.of(context).size.height, -// color: Colors.black.withOpacity( -// _controller != null && _controller.value.isPlaying ? 0 : 0.5), -// padding: EdgeInsets.only(bottom: 20), -// alignment: Alignment.center, -// child: Image.asset( -// 'assets/images/bofang.png', -// width: -// _controller != null && _controller.value.isPlaying ? 0 : 70, -// ), -// )) -// ], -// ); -// return stack; } } diff --git a/lib/home/new_friends.dart b/lib/home/new_friends.dart index 7a509b5..d0f64e5 100644 --- a/lib/home/new_friends.dart +++ b/lib/home/new_friends.dart @@ -13,7 +13,6 @@ import 'package:dio/dio.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:oktoast/oktoast.dart'; import 'package:provider/provider.dart'; import 'package:chat/models/friends_info.dart'; import 'ProfilePage.dart'; diff --git a/lib/utils/PicSwiper.dart b/lib/utils/PicSwiper.dart index cca8501..835a047 100644 --- a/lib/utils/PicSwiper.dart +++ b/lib/utils/PicSwiper.dart @@ -131,7 +131,7 @@ class _PicSwiperState extends State }; data['sign'] = TokenMgr().getSign(data); data['price'] = price; - Response res = await HttpUtil().post('user/browse/photo', data: data); + Response res = await HttpUtil().post('user/browse/photo', data: data,isShowLoading: true); Map resData = res.data; print(resData); if (resData['code'] == 0) { diff --git a/lib/utils/upload_util.dart b/lib/utils/upload_util.dart index 4bbe1ae..1c521c6 100644 --- a/lib/utils/upload_util.dart +++ b/lib/utils/upload_util.dart @@ -114,7 +114,7 @@ class UploadUtil { return cancelMap[fileId]; } - cancelSendMsg(MsgModel msgModel){ + cancelSendMsg(MsgModel msgModel) { var token = cancelMap[msgModel.extraFile]; if (token != null) { token.cancel('用户取消'); @@ -265,6 +265,24 @@ class UploadUtil { } } + //下载认证视频 + Future downloadCertifiedvideo(String url, downloadSuccess) async { + Response response; + var path = await FileCacheMgr().genFilePath(url); + try { + response = await dio.download(url, path); + if (response.statusCode == 200) { + if (downloadSuccess != null) downloadSuccess(); + return path; + } else { + showToast(I18n.of(Constants.getCurrentContext()).server_error_tips); + return null; + } + } catch (e) { + showToast(I18n.of(Constants.getCurrentContext()).server_error_tips); + } + } + //机器人翻译,type 1文字,2语音 Future commitTranslateSource( int type, int sourceLang, int toLang, dynamic content) async { diff --git a/pubspec.yaml b/pubspec.yaml index 5e04abf..5f19193 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: chat description: A new Flutter project. #修改版本号后get-clean -version: 1.1.0+15 +version: 1.1.3+17 environment: sdk: ">=2.1.0 <3.0.0"