diff --git a/assets/fonts/iconfont.ttf b/assets/fonts/iconfont.ttf index 04c186a..bf143a8 100644 Binary files a/assets/fonts/iconfont.ttf and b/assets/fonts/iconfont.ttf differ diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh index c2e3548..7f00e2d 100755 --- a/ios/Flutter/flutter_export_environment.sh +++ b/ios/Flutter/flutter_export_environment.sh @@ -7,5 +7,5 @@ export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build/ios" export "FLUTTER_FRAMEWORK_DIR=/Users/random/sdk/flutter_sdk/bin/cache/artifacts/engine/ios" export "FLUTTER_BUILD_NAME=1.0.9" -export "FLUTTER_BUILD_NUMBER=13" +export "FLUTTER_BUILD_NUMBER=14" export "TRACK_WIDGET_CREATION=true" diff --git a/lib/chat/ChatPage.dart b/lib/chat/ChatPage.dart index 47cfa58..2782af0 100644 --- a/lib/chat/ChatPage.dart +++ b/lib/chat/ChatPage.dart @@ -365,12 +365,6 @@ class _ChatPageState extends State { widget.isTranslateButler ? _buildTranslationButler() : Container(), - widget.isTranslateButler - ? _buildServiceCard(true, () {}) - : Container(), - widget.isTranslateButler - ? _buildServiceCard(false, () {}) - : Container(), Expanded(child: _buildMessageList()), InputBar(sendMsg: sendMsg), ], @@ -396,8 +390,8 @@ class _ChatPageState extends State { ); }, ))), - widget.isTranslateButler ? getAudioChatView() : Container(), - widget.isTranslateButler ? zoomAudioButton() : Container() +// widget.isTranslateButler ? getAudioChatView() : Container(), +// widget.isTranslateButler ? zoomAudioButton() : Container() ], ); } @@ -580,7 +574,7 @@ class _ChatPageState extends State { () { Navigator.of(context).pop(); }, - countDownTime: 360, + countDownTime: 3600, align: Alignment.centerRight, onPress: () {}, ), @@ -591,67 +585,6 @@ class _ChatPageState extends State { ); } - Widget _buildServiceCard(bool isStart, Function callBack) { - return Container( - margin: EdgeInsets.all(10), - child: Card( - elevation: 2, - // 阴影 - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10), -// side: BorderSide(color: Colors.green,width: 25), - ), - child: Padding( - padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15), - child: Row( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - isStart - ? I18n.of(context).translation_butler_start_service - : I18n.of(context).translation_butler_service_end, - textScaleFactor: 1.0, - style: TextStyle( - color: AppColors.NewAppbarTextColor, fontSize: 15), - ), - Text( - isStart - ? I18n.of(context).translation_butler_start_tips - : I18n.of(context).translation_butler_evaluation_tips, - textScaleFactor: 1.0, - style: TextStyle( - color: AppColors.NewAppbarTextColor, fontSize: 13), - ) - ], - ), - isStart - ? Container() - : Expanded( - child: Container( - margin: EdgeInsets.only(left: 15), - height: 30, - child: RaisedButton( - color: Color(0xff3875E9), - shape: RoundedRectangleBorder( - borderRadius: - BorderRadius.all(Radius.circular(10))), - child: Text( - I18n.of(context).translation_butler_evaluation, - textScaleFactor: 1.0, - style: TextStyle(color: Colors.white, fontSize: 15), - ), - onPressed: () { - CustomUI.buildTranslationEvaluationDialog(context); - }), - )), - ], - ), - ), - ), - ); - } Widget _buildMessageList() { return Container( @@ -695,11 +628,16 @@ class _ChatPageState extends State { } sendMsg(MsgModel msg) { + +// if(widget.isTranslateButler){ ///翻译管家聊天通道 +// msg.channelType = ChatChannelType.TransHK.value; +// } + print('对方是否拉黑你 ${friendInfo.isBlackened}'); if (BlacklistMgr.isBlack(friendInfo.userId)) { return; } - + print('chat page session id:${msg.sessionId}'); if (!friendInfo.isCanStrangerNews && !FriendListMgr().isMyFriend(friendInfo.userId)) { showToast(I18n.of(context).stranger_close_tips); diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index 5b2101c..cd4e3ff 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -22,6 +22,7 @@ import 'package:chat/models/keyboard_provider.dart'; import 'package:chat/models/ref_name_provider.dart'; import 'package:chat/proto/chat.pbenum.dart'; import 'package:chat/proto/chat.pbserver.dart'; +import 'package:chat/proto/transhousekeeper.pb.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/MessageMgr.dart'; @@ -210,6 +211,7 @@ class _ChatPageItemState extends State } _msgWidget() { + if (widget.msg.from == 0) { return _serverNotifyMsg(); } else { @@ -257,24 +259,44 @@ class _ChatPageItemState extends State } else { ///todo 翻译管家系统通知消息 + print('这里应该要有翻译管家'); + if (type == ChatType.GroupChatNoticeType.value && widget.msg.channelType ==ChatChannelType.Session.value) { + TransHKChatNotice res = TransHKChatNotice.fromBuffer(widget.msg.msgContent); + + if(res.noticeType==TransHKChatNoticeType.StartChat){ + ///开始翻译服务 + return _buildServiceCard(true, () {}); + }else if(res.noticeType==TransHKChatNoticeType.EndChat){ + ///翻译服务结束 + return _buildServiceCard(false, () {}); + }else{ + return Container(); + } +// return Container(); + + } +// else{ +// if (type == ChatType.GroupChatNoticeType.value) { +// var res = GroupChatNotice.fromBuffer(widget.msg.msgContent); +// +// var groupInfoModel = Provider.of(context); +// var showStr = MsgHandler.getGroupNoticeMsg(res, groupInfoModel); +// return Container( +// alignment: Alignment.center, +// constraints: BoxConstraints(maxWidth: Screen.width - 120), +// child: Text( +// showStr, +// textScaleFactor: 1.0, +// textAlign: TextAlign.center, +// style: TextStyle(color: Constants.GreyTextColor, fontSize: 12), +// ), +// ); +// } +// } + - if (type == ChatType.GroupChatNoticeType.value) { - var res = GroupChatNotice.fromBuffer(widget.msg.msgContent); - var groupInfoModel = Provider.of(context); - var showStr = MsgHandler.getGroupNoticeMsg(res, groupInfoModel); - return Container( - alignment: Alignment.center, - constraints: BoxConstraints(maxWidth: Screen.width - 120), - child: Text( - showStr, - textScaleFactor: 1.0, - textAlign: TextAlign.center, - style: TextStyle(color: Constants.GreyTextColor, fontSize: 12), - ), - ); - } } return Container(); } @@ -1048,7 +1070,7 @@ class _ChatPageItemState extends State isAutoDown: false, msg: widget.msg, onFinishTap: (){ - widget.hideKeyboard(); + showFullImg(context, widget.msg); }, child: Container( @@ -1297,6 +1319,7 @@ class _ChatPageItemState extends State void showFullImg(BuildContext context, MsgModel msg) { print('显示图片'); + widget.hideKeyboard(); Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { return PhotoPage(msg: msg); @@ -1399,4 +1422,70 @@ class _ChatPageItemState extends State : Container() ]); } + + + Widget _buildServiceCard(bool isStart, Function callBack) { + return Container( + + alignment: Alignment.center, + margin: EdgeInsets.all(10), + child: Card( + elevation: 2, + // 阴影 + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(10), +// side: BorderSide(color: Colors.green,width: 25), + ), + child: Padding( + padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15), + child: Row( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + isStart + ? I18n.of(context).translation_butler_start_service + : I18n.of(context).translation_butler_service_end, + textScaleFactor: 1.0, + style: TextStyle( + color: AppColors.NewAppbarTextColor, fontSize: 15), + ), + Text( + isStart + ? I18n.of(context).translation_butler_start_tips + : I18n.of(context).translation_butler_evaluation_tips, + textScaleFactor: 1.0, + style: TextStyle( + color: AppColors.NewAppbarTextColor, fontSize: 13), + ) + ], + ), + isStart + ? Container() + : Expanded( + child: Container( + margin: EdgeInsets.only(left: 15), + height: 30, + child: RaisedButton( + color: Color(0xff3875E9), + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.all(Radius.circular(10))), + child: Text( + I18n.of(context).translation_butler_evaluation, + textScaleFactor: 1.0, + style: TextStyle(color: Colors.white, fontSize: 15), + ), + onPressed: () { + CustomUI.buildTranslationEvaluationDialog(context); + }), + )), + ], + ), + ), + ), + ); + } + } diff --git a/lib/chat/company_server_view.dart b/lib/chat/company_server_view.dart index e9b176a..f1bf89a 100644 --- a/lib/chat/company_server_view.dart +++ b/lib/chat/company_server_view.dart @@ -172,7 +172,7 @@ class _CompanyServerPageState extends State { for (var i = 0; i < resultList.length; i++) { Asset photoEntity = resultList[i]; ByteData byteData = await photoEntity.getByteData(); - File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', byteData.buffer.asInt8List(0)); _sendPhotoFile(file); } } diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index ae0a11c..75bcabf 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -1055,7 +1055,6 @@ class _GroupChatPageItemState extends State isAutoDown: false, msg: widget.msg, onFinishTap: (){ - widget.hideKeyboard(); showFullImg(context, widget.msg); }, child: Container( @@ -1080,7 +1079,7 @@ class _GroupChatPageItemState extends State return InkWell( onTap: () { if (widget.msg.localFile != null) { - widget.hideKeyboard(); + showVideoPage(context, widget.msg.localFile); } }, @@ -1101,6 +1100,7 @@ class _GroupChatPageItemState extends State } showVideoPage(BuildContext context, String filePath) { + widget.hideKeyboard(); Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { return VideoPage(videoPath: filePath); @@ -1285,6 +1285,9 @@ class _GroupChatPageItemState extends State void showFullImg(BuildContext context, MsgModel msg) { print('显示图片'); + if( widget.hideKeyboard!=null){ + widget.hideKeyboard(); + } Navigator.push(context, MaterialPageRoute(builder: (BuildContext context) { return PhotoPage(msg: msg); diff --git a/lib/chat/input_bar.dart b/lib/chat/input_bar.dart index 6b4205f..3e171e1 100644 --- a/lib/chat/input_bar.dart +++ b/lib/chat/input_bar.dart @@ -707,7 +707,7 @@ class InputBarState extends State for (var i = 0; i < resultList.length; i++) { Asset photoEntity = resultList[i]; ByteData byteData = await photoEntity.getByteData(); - File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', byteData.buffer.asInt8List(0)); _sendPhotoFile(file); } } diff --git a/lib/chat/translate_state.dart b/lib/chat/translate_state.dart index cad1afd..29a6018 100644 --- a/lib/chat/translate_state.dart +++ b/lib/chat/translate_state.dart @@ -93,7 +93,7 @@ class _TranslateSateWidgetState extends State { if (mounted) { setState(() {}); } - MsgHandler.swtichTranslateState(newState); +// MsgHandler.swtichTranslateState(newState); } } @@ -121,7 +121,7 @@ class _TranslateSateWidgetState extends State { translateStatus = TranslateState.valueOf(status); //同步双方翻译状态 - MsgHandler.swtichTranslateState(translateStatus); +// MsgHandler.swtichTranslateState(translateStatus); if (mounted) { setState(() {}); } diff --git a/lib/chat/util_keyboard.dart b/lib/chat/util_keyboard.dart index 698ecdc..d5350ce 100644 --- a/lib/chat/util_keyboard.dart +++ b/lib/chat/util_keyboard.dart @@ -313,6 +313,11 @@ class _UtilKeyboardState extends State { showToast(I18n.of(context).max_file.replaceFirst('/s1', 33.toString())); return; } + ///ios存在着文件夹才打得开 + File newFile= await FileCacheMgr().writeFile(file.path.split('/').last, file.readAsBytesSync()); + + + int friendId = 0; if (!widget.isGroup) { @@ -336,7 +341,7 @@ class _UtilKeyboardState extends State { var msg = MsgHandler.createSendMsg( ChatType.FileChatType, fileMsg.writeToBuffer(), friendId: friendId, - localFile: file.path, + localFile: newFile.path, channelType: widget.isGroup ? ChatChannelType.Group : ChatChannelType.Session); diff --git a/lib/data/chat_data_mgr.dart b/lib/data/chat_data_mgr.dart index 509a570..9223e62 100644 --- a/lib/data/chat_data_mgr.dart +++ b/lib/data/chat_data_mgr.dart @@ -280,8 +280,9 @@ class ChatDataMgr { } var result = getMsgBy(msg.sessionId, msg.time, true); if (result != null) { - // print('消息存在!!!!'); + print('消息存在!!!!'); } else { + print('插入消息!!!!'); insertToDB(msg, record); } } else { @@ -386,6 +387,7 @@ class ChatDataMgr { groupUnreadProvider.updateUnreadCount(msgModel.sessionId, 1); } } else { + print('更新最后一条记录msgModel friendid :${msgModel.friendId}'); lastMsgProvider.updateLastMsg(msgModel); if (msgModel.readState == 1) { unreadCountProvider.updateUnreadCount(msgModel.sessionId, 1); diff --git a/lib/data/translate_hk_data_mgr.dart b/lib/data/translate_hk_data_mgr.dart new file mode 100644 index 0000000..ffd0420 --- /dev/null +++ b/lib/data/translate_hk_data_mgr.dart @@ -0,0 +1,47 @@ +import 'dart:convert'; + +import 'package:chat/data/UserData.dart'; +import 'package:chat/data/chat_data_mgr.dart'; +import 'package:chat/models/group_info_model.dart'; +import 'package:chat/proto/chat.pbserver.dart'; +import 'package:chat/utils/MessageMgr.dart'; +import 'package:chat/utils/group_member_model.dart'; +import 'package:chat/utils/sql_util.dart'; +import 'package:chat/utils/upload_util.dart'; +import 'package:crclib/crclib.dart'; + + +class TranslateOrder{ + String orderId; + int createTime; + int tLanguage; + int scenes; + String desc; +} + +class TranslateHKMgr { + static TranslateHKMgr _instance; + factory TranslateHKMgr() => _getInstance(); + + TranslateHKMgr._(); + static TranslateHKMgr _getInstance() { + if (_instance == null) { + _instance = TranslateHKMgr._(); + } + return _instance; + } + + TranslateOrder order; + + String orderId; + int waitNum=0; + + + + int orderStatus=0; + + static const ORDER_STATUS_EMPTY=0; ///未创建订单 + static const ORDER_STATUS_WAITING=1;///等待翻译官 + static const ORDER_STATUS_START=1;///翻译管家开始 + +} diff --git a/lib/home/AddProgram.dart b/lib/home/AddProgram.dart index 4116141..b153722 100644 --- a/lib/home/AddProgram.dart +++ b/lib/home/AddProgram.dart @@ -733,8 +733,10 @@ class _AddProgramState extends State { List fileList = []; for (var i = 0; i < resultList.length; i++) { Asset photoEntity = resultList[i]; + print('名字:${photoEntity.name}'); ByteData byteData = await photoEntity.getByteData(); - File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', byteData.buffer.asInt8List(0)); + fileList.add(file); } print('文件列表${fileList.length}'); diff --git a/lib/home/ConversActionPage.dart b/lib/home/ConversActionPage.dart index 3d646f3..7f1cf53 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'; @@ -859,12 +242,12 @@ class _ConversActionPageState extends State super.initState(); MessageMgr().on('update_system', getSystemMsg); -// MessageMgr().on('Quit Group', quitGroup); -// -// MessageMgr().on('Update Group List', updateGroupLastMsg); + MessageMgr().on('Quit Group', quitGroup); + + MessageMgr().on('Update Group List', updateGroupLastMsg); getSystemMsg(null); - tabCtrl = TabController(length: 2, vsync: this); + tabCtrl = TabController(length: 3, vsync: this); } @override @@ -872,11 +255,14 @@ class _ConversActionPageState extends State 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; + List groupList = GroupInfoMgr().groupInfoList; return Scaffold( backgroundColor: Colors.white, @@ -950,13 +336,13 @@ class _ConversActionPageState extends State 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).group_chat, + textScaleFactor: 1.0), + ), + type: 4), UnreadDot( child: Container( margin: EdgeInsets.only(right: 4), @@ -972,18 +358,18 @@ class _ConversActionPageState extends State 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.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), @@ -1021,8 +407,8 @@ class _ConversActionPageState extends State conversation: Conversation( avatar: 'assets/images/ic_tx_news.png', title: I18n.of(context).wallet_reminder, - desc: RichTitle.normalTitle(systemInfo['walletList'], - context, InfoType.IncomeMoney), + desc: RichTitle.normalTitle( + systemInfo['walletList'], context, InfoType.IncomeMoney), updateAt: systemInfo['walletList'] == null ? "" : WebData().getLoginTime( @@ -1174,7 +560,6 @@ class _ConversActionPageState extends State SizedBox(width: 14.0), Text( I18n.of(context).create_group_chat, - textScaleFactor: 1.0, style: TextStyle(fontSize: 15.5), ), ], @@ -1189,10 +574,7 @@ class _ConversActionPageState extends State decoration: BoxDecoration( color: Colors.white, border: Border(bottom: Constants.GreyBorderSide)), - child: Text( - I18n.of(context).group_chat + '(${groupList.length})', - textScaleFactor: 1.0, - ), + child: Text(I18n.of(context).group_chat + '(${groupList.length})'), ); return Column( @@ -1217,18 +599,636 @@ class _ConversActionPageState extends State ); } -// quitGroup(args) { -// if (mounted) { -// setState(() { -// print('更新群列表'); -// }); + 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'; +//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(() {}); +// } // } // } // -// updateGroupLastMsg(args) async { -// await GroupInfoMgr().sortGroupList(); -// 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/InformUser.dart b/lib/home/InformUser.dart index 2d3e746..6f8c9d5 100644 --- a/lib/home/InformUser.dart +++ b/lib/home/InformUser.dart @@ -204,7 +204,7 @@ class _InformUserPageState extends State { for (var i = 0; i < resultList.length; i++) { Asset photoEntity = resultList[i]; ByteData byteData = await photoEntity.getByteData(); - File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-$i', byteData.buffer.asInt8List(0)); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', byteData.buffer.asInt8List(0)); fileList.add(file); } Map data = {"type": 3, "userId": UserData().basicInfo.userId}; diff --git a/lib/home/ProfilePage.dart b/lib/home/ProfilePage.dart index 539ed5b..8c0e770 100644 --- a/lib/home/ProfilePage.dart +++ b/lib/home/ProfilePage.dart @@ -12,6 +12,7 @@ import 'package:chat/utils/ChargeMoney.dart'; import 'package:chat/utils/app_navigator.dart'; import 'package:chat/utils/blacklist_mgr.dart'; import 'package:chat/utils/conversation_table.dart'; +import 'package:chat/utils/file_cache_mgr.dart'; import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/screen.dart'; @@ -38,6 +39,7 @@ import 'package:flutter/services.dart'; import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; import 'package:oktoast/oktoast.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:photo_manager/photo_manager.dart'; @@ -429,18 +431,35 @@ class _ProfilePageState extends State // ); // } // } - var photos = await PhotoPicker.pickAsset( - context: context, - themeColor: Color(0xFFF0F0F0), - textColor: Color(0xFF3F3F3F), - pickType: PickType.onlyImage); - if (photos != null && photos.length > 0) { + + List resultList = List(); + + resultList = await MultiImagePicker.pickImages( + maxImages: 9, + enableCamera: false, + selectedAssets: [], + cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"), + materialOptions: MaterialOptions( + actionBarColor: "#50A7F9", + actionBarTitle: "Hibok", + allViewTitle: "", + useDetailsView: false, + selectCircleStrokeColor: "#000000", + ), + ); + + if (resultList != null && resultList.length > 0) { List fileList = []; - for (var i = 0; i < photos.length; i++) { - AssetEntity photoEntity = photos[i]; - fileList.add(await photoEntity.file); + for (var i = 0; i < resultList.length; i++) { + Asset photoEntity = resultList[i]; + print('名字:${photoEntity.name}'); + ByteData byteData = await photoEntity.getByteData(); + File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', byteData.buffer.asInt8List(0)); + + fileList.add(file); } + print('文件列表${fileList.length}'); Map data = {"type": 2, "userId": UserData().basicInfo.userId}; data['sign'] = TokenMgr().getSign(data); data['sex'] = UserData().basicInfo.sex; @@ -453,12 +472,43 @@ class _ProfilePageState extends State if (resData['data']['msg'] != '' && resData['data']['msg'] != null) { showToast(resData['data']['msg']); } - if(resData['msg'].split('|').length !=photos.length){ + if(resData['msg'].split('|').length !=fileList.length){ showToast(I18n.of(context).hava_error_photo); } MessageMgr().emit('refresh_photo'); } } + +// var photos = await PhotoPicker.pickAsset( +// context: context, +// themeColor: Color(0xFFF0F0F0), +// textColor: Color(0xFF3F3F3F), +// pickType: PickType.onlyImage); + +// if (photos != null && photos.length > 0) { +// List fileList = []; +// for (var i = 0; i < photos.length; i++) { +// AssetEntity photoEntity = photos[i]; +// fileList.add(await photoEntity.file); +// } +// Map data = {"type": 2, "userId": UserData().basicInfo.userId}; +// data['sign'] = TokenMgr().getSign(data); +// data['sex'] = UserData().basicInfo.sex; +// data['isBurn'] = 0; +// Response res = await HttpUtil().uploadFiles( +// fileList, data, 'upload/post/postfiles', 'image', +// isShowLoading: true); +// var resData = res.data; +// if (resData['code'] == 0) { +// if (resData['data']['msg'] != '' && resData['data']['msg'] != null) { +// showToast(resData['data']['msg']); +// } +// if(resData['msg'].split('|').length !=photos.length){ +// showToast(I18n.of(context).hava_error_photo); +// } +// MessageMgr().emit('refresh_photo'); +// } +// } } void _sendPicture() async { diff --git a/lib/home/audio_chat_view.dart b/lib/home/audio_chat_view.dart index 03756dd..f014f22 100644 --- a/lib/home/audio_chat_view.dart +++ b/lib/home/audio_chat_view.dart @@ -35,7 +35,7 @@ class AudioChatPage extends StatefulWidget { final bool isReplay; final bool isTranslateButler; final Function translateButlerCloseCallBack; - AudioChatPage({@required this.userInfo, this.isReplay = false, this.isTranslateButler,this.translateButlerCloseCallBack}); + AudioChatPage({@required this.userInfo, this.isReplay = false, this.isTranslateButler=false,this.translateButlerCloseCallBack}); @override _AudioChatPageState createState() => _AudioChatPageState(); } diff --git a/lib/home/homeMain.dart b/lib/home/homeMain.dart index d4dcf26..53da171 100644 --- a/lib/home/homeMain.dart +++ b/lib/home/homeMain.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'package:chat/chat/ChatPage.dart'; import 'package:chat/data/UserData.dart'; import 'package:chat/data/constants.dart'; import 'package:chat/generated/i18n.dart'; @@ -8,6 +9,8 @@ import 'package:chat/home/realtimehelper/real_time_helper_page.dart'; import 'package:chat/home/unread_dot_widget.dart'; import 'package:chat/models/UserInfo.dart'; import 'package:chat/models/ref_name_provider.dart'; +import 'package:chat/proto/transhousekeeper.pb.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'; @@ -162,6 +165,8 @@ class _HomeMainState extends State { MessageMgr().on('Show My Profile', showMyProfile); MessageMgr().on('test_Permission', msgTestPermission); MessageMgr().on(MessageMgr.RECEIVE_THIRD_SHARE, goShareInfo); + MessageMgr().on(MessageMgr.TRANSLATE_HK_RECEIVE_ORDER, receiveTranslateOrder); + MessageMgr().on(MessageMgr.TRANSLATE_HK_START_CHAT, startTranslateHKChat); ///初始化语音播放是外放还是听筒-默认外放 SoundUtils.instance.initPlayMode(); @@ -250,6 +255,8 @@ class _HomeMainState extends State { MessageMgr().off('Show My Profile', showMyProfile); MessageMgr().off('test_Permission', msgTestPermission); MessageMgr().off(MessageMgr.RECEIVE_THIRD_SHARE, goShareInfo); + MessageMgr().off(MessageMgr.TRANSLATE_HK_RECEIVE_ORDER, receiveTranslateOrder); + MessageMgr().off(MessageMgr.TRANSLATE_HK_START_CHAT, startTranslateHKChat); LocalNotificationUtil.instance.dispose(); if (time != null) { time.cancel(); @@ -269,6 +276,25 @@ class _HomeMainState extends State { }); } + receiveTranslateOrder(var data) async { + CustomUI.buildTranslationHelperOrderDialog(context,false,orderId: data.orderId,scenes: data.scenes,desc: data.desc); + } + + startTranslateHKChat(var friendID){ + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return ChatPage( + key: Key('Chat'), + friendId: friendID, + isTranslateButler: true, + ); + }, + ), + ); + } + + msgTestPermission(data) async { PermissionStatus status = await LocationPermissions().checkPermissionStatus(); @@ -313,79 +339,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 +366,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 +385,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/home/realtimehelper/translation_butler_page.dart b/lib/home/realtimehelper/translation_butler_page.dart index 0e65a19..043e5d3 100644 --- a/lib/home/realtimehelper/translation_butler_page.dart +++ b/lib/home/realtimehelper/translation_butler_page.dart @@ -5,12 +5,14 @@ import 'package:chat/chat/ChatPage.dart'; import 'package:chat/data/UserData.dart'; import 'package:chat/data/chat_data_mgr.dart'; import 'package:chat/data/group_data_mgr.dart'; +import 'package:chat/data/translate_hk_data_mgr.dart'; import 'package:chat/home/add_friend.dart'; import 'package:chat/home/group_announcement.dart'; import 'package:chat/home/group_manage_page.dart'; import 'package:chat/models/group_info_model.dart'; import 'package:chat/models/money_change.dart'; import 'package:chat/models/ref_name_provider.dart'; +import 'package:chat/utils/LoadingDialog.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/group_member_model.dart'; import 'package:chat/utils/msgHandler.dart'; @@ -53,41 +55,62 @@ class TranslationButlerPageState extends State { int curToLang = 1; int curSourceLang = UserData().language; int curScenes = 0; - List langList; - List scenesList; + List langList; ///语言列表 + List scenesList; ///场景列表 - String extraMsg; + String extraMsg=''; FocusNode focusNode = new FocusNode(); String textLimitTips=''; ScrollController _scrollController = new ScrollController(); + + int orderStatus = 0; ///订单状态 + int secondsPassed = 1;///等待时间计数 + int timeStamp; ///订单开始时间戳 + Timer waitTimer;///等待时间计时器 + int time60=1; ///60秒一圈计数 + + int waitNum=0; + + refreshOrder(args){ + orderStatus = TranslateHKMgr().orderStatus; + waitNum = TranslateHKMgr().waitNum; + waitTimer = Timer.periodic(Duration(seconds: 1), (Timer t) { + handleTick(); + }); + setState(() {}); + } + @override void initState() { super.initState(); - initData(); + orderStatus = TranslateHKMgr().orderStatus; + waitNum = TranslateHKMgr().waitNum; + initData(); + MessageMgr().on(MessageMgr.TRANSLATE_HK_REFRESH_ORDER, refreshOrder); WidgetsBinding.instance.addPostFrameCallback((_) { - Future.delayed(Duration(seconds: 1), () { -// CustomUI.buildTranslationHelperOrderDialog(context,true); - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return ChatPage( - key: Key('Chat'), - friendId: 100029, - isTranslateButler: true, - ); - }, - ), - ); - }); +// Future.delayed(Duration(seconds: 1), () { +//// CustomUI.buildTranslationHelperOrderDialog(context,true); +// Navigator.of(context).push( +// new MaterialPageRoute( +// builder: (context) { +// return ChatPage( +// key: Key('Chat'), +// friendId: 100029, +// isTranslateButler: true, +// ); +// }, +// ), +// ); +// }); @@ -113,19 +136,18 @@ class TranslationButlerPageState extends State { } } + bool isCreatingOrder=false; apply() { - + if(isCreatingOrder){ + return; + } + isCreatingOrder=true; MsgHandler.sendCreateTranslateOrder(langList[curSourceLang].key,langList[curToLang].key,scenesList[curScenes].key,extraMsg); - isApply = false; - timer = Timer.periodic(Duration(seconds: 1), (Timer t) { - handleTick(); - }); - setState(() {}); } @override @@ -152,9 +174,9 @@ class TranslationButlerPageState extends State { @override void dispose() { - timer?.cancel(); - - if (!isApply && timeStamp != null) { + waitTimer?.cancel(); + MessageMgr().off(MessageMgr.TRANSLATE_HK_REFRESH_ORDER, refreshOrder); + if (orderStatus==TranslateHKMgr.ORDER_STATUS_WAITING && timeStamp != null) { print('保存时间戳$timeStamp'); SPUtils.save(Constants.TranslationHelper, timeStamp.toString()); } @@ -320,13 +342,13 @@ class TranslationButlerPageState extends State { body: SafeArea( child: Container( color: Color(0xffE8EAF0), - child: isApply ? applyPage() : waitPage(), + child: orderStatus==TranslateHKMgr.ORDER_STATUS_EMPTY ? createOrderPage() : waitPage(), ), ), ); } - Widget applyPage() { + Widget createOrderPage() { return ListView( controller: _scrollController, children: [ @@ -575,7 +597,7 @@ class TranslationButlerPageState extends State { textAlign: TextAlign.center, text: TextSpan(children: [ TextSpan( - text: '333', + text: '$waitNum', style: TextStyle( color: Color(0xffFF1010), fontSize: 27)), @@ -608,7 +630,7 @@ class TranslationButlerPageState extends State { textAlign: TextAlign.center, text: TextSpan(children: [ TextSpan( - text: '666', + text: '${waitNum*5}', style: TextStyle( color: Color(0xff3875E9), fontSize: 27)), @@ -693,9 +715,11 @@ class TranslationButlerPageState extends State { onPressed: () async { await SPUtils.save(Constants.TranslationHelper, null); setState(() { - isApply = true; - timer?.cancel(); + orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY; + waitTimer?.cancel(); secondsPassed = 0; + MsgHandler.sendCancelTranslateOrder(); + }); }), ), @@ -717,13 +741,9 @@ class TranslationButlerPageState extends State { ); } - bool isApply = true; - int secondsPassed = 1; - int timeStamp; - Timer timer; - int time60=1; + void handleTick() { -// if (isActive) { + setState(() { secondsPassed = secondsPassed + 1; //需要更新UI @@ -732,7 +752,6 @@ class TranslationButlerPageState extends State { time60=0; } }); -// } } getFull(int sec) { diff --git a/lib/models/last_message_model.dart b/lib/models/last_message_model.dart index 62df97b..0001d1c 100644 --- a/lib/models/last_message_model.dart +++ b/lib/models/last_message_model.dart @@ -32,6 +32,12 @@ class LastMessageModel { friendId = msgModel.from; } + ///翻译管家 + if(msgModel.channelType==ChatChannelType.Session.value && msgModel.msgType==ChatType.GroupChatNoticeType.value){ + friendId = msgModel.friendId; + } + + channelType = msgModel.channelType; type = ChatType.valueOf(msgModel.msgType); diff --git a/lib/models/last_msg_description.dart b/lib/models/last_msg_description.dart index f1b25ea..79534d0 100644 --- a/lib/models/last_msg_description.dart +++ b/lib/models/last_msg_description.dart @@ -7,6 +7,7 @@ import 'package:chat/generated/i18n.dart'; import 'package:chat/models/last_message_model.dart'; import 'package:chat/models/ref_name_provider.dart'; import 'package:chat/proto/chat.pb.dart'; +import 'package:chat/proto/transhousekeeper.pb.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/msgHandler.dart'; @@ -136,17 +137,36 @@ class _LastMsgDescriptionState extends State { break; case ChatType.GroupChatNoticeType: - var notice = - GroupChatNotice.fromBuffer(widget.lastMessageModel.msgContent); - print('widget.lastMessageModel.type ${widget.lastMessageModel.type}'); - var groupInfo = await GroupInfoMgr() - .getGroupInfo(widget.lastMessageModel.sessionId); - - desc = MsgHandler.getGroupNoticeMsg(notice, groupInfo); - print('ggdesc $desc}'); - if (desc.contains('\$')) { - desc = desc.substring(0, desc.indexOf('\$')); - } else {} + + if(widget.lastMessageModel.channelType==ChatChannelType.Session.value){ + ///翻译管家的 通知消息 + desc = '翻译管家---'; + print('翻译管家的 通知消息-'); + TransHKChatNotice res = TransHKChatNotice.fromBuffer(widget.lastMessageModel.msgContent); + if(res.noticeType==TransHKChatNoticeType.StartChat){ + return '[翻译管家服务开始]'; + }else if(res.noticeType==TransHKChatNoticeType.EndChat){ + return '[翻译管家服务结束]'; + }else{ + return ''; + } + + + }else{ + var notice = + GroupChatNotice.fromBuffer(widget.lastMessageModel.msgContent); + print('widget.lastMessageModel.type ${widget.lastMessageModel.type}'); + var groupInfo = await GroupInfoMgr() + .getGroupInfo(widget.lastMessageModel.sessionId); + + desc = MsgHandler.getGroupNoticeMsg(notice, groupInfo); + print('ggdesc $desc}'); + if (desc.contains('\$')) { + desc = desc.substring(0, desc.indexOf('\$')); + } else {} + } + + break; diff --git a/lib/proto/transhousekeeper.pb.dart b/lib/proto/transhousekeeper.pb.dart index a52bdfd..13d5d7f 100644 --- a/lib/proto/transhousekeeper.pb.dart +++ b/lib/proto/transhousekeeper.pb.dart @@ -12,6 +12,8 @@ import 'package:protobuf/protobuf.dart' as $pb; import 'chat.pb.dart' as $0; +import 'transhousekeeper.pbenum.dart'; + export 'transhousekeeper.pbenum.dart'; class IssueTransHKOrderReq extends $pb.GeneratedMessage { @@ -276,79 +278,38 @@ class CancellationTransHKOrderPush extends $pb.GeneratedMessage { void clearOrderId() => clearField(1); } -class TransHKChatStartPush extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo('TransHKChatStartPush', package: const $pb.PackageName('yl_pb')) - ..aInt64(1, 'startTime') - ..a<$core.int>(2, 'targetId', $pb.PbFieldType.OU3) - ..a<$0.BaseUserInfo>(3, 'employer', $pb.PbFieldType.OM, $0.BaseUserInfo.getDefault, $0.BaseUserInfo.create) - ..a<$0.BaseUserInfo>(4, 'inter', $pb.PbFieldType.OM, $0.BaseUserInfo.getDefault, $0.BaseUserInfo.create) - ..hasRequiredFields = false - ; - - TransHKChatStartPush._() : super(); - factory TransHKChatStartPush() => create(); - factory TransHKChatStartPush.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory TransHKChatStartPush.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - TransHKChatStartPush clone() => TransHKChatStartPush()..mergeFromMessage(this); - TransHKChatStartPush copyWith(void Function(TransHKChatStartPush) updates) => super.copyWith((message) => updates(message as TransHKChatStartPush)); - $pb.BuilderInfo get info_ => _i; - @$core.pragma('dart2js:noInline') - static TransHKChatStartPush create() => TransHKChatStartPush._(); - TransHKChatStartPush createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - static TransHKChatStartPush getDefault() => _defaultInstance ??= create()..freeze(); - static TransHKChatStartPush _defaultInstance; - - Int64 get startTime => $_getI64(0); - set startTime(Int64 v) { $_setInt64(0, v); } - $core.bool hasStartTime() => $_has(0); - void clearStartTime() => clearField(1); - - $core.int get targetId => $_get(1, 0); - set targetId($core.int v) { $_setUnsignedInt32(1, v); } - $core.bool hasTargetId() => $_has(1); - void clearTargetId() => clearField(2); - - $0.BaseUserInfo get employer => $_getN(2); - set employer($0.BaseUserInfo v) { setField(3, v); } - $core.bool hasEmployer() => $_has(2); - void clearEmployer() => clearField(3); - - $0.BaseUserInfo get inter => $_getN(3); - set inter($0.BaseUserInfo v) { setField(4, v); } - $core.bool hasInter() => $_has(3); - void clearInter() => clearField(4); -} - -class TransHKChatEndPush extends $pb.GeneratedMessage { - static final $pb.BuilderInfo _i = $pb.BuilderInfo('TransHKChatEndPush', package: const $pb.PackageName('yl_pb')) - ..a<$core.int>(1, 'targetId', $pb.PbFieldType.OU3) - ..aInt64(2, 'endTime') +class TransHKChatNotice extends $pb.GeneratedMessage { + static final $pb.BuilderInfo _i = $pb.BuilderInfo('TransHKChatNotice', package: const $pb.PackageName('yl_pb')) + ..e(1, 'noticeType', $pb.PbFieldType.OE, TransHKChatNoticeType.StartChat, TransHKChatNoticeType.valueOf, TransHKChatNoticeType.values) + ..a<$0.BaseUserInfo>(2, 'operatuId', $pb.PbFieldType.OM, $0.BaseUserInfo.getDefault, $0.BaseUserInfo.create) + ..pc<$0.BaseUserInfo>(3, 'operateduId', $pb.PbFieldType.PM,$0.BaseUserInfo.create) ..hasRequiredFields = false ; - TransHKChatEndPush._() : super(); - factory TransHKChatEndPush() => create(); - factory TransHKChatEndPush.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); - factory TransHKChatEndPush.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); - TransHKChatEndPush clone() => TransHKChatEndPush()..mergeFromMessage(this); - TransHKChatEndPush copyWith(void Function(TransHKChatEndPush) updates) => super.copyWith((message) => updates(message as TransHKChatEndPush)); + TransHKChatNotice._() : super(); + factory TransHKChatNotice() => create(); + factory TransHKChatNotice.fromBuffer($core.List<$core.int> i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromBuffer(i, r); + factory TransHKChatNotice.fromJson($core.String i, [$pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY]) => create()..mergeFromJson(i, r); + TransHKChatNotice clone() => TransHKChatNotice()..mergeFromMessage(this); + TransHKChatNotice copyWith(void Function(TransHKChatNotice) updates) => super.copyWith((message) => updates(message as TransHKChatNotice)); $pb.BuilderInfo get info_ => _i; @$core.pragma('dart2js:noInline') - static TransHKChatEndPush create() => TransHKChatEndPush._(); - TransHKChatEndPush createEmptyInstance() => create(); - static $pb.PbList createRepeated() => $pb.PbList(); - static TransHKChatEndPush getDefault() => _defaultInstance ??= create()..freeze(); - static TransHKChatEndPush _defaultInstance; - - $core.int get targetId => $_get(0, 0); - set targetId($core.int v) { $_setUnsignedInt32(0, v); } - $core.bool hasTargetId() => $_has(0); - void clearTargetId() => clearField(1); - - Int64 get endTime => $_getI64(1); - set endTime(Int64 v) { $_setInt64(1, v); } - $core.bool hasEndTime() => $_has(1); - void clearEndTime() => clearField(2); + static TransHKChatNotice create() => TransHKChatNotice._(); + TransHKChatNotice createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + static TransHKChatNotice getDefault() => _defaultInstance ??= create()..freeze(); + static TransHKChatNotice _defaultInstance; + + TransHKChatNoticeType get noticeType => $_getN(0); + set noticeType(TransHKChatNoticeType v) { setField(1, v); } + $core.bool hasNoticeType() => $_has(0); + void clearNoticeType() => clearField(1); + + $0.BaseUserInfo get operatuId => $_getN(1); + set operatuId($0.BaseUserInfo v) { setField(2, v); } + $core.bool hasOperatuId() => $_has(1); + void clearOperatuId() => clearField(2); + + $core.List<$0.BaseUserInfo> get operateduId => $_getList(2); } diff --git a/lib/proto/transhousekeeper.pbenum.dart b/lib/proto/transhousekeeper.pbenum.dart index 723fd56..d85159c 100644 --- a/lib/proto/transhousekeeper.pbenum.dart +++ b/lib/proto/transhousekeeper.pbenum.dart @@ -30,3 +30,18 @@ class TransHKOrderState extends $pb.ProtobufEnum { const TransHKOrderState._($core.int v, $core.String n) : super(v, n); } +class TransHKChatNoticeType extends $pb.ProtobufEnum { + static const TransHKChatNoticeType StartChat = TransHKChatNoticeType._(1, 'StartChat'); + static const TransHKChatNoticeType EndChat = TransHKChatNoticeType._(2, 'EndChat'); + + static const $core.List values = [ + StartChat, + EndChat, + ]; + + static final $core.Map<$core.int, TransHKChatNoticeType> _byValue = $pb.ProtobufEnum.initByValue(values); + static TransHKChatNoticeType valueOf($core.int value) => _byValue[value]; + + const TransHKChatNoticeType._($core.int v, $core.String n) : super(v, n); +} + diff --git a/lib/proto/transhousekeeper.pbjson.dart b/lib/proto/transhousekeeper.pbjson.dart index f6b0367..aad108a 100644 --- a/lib/proto/transhousekeeper.pbjson.dart +++ b/lib/proto/transhousekeeper.pbjson.dart @@ -16,6 +16,14 @@ const TransHKOrderState$json = const { ], }; +const TransHKChatNoticeType$json = const { + '1': 'TransHKChatNoticeType', + '2': const [ + const {'1': 'StartChat', '2': 1}, + const {'1': 'EndChat', '2': 2}, + ], +}; + const IssueTransHKOrderReq$json = const { '1': 'IssueTransHKOrderReq', '2': const [ @@ -81,21 +89,12 @@ const CancellationTransHKOrderPush$json = const { ], }; -const TransHKChatStartPush$json = const { - '1': 'TransHKChatStartPush', - '2': const [ - const {'1': 'StartTime', '3': 1, '4': 1, '5': 3, '10': 'StartTime'}, - const {'1': 'TargetId', '3': 2, '4': 1, '5': 13, '10': 'TargetId'}, - const {'1': 'Employer', '3': 3, '4': 1, '5': 11, '6': '.yl_pb.BaseUserInfo', '10': 'Employer'}, - const {'1': 'Inter', '3': 4, '4': 1, '5': 11, '6': '.yl_pb.BaseUserInfo', '10': 'Inter'}, - ], -}; - -const TransHKChatEndPush$json = const { - '1': 'TransHKChatEndPush', +const TransHKChatNotice$json = const { + '1': 'TransHKChatNotice', '2': const [ - const {'1': 'TargetId', '3': 1, '4': 1, '5': 13, '10': 'TargetId'}, - const {'1': 'EndTime', '3': 2, '4': 1, '5': 3, '10': 'EndTime'}, + const {'1': 'NoticeType', '3': 1, '4': 1, '5': 14, '6': '.yl_pb.TransHKChatNoticeType', '10': 'NoticeType'}, + const {'1': 'OperatuId', '3': 2, '4': 1, '5': 11, '6': '.yl_pb.BaseUserInfo', '10': 'OperatuId'}, + const {'1': 'OperateduId', '3': 3, '4': 3, '5': 11, '6': '.yl_pb.BaseUserInfo', '10': 'OperateduId'}, ], }; diff --git a/lib/proto/transhousekeeper.proto b/lib/proto/transhousekeeper.proto old mode 100644 new mode 100755 index c760e94..3269413 --- a/lib/proto/transhousekeeper.proto +++ b/lib/proto/transhousekeeper.proto @@ -13,6 +13,12 @@ enum TransHKOrderState{ Completed = 5; //已完成 } +//comid = 3 +enum TransHKChatNoticeType{ + StartChat = 1; //开始 + EndChat = 2; //结束 +} + //-------------------------------------------消息------------------------- //Msg=1 发布翻译管家帮助订单 message IssueTransHKOrderReq { @@ -66,17 +72,9 @@ message CancellationTransHKOrderPush { } - -//Msg = 30 翻译官价聊天开始推送 -message TransHKChatStartPush { - optional int64 StartTime = 1; //开始时间 - optional uint32 TargetId = 2; //目标聊天用户 - optional BaseUserInfo Employer = 3; //雇主信息 - optional BaseUserInfo Inter = 4; //翻译官信息 -} - -//Msg = 31 翻译官价聊天结束推送 -message TransHKChatEndPush { - optional uint32 TargetId = 1; //发送目标Id SessionId or GroudId - optional int64 EndTime = 2; //结束时间 +//翻译会话通告消息 +message TransHKChatNotice { + optional TransHKChatNoticeType NoticeType = 1; //公告类型 + optional BaseUserInfo OperatuId = 2; //操作用户Id + repeated BaseUserInfo OperateduId = 3; //被操作用户Ids 有可能是多人 } \ No newline at end of file diff --git a/lib/utils/CustomUI.dart b/lib/utils/CustomUI.dart index f711477..40ef4cc 100644 --- a/lib/utils/CustomUI.dart +++ b/lib/utils/CustomUI.dart @@ -1389,9 +1389,12 @@ class CustomUI { I18n.of(context) .translation_butler_dialog_start_service, () { - MsgHandler.sendReceiveOrder(orderId); + Navigator.of(context).pop(); - }), + },onPress: (){ + MsgHandler.sendReceiveOrder(); + Navigator.of(context).pop(); + },), ) ], ), diff --git a/lib/utils/HttpUtil.dart b/lib/utils/HttpUtil.dart index 7661a77..86d44dd 100644 --- a/lib/utils/HttpUtil.dart +++ b/lib/utils/HttpUtil.dart @@ -44,9 +44,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/MessageMgr.dart b/lib/utils/MessageMgr.dart index 59abf40..7860774 100644 --- a/lib/utils/MessageMgr.dart +++ b/lib/utils/MessageMgr.dart @@ -6,6 +6,10 @@ class MessageMgr { static const String REFRESH_PUSH_PERMISSION ='refresh_push_permission'; static const String RECEIVE_THIRD_SHARE ='receive_third_share'; + static const String TRANSLATE_HK_REFRESH_ORDER ='translate_hk_refresh_order'; + static const String TRANSLATE_HK_RECEIVE_ORDER ='translate_hk_receive_order'; + static const String TRANSLATE_HK_START_CHAT ='translate_hk_start_chat'; + //私有构造函数 MessageMgr._internal(); diff --git a/lib/utils/image_util.dart b/lib/utils/image_util.dart index 01fd748..df91a60 100644 --- a/lib/utils/image_util.dart +++ b/lib/utils/image_util.dart @@ -189,7 +189,7 @@ class WidgetUtil { //防止头像文件被清除后 Uint8List pngBytes = file.readAsBytesSync(); - print('pngBytes.lengthInBytes length;${pngBytes.lengthInBytes}'); +// print('pngBytes.lengthInBytes length;${pngBytes.lengthInBytes}'); if (pngBytes.lengthInBytes > 8000) { return ClipRRect( borderRadius: BorderRadius.circular(5), @@ -221,7 +221,7 @@ class WidgetUtil { Uint8List pngBytes = byteData.buffer.asUint8List(); File file = await FileCacheMgr() .writeFile(model.sessionId.toString(), pngBytes); - print('图片地址byteData${byteData.lengthInBytes}'); +// print('图片地址byteData${byteData.lengthInBytes}'); if (byteData.lengthInBytes > 8000 && members.length > 1) { //图片保存成功 GroupInfoMgr().updateAvatar(model.sessionId, file.path); diff --git a/lib/utils/msgHandler.dart b/lib/utils/msgHandler.dart index a30ab78..5dc7ad6 100644 --- a/lib/utils/msgHandler.dart +++ b/lib/utils/msgHandler.dart @@ -6,11 +6,14 @@ import 'package:chat/data/UserData.dart'; import 'package:chat/data/chat_data_mgr.dart'; import 'package:chat/data/constants.dart'; import 'package:chat/data/group_data_mgr.dart'; +import 'package:chat/data/translate_hk_data_mgr.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/home/IndexPage.dart'; +import 'package:chat/home/realtimehelper/translation_butler_page.dart'; import 'package:chat/models/ChatMsg.dart'; import 'package:chat/models/group_info_model.dart'; import 'package:chat/proto/all.pbserver.dart'; +import 'package:chat/proto/transhousekeeper.pb.dart'; import 'package:chat/utils/NetUtil.dart'; import 'package:chat/utils/blacklist_mgr.dart'; import 'package:chat/utils/friend_list_mgr.dart'; @@ -23,6 +26,7 @@ import 'package:flutter/material.dart'; import 'package:oktoast/oktoast.dart'; import 'package:fixnum/fixnum.dart'; +import 'LoadingDialog.dart'; import 'MessageMgr.dart'; const MaxMsgContentSize = 1024 * 1024 * 3; @@ -257,9 +261,13 @@ class MsgHandler { // static int receivedCount=0; static handlerReceiveMsg(PushChat chat) async { bool isGroup = false; + bool isTranslateHK= false; if (chat.channelType == ChatChannelType.Group) { print('群聊消息'); isGroup = true; + }else if (chat.channelType == ChatChannelType.TransHK) { + print('聊天管家消息'); + isTranslateHK = true; } MsgModel msgModel; @@ -313,7 +321,7 @@ class MsgHandler { } } else { if (chat.sendUserId == 0) { - print('服务器通知消息 ${chat.sendTime.toInt()}'); + print('服务器通知消息 ${chat.sendTime.toInt()} 是否是翻译管家 $isTranslateHK'); if (isGroup) { if (chat.cType == ChatType.GroupChatNoticeType) { @@ -405,7 +413,40 @@ class MsgHandler { chat.contentBuff, chat.sendTime.toInt(), chat.targetId, channelType: ChatChannelType.Group.value); } - } else {//私聊通知消息 + } + else if(isTranslateHK){ //TODO ddddd + var myId = UserData().basicInfo.userId; + TransHKChatNotice notice = TransHKChatNotice.fromBuffer(chat.contentBuff); + BaseUserInfo friendId ; + + if(notice.operateduId[0].id==myId){ + friendId =notice.operateduId[1]; + }else{ + friendId = notice.operateduId[0]; + } + + + print('notice.operateduId length ${notice.operateduId.length}'); + print('friend id: ${friendId.id} '); + + int sessionId = chat.targetId; + if (chat.cType == ChatType.GroupChatNoticeType) { + print('是群公告哦'); + msgModel = MsgModel(0, friendId.id, chat.cType.value, + chat.contentBuff, chat.sendTime.toInt(), sessionId, + channelType: ChatChannelType.Session.value); + } + + ///接到开始翻译管家消息-打开翻译管家页面 + if(notice.noticeType==TransHKChatNoticeType.StartChat){ + Future.delayed(Duration(seconds: 3),(){ + curActiveSession = sessionId; + print('curActiveSession:$curActiveSession'); + MessageMgr().emit(MessageMgr.TRANSLATE_HK_START_CHAT, friendId.id); + }); + } + + }else{//私聊通知消息 if (chat.cType == ChatType.RedWalletChatType) { //系统红包通知消息 RedWallet wallet = RedWallet.fromBuffer(chat.contentBuff); @@ -430,9 +471,9 @@ class MsgHandler { print('未知私聊通知消息'); } } - } else { //聊天消息 + } + else { //聊天消息 -// receivedCount++; @@ -539,7 +580,7 @@ class MsgHandler { print('消息为空,无法保存'); return; } -// print('收到消息,准备保存 会话Id:${msgModel.sessionId}'); + print('收到消息,准备保存 会话Id:${msgModel.sessionId} friendId: ${msgModel.friendId} ChatType: ${msgModel.channelType}'); ChatDataMgr().saveMsg(msgModel); if (msgModel.msgType == ChatType.ShortVoiceChatType.value) { //如果是语音消息,自动下载 @@ -929,7 +970,7 @@ class MsgHandler { handlerReceiveOrder(content); }else if(msgId ==6){ handlerCancelTranslateOrder(content); - }else if(msgId==50){ + }else if(msgId==20){ handlerDeliveryInterpreterOrderPush(content); } break; @@ -1224,84 +1265,101 @@ class MsgHandler { //发布翻译管家帮助订单 static sendCreateTranslateOrder(int fromLanguage,int toLanguage,int scences,String extraDesc) { - - + showToast('正在创建订单...'); debugPrint('发布翻译管家帮助订单 fromLanguage:$fromLanguage toLanguage: $toLanguage | ${fromLanguage|toLanguage}' ); -// var seq = IssueInterpreterOrderReq.create(); -// seq.tLanguage = fromLanguage|toLanguage; -// -// NetWork().sendMsg(ComId.TranslateOrder, 1, seq); + var seq = IssueTransHKOrderReq.create(); + seq.tLanguage = fromLanguage | toLanguage; + seq.scenes = 0; + seq.desc = extraDesc; + + NetWork().sendMsg(ComId.TranslateOrder, 1, seq); } //发布翻译管家帮助订单回应 static handlerCreateTranslateOrder(List msgContent) { debugPrint('发布翻译管家帮助订单回应'); -// var res = IssueInterpreterOrderRes.fromBuffer(msgContent); -// if (res.errorCode == 0) { -// -//// GroupInfoMgr().updateMemberMsgFree(res.groupId, res.messageFree); -// debugPrint('发布翻译管家帮助订单回应-订单号: ${res.orderId} 等待人数 ${res.waitNum}'); -// } else { -// debugPrint('发布翻译管家帮助订单回应${res.errorCode}'); -// } +// LoadingManage().closeLoading(); + var res = IssueTransHKOrderRes.fromBuffer(msgContent); + if (res.errorCode == 0) { + TranslateHKMgr().orderId = res.orderId; + TranslateHKMgr().waitNum = res.waitNum; + TranslateHKMgr().orderStatus=TranslateHKMgr.ORDER_STATUS_WAITING; + MessageMgr().emit(MessageMgr.TRANSLATE_HK_REFRESH_ORDER); +// GroupInfoMgr().updateMemberMsgFree(res.groupId, res.messageFree); + debugPrint('发布翻译管家帮助订单回应-订单号: ${res.orderId} 等待人数 ${res.waitNum}'); + } else { + debugPrint('发布翻译管家帮助订单回应${res.errorCode}'); + } } //撤销订单消息 - static sendCancelTranslateOrder( String orderId) { - - -// debugPrint('取消订单 fromLanguage:$orderId' ); -// var seq = CancellationInterpreterOrderReq.create(); -// seq.orderId = orderId; -// -// NetWork().sendMsg(ComId.TranslateOrder, 5, seq); + static sendCancelTranslateOrder( ) { + TranslateHKMgr().orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY; + String orderId= TranslateHKMgr().orderId; + debugPrint('取消订单 fromLanguage:$orderId' ); + var seq = CancellationTransHKOrderReq.create(); + seq.orderId = orderId; + + NetWork().sendMsg(ComId.TranslateOrder, 5, seq); } //撤销订单消息回应 static handlerCancelTranslateOrder(List msgContent) { debugPrint('撤销订单消息回应'); -// var res = CancellationInterpreterOrderRes.fromBuffer(msgContent); -// if (res.errorCode == 0) { -// -//// GroupInfoMgr().updateMemberMsgFree(res.groupId, res.messageFree); -// debugPrint('撤销订单消息回应成功: ${res.orderId}'); -// } else { -// debugPrint('撤销订单消息回应成功失败${res.errorCode}'); -// } + var res = CancellationTransHKOrderRes.fromBuffer(msgContent); + if (res.errorCode == 0) { + + debugPrint('撤销订单消息回应成功: ${res.orderId}'); + } else { + debugPrint('撤销订单消息回应成功失败${res.errorCode}'); + } } //派送订单推送 static handlerDeliveryInterpreterOrderPush(List msgContent) { -// debugPrint('撤销订单消息回应'); -// var res = DeliveryInterpreterOrderPush.fromBuffer(msgContent); -// print('OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}'); + debugPrint('派送订单推送'); + var res = DeliveryTransHKOrderPush.fromBuffer(msgContent); + print('OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}'); + + TranslateOrder order = new TranslateOrder(); + order.orderId=res.orderId; + order.desc=res.desc; + order.createTime=res.createTime.toInt(); + order.tLanguage=res.tLanguage.toInt(); + order.scenes=res.scenes.toInt(); + TranslateHKMgr().order = order; + MessageMgr().emit(MessageMgr.TRANSLATE_HK_RECEIVE_ORDER, res); + } //接收订单请求 - static sendReceiveOrder( String orderId) { + static sendReceiveOrder( ) { + TranslateOrder order = TranslateHKMgr().order; + debugPrint('接收订单消息请求 orderId:${order.orderId}' ); + var seq = ReceivingTransHKOrderReq.create(); + seq.orderId = order.orderId; -// debugPrint('接收订单消息请求 orderId:$orderId' ); -// var seq = ReceivingInterpreterOrderReq.create(); -// seq.orderId = orderId; -// -// NetWork().sendMsg(ComId.TranslateOrder,3, seq); + NetWork().sendMsg(ComId.TranslateOrder,3, seq); } //接收订单消息回应 static handlerReceiveOrder(List msgContent) { debugPrint('接收订单消息回应'); -// var res = ReceivingInterpreterOrderRes.fromBuffer(msgContent); -// if (res.errorCode == 0) { -// -//// GroupInfoMgr().updateMemberMsgFree(res.groupId, res.messageFree); -// debugPrint('接收订单消息回应成功: '); -// } else { -// debugPrint('接收订单消息回应失败${res.errorCode}'); -// } - } - + var res = ReceivingTransHKOrderRes.fromBuffer(msgContent); + if (res.errorCode == 0) { +// GroupInfoMgr().updateMemberMsgFree(res.groupId, res.messageFree); + debugPrint('接收订单消息回应成功: '); + } else { + debugPrint('接收订单消息回应失败${res.errorCode}'); + } + } + ///翻译官价聊天开始推送 + static handlerTranslateStart(List msgContent) { + debugPrint('翻译官价聊天开始推送'); +// var res = TransHKChatStartPush.fromBuffer(msgContent); + } //消息免打扰请求结果 static handlerGroupIsShowMenberNiceName(List msgContent) { @@ -1428,14 +1486,15 @@ class MsgHandler { NetWork().sendMsg(ComId.Chat, 100, seq); } - static swtichTranslateState(TranslateState transState) { - print('请求切换人工翻译状态'); - var seq = RequestSetHTranslReq.create(); - seq.sessionId = curActiveSession; - seq.hTransl = transState; - - NetWork().sendMsg(ComId.Chat, 7, seq); - } + ///服务端已作废 +// static swtichTranslateState(TranslateState transState) { +// print('请求切换人工翻译状态'); +// var seq = RequestSetHTranslReq.create(); +// seq.sessionId = curActiveSession; +// seq.hTransl = transState; +// +// NetWork().sendMsg(ComId.Chat, 7, seq); +// } static void receiveTranslateState(msg) { var res = PushHTranslState.fromBuffer(msg); diff --git a/pubspec.yaml b/pubspec.yaml index a421854..30e4d05 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: chat description: A new Flutter project. #修改版本号后get-clean -version: 1.0.9+13 +version: 1.0.9+14 environment: sdk: ">=2.1.0 <3.0.0"