From 51bb86318c5eafc1027178dc5e845232f33cadb2 Mon Sep 17 00:00:00 2001 From: jiahao <283739569@qq.com> Date: Wed, 25 Mar 2020 16:44:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=BF=9D=E5=AD=98/=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .flutter-plugins-dependencies | 2 +- lib/chat/ChatPageItem.dart | 53 +- lib/chat/group_chat_item.dart | 61 +- lib/chat/input_bar.dart | 12 +- lib/home/ConversActionPage.dart | 2138 +++++++++++++++--------------- lib/home/homeMain.dart | 142 +- lib/main.dart | 1 + lib/utils/HttpUtil.dart | 4 +- lib/utils/screen.dart | 2 +- lib/utils/wpop/w_popup_menu.dart | 6 + pubspec.lock | 7 + pubspec.yaml | 5 +- 12 files changed, 1276 insertions(+), 1157 deletions(-) diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index 10f2431..51117eb 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"agora_rtc_engine","dependencies":[]},{"name":"amap_location","dependencies":[]},{"name":"android_intent","dependencies":[]},{"name":"app_installer","dependencies":[]},{"name":"apple_sign_in","dependencies":[]},{"name":"audioplayer","dependencies":[]},{"name":"auto_orientation","dependencies":[]},{"name":"city_pickers","dependencies":[]},{"name":"connectivity","dependencies":[]},{"name":"easy_contact_picker","dependencies":[]},{"name":"file_picker","dependencies":[]},{"name":"flutter_app_badger","dependencies":[]},{"name":"flutter_audio_recorder","dependencies":[]},{"name":"flutter_bugly","dependencies":[]},{"name":"flutter_facebook_login","dependencies":[]},{"name":"flutter_ijkplayer","dependencies":[]},{"name":"flutter_inapp_purchase","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"flutter_native_image","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_qr_reader","dependencies":["image_picker"]},{"name":"flutter_webview_plugin","dependencies":[]},{"name":"fluwx_no_pay","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"google_maps_flutter","dependencies":[]},{"name":"image_cropper","dependencies":[]},{"name":"image_gallery_saver","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"jpush_flutter","dependencies":[]},{"name":"keyboard_utils","dependencies":[]},{"name":"location","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"open_file","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"photo_manager","dependencies":[]},{"name":"receive_sharing_intent","dependencies":[]},{"name":"share","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":[]},{"name":"video_player","dependencies":[]},{"name":"video_thumbnail","dependencies":[]},{"name":"wifi_info_plugin","dependencies":[]}]} \ No newline at end of file +{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"agora_rtc_engine","dependencies":[]},{"name":"amap_location","dependencies":[]},{"name":"android_intent","dependencies":[]},{"name":"app_installer","dependencies":[]},{"name":"apple_sign_in","dependencies":[]},{"name":"audioplayer","dependencies":[]},{"name":"auto_orientation","dependencies":[]},{"name":"city_pickers","dependencies":[]},{"name":"connectivity","dependencies":[]},{"name":"easy_contact_picker","dependencies":[]},{"name":"file_picker","dependencies":[]},{"name":"flutter_app_badger","dependencies":[]},{"name":"flutter_audio_recorder","dependencies":[]},{"name":"flutter_bugly","dependencies":[]},{"name":"flutter_facebook_login","dependencies":[]},{"name":"flutter_ijkplayer","dependencies":[]},{"name":"flutter_inapp_purchase","dependencies":[]},{"name":"flutter_local_notifications","dependencies":[]},{"name":"flutter_native_image","dependencies":[]},{"name":"flutter_plugin_android_lifecycle","dependencies":[]},{"name":"flutter_qr_reader","dependencies":["image_picker"]},{"name":"flutter_webview_plugin","dependencies":[]},{"name":"fluwx_no_pay","dependencies":[]},{"name":"geolocator","dependencies":["google_api_availability","location_permissions"]},{"name":"google_api_availability","dependencies":[]},{"name":"google_maps_flutter","dependencies":[]},{"name":"image_cropper","dependencies":[]},{"name":"image_gallery_saver","dependencies":[]},{"name":"image_picker","dependencies":["flutter_plugin_android_lifecycle"]},{"name":"jpush_flutter","dependencies":[]},{"name":"keyboard_utils","dependencies":[]},{"name":"location","dependencies":[]},{"name":"location_permissions","dependencies":[]},{"name":"open_file","dependencies":[]},{"name":"package_info","dependencies":[]},{"name":"path_provider","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"photo_manager","dependencies":[]},{"name":"receive_sharing_intent","dependencies":[]},{"name":"share","dependencies":[]},{"name":"share_extend","dependencies":[]},{"name":"shared_preferences","dependencies":["shared_preferences_macos","shared_preferences_web"]},{"name":"shared_preferences_macos","dependencies":[]},{"name":"shared_preferences_web","dependencies":[]},{"name":"sqflite","dependencies":[]},{"name":"url_launcher","dependencies":[]},{"name":"video_player","dependencies":[]},{"name":"video_thumbnail","dependencies":[]},{"name":"wifi_info_plugin","dependencies":[]}]} \ No newline at end of file diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index c33346f..03a7d1b 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -26,6 +26,7 @@ import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/app_navigator.dart'; import 'package:chat/utils/date_utils.dart'; +import 'package:chat/utils/file_cache_mgr.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/screen.dart'; import 'package:chat/utils/sound_util.dart'; @@ -38,6 +39,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:oktoast/oktoast.dart'; import 'package:provider/provider.dart'; +import 'package:share_extend/share_extend.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../r.dart'; import 'full_img_view.dart'; @@ -290,14 +293,17 @@ class _ChatPageItemState extends State _textMsg(List msgContent) { var msg = utf8.decode(msgContent); - + bool isUrl =false; + if(textList[curTextType].contains('http') ){ + isUrl =true; + } Widget text = Container( constraints: BoxConstraints(maxWidth: Screen.width - 120), child: extendedText( msg, hideKeyboard: widget.hideKeyboard, fontSize: FontSize, - color: Colors.black, + color: isUrl?Colors.blue:Colors.black, ), padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), decoration: BoxDecoration( @@ -638,6 +644,27 @@ class _ChatPageItemState extends State AppNavigator.pushForwardPage(context, widget.msg); }); + if (widget.msg.msgType == ChatType.FileChatType.value &&widget.msg.localFile!=null) { + //分享文件 + actions.add('保存文件'); + actionsFunc.add(() async{ + + String path = widget.msg.localFile; + + String type='file'; + if(path.contains('mp4') ||path.contains('mp3')){ + type = 'video'; + }else if(path.contains('png')||path.contains('jpg')||path.contains('jpeg')||path.contains('JPG')||path.contains('PNG')){ + type = 'image'; + } + + ShareExtend.share(FileCacheMgr.replacePath(path), type); + + + }); + + } + if (widget.msg.msgType == ChatType.TextChatType.value) { actions.insert(0, I18n.of(context).copy); actionsFunc.insert(0, () { @@ -663,9 +690,23 @@ class _ChatPageItemState extends State }); } // String date2 = DateTime.fromMillisecondsSinceEpoch(widget.msg.time).toString(); + bool isUrl =false; + if(widget.msg.msgType==ChatType.TextChatType.value ){ + if( textList[curTextType].contains('http')){ + isUrl =true; + } + + } return WPopupMenu( child: item, actions: actions, + onTap: ()async{ + if(isUrl){ + if (await canLaunch(textList[curTextType])) { + launch(textList[curTextType]); + } + } + }, onLongPressStart: () { isLongPressed = true; setState(() {}); @@ -727,13 +768,19 @@ class _ChatPageItemState extends State _receiveText(MsgModel msg) { List showMsg = []; if (textList.length > 0) { + + bool isUrl =false; + if(textList[curTextType].contains('http') ){ + isUrl =true; + } + showMsg.add(Container( constraints: BoxConstraints(maxWidth: Screen.width - 140, minHeight: 24), alignment: Alignment.centerLeft, child: extendedText( textList[curTextType], - color: Constants.BlackTextColor, + color: isUrl?Colors.blue:Constants.BlackTextColor, hideKeyboard: widget.hideKeyboard, fontSize: FontSize, ))); diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 764c1bc..e5a1c46 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; @@ -35,11 +36,15 @@ import 'package:chat/utils/video_anim.dart'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:path_provider/path_provider.dart'; import 'package:provider/provider.dart'; import 'package:oktoast/oktoast.dart'; import 'package:chat/utils/HttpUtil.dart'; +import 'package:share_extend/share_extend.dart'; +import 'package:url_launcher/url_launcher.dart'; import '../r.dart'; +import '../utils/file_cache_mgr.dart'; import 'full_img_view.dart'; import 'upload_item.dart'; import 'package:chat/models/ref_name_provider.dart'; @@ -279,13 +284,17 @@ class _GroupChatPageItemState extends State if (msg.contains(' ]')) { msg = msg.replaceAll(' ]', ']'); } + bool isUrl =false; + if(textList[curTextType].contains('http') ){ + isUrl =true; + } Widget text = Container( constraints: BoxConstraints(maxWidth: Screen.width - 120), child: extendedText( msg, hideKeyboard: widget.hideKeyboard, fontSize: FontSize, - color: SendMsgText, + color: isUrl?Colors.blue:SendMsgText, ), padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), decoration: BoxDecoration( @@ -577,6 +586,31 @@ class _GroupChatPageItemState extends State AppNavigator.pushForwardPage(context, widget.msg); }); + + + + + if (widget.msg.msgType == ChatType.FileChatType.value &&widget.msg.localFile!=null) { + //分享文件 + actions.add('保存文件'); + actionsFunc.add(() async{ + + String path = widget.msg.localFile; + + String type='file'; + if(path.contains('mp4') ||path.contains('mp3')){ + type = 'video'; + }else if(path.contains('png')||path.contains('jpg')||path.contains('jpeg')||path.contains('JPG')||path.contains('PNG')){ + type = 'image'; + } + + ShareExtend.share(FileCacheMgr.replacePath(path), type); + + + }); + + } + if (widget.msg.msgType == ChatType.TextChatType.value) { actions.insert(0, I18n.of(context).copy); actionsFunc.insert(0, () { @@ -602,9 +636,24 @@ class _GroupChatPageItemState extends State } // String date2 = DateTime.fromMillisecondsSinceEpoch(widget.msg.time).toString(); + bool isUrl =false; + if(widget.msg.msgType==ChatType.TextChatType.value ){ + if( textList[curTextType].contains('http')){ + isUrl =true; + } + + } + return WPopupMenu( child: item, actions: actions, + onTap: ()async{ + if(isUrl){ + if (await canLaunch(textList[curTextType])) { + launch(textList[curTextType]); + } + } + }, onLongPressStart: () { isLongPressed = true; setState(() {}); @@ -705,13 +754,21 @@ class _GroupChatPageItemState extends State _receiveText(MsgModel msg) { List showMsg = []; if (textList.length > 0) { + bool isUrl =false; + if(textList[curTextType].contains('http') ){ + isUrl =true; + } + + + showMsg.add(Container( constraints: BoxConstraints(maxWidth: Screen.width - 140, minHeight: 22), alignment: Alignment.centerLeft, child: extendedText( textList[curTextType], - color: Constants.BlackTextColor, + color: isUrl?Colors.blue:Constants.BlackTextColor, + hideKeyboard: widget.hideKeyboard, fontSize: FontSize, ))); diff --git a/lib/chat/input_bar.dart b/lib/chat/input_bar.dart index 7159ad2..a222ba9 100644 --- a/lib/chat/input_bar.dart +++ b/lib/chat/input_bar.dart @@ -233,10 +233,10 @@ class InputBarState extends State bool isGroup = Provider.of(context); Widget centerWidget; - Widget input = Container( - child: ExtendedTextField( - textSelectionControls: MyExtendedMaterialTextSelectionControls(), + child: + TextField( +// textSelectionControls: ExtendedMaterialTextSelectionControls(), keyboardAppearance: Brightness.light, onChanged: (String messageText) { if (_textCtrl.text.length > 0) { @@ -262,9 +262,9 @@ class InputBarState extends State textBaseline: TextBaseline.alphabetic), maxLines: 3, minLines: 1, - specialTextSpanBuilder: MySpecialTextSpanBuilder( - showAtBackground: true, - ), +// specialTextSpanBuilder: MySpecialTextSpanBuilder( +// showAtBackground: true, +// ), controller: _textCtrl, textInputAction: TextInputAction.newline, inputFormatters: [ diff --git a/lib/home/ConversActionPage.dart b/lib/home/ConversActionPage.dart index 7f1cf53..3d646f3 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'; @@ -757,478 +140,1095 @@ class _ConversActionPageState extends State // ], // ), // ), -// // Container(width: 10.0), -// SizedBox( -// height: Constants.ConversationAvatarSize, -// child: Column( -// crossAxisAlignment: CrossAxisAlignment.end, -// mainAxisAlignment: MainAxisAlignment.start, -// children: _rightArea, -// ), -// ) +// // 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, +// ), +// )), // ), -// ), -// 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; -//} +// 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, +// ))); +// } // -//getAllResNum(prefs) { -// getResNum(prefs, Constants.ApplyCount); -// getResNum(prefs, Constants.EvaluateCount); -// getResNum(prefs, Constants.ParkCount); -// getResNum(prefs, Constants.CastCount); -// getResNum(prefs, Constants.WalletCount); -//} +// 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, +// ), +// )); // -//getResNum(prefs, url) async { -// var count = prefs.getInt(url + UserData().basicInfo.userId.toString()); -// systemInfo[url] = count == null ? systemInfo[url] : (systemInfo[url] - count); +// 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), +// ), +// ], +// ), +// ))); // -// msgNum += systemInfo[url]; -//} +// 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})'), +// ); // -//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; +// 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, +// ], +// ); // } -//} -// -//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(() {}); -// } +// quitGroup(args) { +// if (mounted) { +// setState(() { +// print('更新群列表'); +// }); // } // } // -// @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(); +// 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); // -// @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: [ +// 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).text_chat, +// child: Text(I18n.of(context).group_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, -// ); -// }, -// ), -// ); +// 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, // ), -// _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, -// ))); + 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('更新群列表'); +// }); +// } // } // -// 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, -// ], -// ); +// updateGroupLastMsg(args) async { +// await GroupInfoMgr().sortGroupList(); +// if (mounted) { +// setState(() {}); +// } // } -// -//// quitGroup(args) { -//// if (mounted) { -//// setState(() { -//// print('更新群列表'); -//// }); -//// } -//// } -//// -//// updateGroupLastMsg(args) async { -//// await GroupInfoMgr().sortGroupList(); -//// if (mounted) { -//// setState(() {}); -//// } -//// } -//} +} diff --git a/lib/home/homeMain.dart b/lib/home/homeMain.dart index dbd0c6a..d4dcf26 100644 --- a/lib/home/homeMain.dart +++ b/lib/home/homeMain.dart @@ -313,79 +313,22 @@ class _HomeMainState extends State { I18n.of(context).me ]; - _navigationViews = [ - NavigationIconView( - title: _titles[2], - icon: IconData( - 0xe67c, - fontFamily: 'iconfont', - ), - isShowdot: true, - iconSize: 29), - NavigationIconView( - title: _titles[0], - isShowdot: true, - iconMargin: EdgeInsets.only(top: 2), - type: 5, - icon: IconData( - 0xe66e, - fontFamily: 'iconfont', - ), - iconSize: 26.5), - NavigationIconView( - title: _titles[1], - icon: IconData( - 0xe656, - fontFamily: 'iconfont', - ), - isCenter: true, - iconSize: 31), - NavigationIconView( - title: _titles[1], - isShowdot: true, - icon: IconData( - 0xe60b, - fontFamily: 'iconfont', - ), - type: 6, - iconSize: 26.5), - NavigationIconView( - title: _titles[3], - icon: IconData( - 0xe67b, - fontFamily: 'iconfont', - ), - iconSize: 26.5), - ]; - - _pages = [ - RealTimeHelperPage(), - FriendPage(), - FindPage(), - ConversActionPage(), -// GroupChatListPage(), - ProfilePage( - userId: UserData().basicInfo.userId, - ), - ]; - // _navigationViews = [ // NavigationIconView( -// title: _titles[1], -// isShowdot: true, +// title: _titles[2], // icon: IconData( -// 0xe60b, +// 0xe67c, // fontFamily: 'iconfont', // ), -// type: 1, -// iconSize: 26.5), +// isShowdot: true, +// iconSize: 29), // NavigationIconView( // title: _titles[0], // isShowdot: true, // iconMargin: EdgeInsets.only(top: 2), // type: 5, // icon: IconData( -// 0xe663, +// 0xe66e, // fontFamily: 'iconfont', // ), // iconSize: 26.5), @@ -397,17 +340,15 @@ class _HomeMainState extends State { // ), // isCenter: true, // iconSize: 31), -// // NavigationIconView( -// title: _titles[3], +// title: _titles[1], // isShowdot: true, // icon: IconData( -// 0xe66e, +// 0xe60b, // fontFamily: 'iconfont', // ), -// type: 4, +// type: 6, // iconSize: 26.5), -// // NavigationIconView( // title: _titles[3], // icon: IconData( @@ -418,17 +359,76 @@ class _HomeMainState extends State { // ]; // // _pages = [ -// ConversActionPage(), -//// RealTimeHelperPage(), +// RealTimeHelperPage(), // FriendPage(), // FindPage(), -//// ConversActionPage(), -// GroupChatListPage(), +// ConversActionPage(), +//// GroupChatListPage(), // ProfilePage( // userId: UserData().basicInfo.userId, // ), // ]; + _navigationViews = [ + NavigationIconView( + title: _titles[1], + isShowdot: true, + icon: IconData( + 0xe60b, + fontFamily: 'iconfont', + ), + type: 1, + iconSize: 26.5), + NavigationIconView( + title: _titles[0], + isShowdot: true, + iconMargin: EdgeInsets.only(top: 2), + type: 5, + icon: IconData( + 0xe663, + fontFamily: 'iconfont', + ), + iconSize: 26.5), + NavigationIconView( + title: _titles[1], + icon: IconData( + 0xe656, + fontFamily: 'iconfont', + ), + isCenter: true, + iconSize: 31), + + NavigationIconView( + title: _titles[3], + isShowdot: true, + icon: IconData( + 0xe66e, + fontFamily: 'iconfont', + ), + type: 4, + iconSize: 26.5), + + NavigationIconView( + title: _titles[3], + icon: IconData( + 0xe67b, + fontFamily: 'iconfont', + ), + iconSize: 26.5), + ]; + + _pages = [ + ConversActionPage(), +// RealTimeHelperPage(), + FriendPage(), + FindPage(), +// ConversActionPage(), + GroupChatListPage(), + ProfilePage( + userId: UserData().basicInfo.userId, + ), + ]; + } diff --git a/lib/main.dart b/lib/main.dart index 42f1230..d09193a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -144,6 +144,7 @@ Map language = { 'zh_Hans_US': LanguageType.SimplifiedChinese, 'zh_Hans_MO': LanguageType.SimplifiedChinese, 'zh_Hans_SG': LanguageType.SimplifiedChinese, + 'zh_Hans_VN': LanguageType.SimplifiedChinese, 'zh_CN': LanguageType.SimplifiedChinese, 'ko_KR': LanguageType.Korean, diff --git a/lib/utils/HttpUtil.dart b/lib/utils/HttpUtil.dart index d742a5c..a2eae7f 100644 --- a/lib/utils/HttpUtil.dart +++ b/lib/utils/HttpUtil.dart @@ -43,9 +43,9 @@ class HttpUtil { //static const String BaseUrl = 'http://192.168.0.223:7001/'; //static const String BaseUrl = 'http://192.168.0.207:9080/'; - static const String BaseUrl = 'http://120.79.107.63:9080/'; +// static const String BaseUrl = 'http://120.79.107.63:9080/'; //static const String BaseUrl = 'http://192.168.0.177:9016/'; -// static const String BaseUrl = 'https://datasm.chengyouhd.com/'; + static const String BaseUrl = 'https://datasm.chengyouhd.com/'; static HttpUtil _getInstance() { if (_instance == null) { diff --git a/lib/utils/screen.dart b/lib/utils/screen.dart index aea9410..8ac35cb 100644 --- a/lib/utils/screen.dart +++ b/lib/utils/screen.dart @@ -68,7 +68,7 @@ extendedText(String text, double emojisize = 20.0, Function hideKeyboard, fontWeight,int maxLines, - Function onSpecialTextTap + Function onSpecialTextTap, }) { return ExtendedText( text, diff --git a/lib/utils/wpop/w_popup_menu.dart b/lib/utils/wpop/w_popup_menu.dart index d40358a..aacde4c 100644 --- a/lib/utils/wpop/w_popup_menu.dart +++ b/lib/utils/wpop/w_popup_menu.dart @@ -16,6 +16,7 @@ class WPopupMenu extends StatefulWidget { this.menuHeight = 38, this.onLongPressStart, this.onLongPressEnd, + this.onTap }); final ValueChanged onValueChanged; @@ -28,6 +29,7 @@ class WPopupMenu extends StatefulWidget { final double menuHeight; final Function onLongPressStart; final Function onLongPressEnd; + final Function onTap; @override _WPopupMenuState createState() => _WPopupMenuState(); @@ -60,6 +62,10 @@ class _WPopupMenuState extends State { return GestureDetector( child: widget.child, onTap: () { + if(widget.onTap!=null){ + widget.onTap(); + } + if (widget.pressType == PressType.singleClick) { onTap(); } diff --git a/pubspec.lock b/pubspec.lock index 02f2bdb..aa6333a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -916,6 +916,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.6.3+4" + share_extend: + dependency: "direct main" + description: + name: share_extend + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.1.1" shared_preferences: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index c972722..3b03a7b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -47,7 +47,7 @@ dependencies: permission_handler: ^4.0.0 location_permissions: ^2.0.3 - # audioplayer: ^0.5.2 +# audioplayer: ^0.5.2 audioplayer: git: https://github.com/randomjoho/audioplayer.git @@ -156,7 +156,7 @@ dependencies: lpinyin: ^1.0.7 #网页-支付跳转 - flutter_webview_plugin: ^0.3.10+1 + flutter_webview_plugin: ^0.3.10 # firebase_auth: ^0.15.3 #图片保存 @@ -174,6 +174,7 @@ dependencies: #文件打开 open_file: ^3.0.1 + share_extend: ^1.1.1 dev_dependencies: