浏览代码

修复翻译消息丢失

master
jiahao 5 年前
父节点
当前提交
889b567bc0
共有 21 个文件被更改,包括 486 次插入406 次删除
  1. +1
    -1
      .flutter-plugins-dependencies
  2. +3
    -0
      android/app/src/main/AndroidManifest.xml
  3. +2
    -1
      i18n/en-US.json
  4. +10
    -9
      i18n/ja-JP.json
  5. +10
    -9
      i18n/ko-KR.json
  6. +4
    -3
      i18n/vi-VN.json
  7. +2
    -3
      i18n/zh-CN.json
  8. +10
    -9
      i18n/zh-HK.json
  9. +1
    -1
      lib/chat/ChatPage.dart
  10. +194
    -190
      lib/chat/ChatPageItem.dart
  11. +140
    -135
      lib/chat/group_chat_item.dart
  12. +2
    -2
      lib/chat/group_chat_view.dart
  13. +20
    -13
      lib/chat/input_bar.dart
  14. +16
    -1
      lib/data/UserData.dart
  15. +8
    -4
      lib/data/chat_data_mgr.dart
  16. +17
    -0
      lib/generated/i18n.dart
  17. +15
    -5
      lib/home/MessagePushPage.dart
  18. +0
    -3
      lib/home/homeMain.dart
  19. +22
    -17
      lib/utils/msgHandler.dart
  20. +7
    -0
      pubspec.lock
  21. +2
    -0
      pubspec.yaml

+ 1
- 1
.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":"device_info","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":"multi_image_picker","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":[]}]}
{"_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":"device_info","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":"multi_image_picker","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":"vibration","dependencies":[]},{"name":"video_player","dependencies":[]},{"name":"video_thumbnail","dependencies":[]},{"name":"wifi_info_plugin","dependencies":[]}]}

+ 3
- 0
android/app/src/main/AndroidManifest.xml 查看文件

@@ -21,6 +21,9 @@
<uses-feature android:name="android.hardware.location.network" android:required="false" />
<uses-feature android:name="android.hardware.location.gps" android:required="false" />
<!-- 震动 -->
<uses-permission android:name="android.permission.VIBRATE"/>
<!-- io.flutter.app.FlutterApplication is an android.app.Application that
calls FlutterMain.startInitialization(this); in its onCreate method.


+ 2
- 1
i18n/en-US.json 查看文件

@@ -1247,5 +1247,6 @@
"translation_butler_introduction": "Still annoying that the other person does n’t understand what you say? Choose the language you need to translate and describe the problem you are experiencing. Personal translation butler will be at your service",
"travel_introduction": "Are you traveling further and further away from your destination? Choose your starting point and ending point, the travel manager will accurately measure the distance for you",
"splash_tips_content4": "Unobstructed travel chat",
"splash_tips_content5": "Worry-free your trip"
"splash_tips_content5": "Worry-free your trip",
"shock_notice": "Vibration notification"
}

+ 10
- 9
i18n/ja-JP.json 查看文件

@@ -1219,14 +1219,14 @@
"translation_input_limit": " /s1と入力することができます",
"translation_more_desc": "詳細説明",
"feedback_assistant": "フィードバックアシスタント",
"feedback_tips":"どんな問題があってもフィードバックしてください",
"man_retranslate":"人工重译",
"robot_retranslate":"机器重译",
"see_original":"查看原文",
"forward":"转发",
"copy_download_url":"复制下载地址",
"total_friends_nus":"共/s1位朋友",
"hava_error_photo":"有图片违规",
"feedback_tips": "どんな問題があってもフィードバックしてください",
"man_retranslate": "人工重译",
"robot_retranslate": "机器重译",
"see_original": "查看原文",
"forward": "转发",
"copy_download_url": "复制下载地址",
"total_friends_nus": "共/s1位朋友",
"hava_error_photo": "有图片违规",
"translation_butler_push_order_time": "时间:今天/s1 时长:",
"translation_butler_push_order_time2": "下单时间:今天/s1 等待时长:",
"translation_butler_title3": "大神专属",
@@ -1246,5 +1246,6 @@
"translation_butler_introduction": "还在烦恼对方听不懂你说什么吗?选择你需要翻译的语言,描述你遇到的问题。贴身翻译管家将随时为你服务",
"travel_introduction": "是否在离目的地越行越远?选择你的起点和终点,出行管家为你精准测距",
"splash_tips_content4": "出行聊天畅通无阻",
"splash_tips_content5": "无忧你的旅行"
"splash_tips_content5": "无忧你的旅行" ,
"shock_notice": "震动通知"
}

+ 10
- 9
i18n/ko-KR.json 查看文件

@@ -1219,14 +1219,14 @@
"translation_input_limit": "/s1자도 입력할 수 있다.",
"translation_more_desc": "더 많은 묘사",
"feedback_assistant": " 피드백 팁",
"feedback_tips":"어떤 문제라도 피드백해 주세요.",
"man_retranslate":"人工重译",
"robot_retranslate":"机器重译",
"see_original":"查看原文",
"forward":"转发",
"copy_download_url":"复制下载地址",
"total_friends_nus":"共/s1位朋友",
"hava_error_photo":"有图片违规",
"feedback_tips": "어떤 문제라도 피드백해 주세요.",
"man_retranslate": "人工重译",
"robot_retranslate": "机器重译",
"see_original": "查看原文",
"forward": "转发",
"copy_download_url": "复制下载地址",
"total_friends_nus": "共/s1位朋友",
"hava_error_photo": "有图片违规",
"translation_butler_evaluation_tips2": "翻译服务已结束,辛苦你了。请保持在线,留意新订单通知",
"translation_butler_push_order_time": "时间:今天/s1 时长:",
"translation_butler_push_order_time2": "下单时间:今天/s1 等待时长:",
@@ -1247,5 +1247,6 @@
"translation_butler_introduction": "还在烦恼对方听不懂你说什么吗?选择你需要翻译的语言,描述你遇到的问题。贴身翻译管家将随时为你服务",
"travel_introduction": "是否在离目的地越行越远?选择你的起点和终点,出行管家为你精准测距",
"splash_tips_content4": "出行聊天畅通无阻",
"splash_tips_content5": "无忧你的旅行"
"splash_tips_content5": "无忧你的旅行" ,
"shock_notice": "震动通知"
}

+ 4
- 3
i18n/vi-VN.json 查看文件

@@ -1225,8 +1225,8 @@
"see_original": "查看原文",
"forward": "转发",
"copy_download_url": "复制下载地址",
"total_friends_nus":"共/s1位朋友",
"hava_error_photo":"有图片违规",
"total_friends_nus": "共/s1位朋友",
"hava_error_photo": "有图片违规",
"translation_butler_push_order_time": "时间:今天/s1 时长:",
"translation_butler_push_order_time2": "下单时间:今天/s1 等待时长:",
"translation_butler_title3": "大神专属",
@@ -1246,5 +1246,6 @@
"translation_butler_introduction": "还在烦恼对方听不懂你说什么吗?选择你需要翻译的语言,描述你遇到的问题。贴身翻译管家将随时为你服务",
"travel_introduction": "是否在离目的地越行越远?选择你的起点和终点,出行管家为你精准测距",
"splash_tips_content4": "出行聊天畅通无阻",
"splash_tips_content5": "无忧你的旅行"
"splash_tips_content5": "无忧你的旅行" ,
"shock_notice": "震动通知"
}

+ 2
- 3
i18n/zh-CN.json 查看文件

@@ -1247,7 +1247,6 @@
"translation_butler_introduction": "还在烦恼对方听不懂你说什么吗?选择你需要翻译的语言,描述你遇到的问题。贴身翻译管家将随时为你服务",
"travel_introduction": "是否在离目的地越行越远?选择你的起点和终点,出行管家为你精准测距",
"splash_tips_content4": "出行聊天畅通无阻",
"splash_tips_content5": "无忧你的旅行"
"splash_tips_content5": "无忧你的旅行",
"shock_notice":"震动通知"
}

+ 10
- 9
i18n/zh-HK.json 查看文件

@@ -1219,14 +1219,14 @@
"translation_input_limit": "还可以输入/s1字",
"translation_more_desc": "更多描述",
"feedback_assistant": "反饋小助手",
"feedback_tips":"有什麼問題都可以反饋給我哦",
"man_retranslate":"人工重譯",
"robot_retranslate":"機器重譯",
"see_original":"查看原文",
"forward":"转发",
"copy_download_url":"複製下載地址",
"total_friends_nus":"共/s1位朋友",
"hava_error_photo":"有圖片違規",
"feedback_tips": "有什麼問題都可以反饋給我哦",
"man_retranslate": "人工重譯",
"robot_retranslate": "機器重譯",
"see_original": "查看原文",
"forward": "转发",
"copy_download_url": "複製下載地址",
"total_friends_nus": "共/s1位朋友",
"hava_error_photo": "有圖片違規",
"translation_butler_push_order_time": "时间:今天/s1 时长:",
"translation_butler_push_order_time2": "下单时间:今天/s1 等待时长:",
"translation_butler_title3": "大神专属",
@@ -1246,5 +1246,6 @@
"translation_butler_introduction": "还在烦恼对方听不懂你说什么吗?选择你需要翻译的语言,描述你遇到的问题。贴身翻译管家将随时为你服务",
"travel_introduction": "是否在离目的地越行越远?选择你的起点和终点,出行管家为你精准测距",
"splash_tips_content4": "出行聊天畅通无阻",
"splash_tips_content5": "无忧你的旅行"
"splash_tips_content5": "无忧你的旅行",
"shock_notice": "震動通知"
}

+ 1
- 1
lib/chat/ChatPage.dart 查看文件

@@ -124,7 +124,7 @@ class _ChatPageState extends State<ChatPage> {
jumIndex = msgList.length - 1;
}
await controller.scrollToIndex(jumIndex,
preferPosition: AutoScrollPosition.begin);
preferPosition: AutoScrollPosition.middle);
controller.highlight(jumIndex,
highlightDuration: new Duration(milliseconds: 100));
}


+ 194
- 190
lib/chat/ChatPageItem.dart 查看文件

@@ -160,8 +160,8 @@ class _ChatPageItemState extends State<ChatPageItem>
showTimeStr =
DateUtils().getFormartData(timeSamp: sendTime, format: 'HH:mm');
} else {
showTimeStr = DateUtils()
.getFormartData(timeSamp: sendTime, format: 'yyyy/MM/dd HH:mm');
showTimeStr =
DateUtils().getFormartData(timeSamp: sendTime, format: 'MM/dd HH:mm');
}
return showTimeStr;
@@ -190,7 +190,7 @@ class _ChatPageItemState extends State<ChatPageItem>
return Container(
width: Screen.width,
margin: const EdgeInsets.symmetric(vertical: 10.0,horizontal: 8),
margin: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 8),
child: Column(
children: <Widget>[
showTime == null
@@ -261,16 +261,18 @@ class _ChatPageItemState extends State<ChatPageItem>
///todo 翻译管家系统通知消息
print('这里应该要有翻译管家');
if (type == ChatType.GroupChatNoticeType.value && widget.msg.channelType ==ChatChannelType.Session.value) {
TransHKChatNotice res = TransHKChatNotice.fromBuffer(widget.msg.msgContent);
if (type == ChatType.GroupChatNoticeType.value &&
widget.msg.channelType == ChatChannelType.Session.value) {
TransHKChatNotice res =
TransHKChatNotice.fromBuffer(widget.msg.msgContent);
if(res.noticeType==TransHKChatNoticeType.StartChat){
if (res.noticeType == TransHKChatNoticeType.StartChat) {
///开始翻译服务
return _buildServiceCard(true, () {});
}else if(res.noticeType==TransHKChatNoticeType.EndChat){
} else if (res.noticeType == TransHKChatNoticeType.EndChat) {
///翻译服务结束
return _buildServiceCard(false, () {});
}else{
} else {
return Container();
}
// return Container();
@@ -295,8 +297,6 @@ class _ChatPageItemState extends State<ChatPageItem>
// }
// }
}
return Container();
}
@@ -314,6 +314,101 @@ class _ChatPageItemState extends State<ChatPageItem>
);
}
double getQuoteContentWidth(QuoteMsg quoteMsg, String refName,
String showTimeStr, String quoteContent) {
double width;
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13);
var nameWidhth = CustomUI.getRealTextWidht(refName, 13);
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 59;
var contentWidht = _getTextWidth(quoteContent, fontSize: 13);
return min(max(width, contentWidht), maxWidth);
}
Widget getQuoteContent(QuoteMsg quoteMsg, String refName, String showTimeStr,
String quoteContent, bool isSend) {
var strColor;
var bgColor;
if (isSend) {
strColor = const Color(0xFF24343C);
bgColor = const Color(0xFFC4E0F5);
} else {
strColor = const Color(0xFF515151);
bgColor = const Color(0xFFEBEBEC);
}
return Container(
padding: EdgeInsets.only(left: 8, bottom: 8),
margin: EdgeInsets.only(bottom: 5, top: 2),
decoration:
BoxDecoration(color: bgColor, borderRadius: BorderRadius.circular(7)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Container(
constraints: BoxConstraints(maxWidth: 70),
child: Text(
refName,
style: TextStyle(fontSize: 13, color: strColor),
overflow: TextOverflow.ellipsis,
)),
SizedBox(width: 10),
Text(
showTimeStr,
style: TextStyle(fontSize: 13, color: strColor),
),
Expanded(child: SizedBox()),
InkWell(
onTap: () {
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt());
},
child: Container(
alignment: Alignment.center,
height: 27,
padding: EdgeInsets.only(
left: 10,
right: 10,
),
child: Icon(
IconData(0xe67e, fontFamily: Constants.IconFontFamily),
size: 13,
color: strColor,
)))
]),
Padding(
padding: EdgeInsets.only(right: 8),
child: Text(
quoteContent,
style: TextStyle(fontSize: 13, color: strColor),
),
),
],
),
);
}
Map getQuoteItem() {
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(widget.msg.refMsgContent);
var refName = Provider.of<RefNameProvider>(context)
.getRefName(friendInfo.userId, friendInfo.nickName);
var msgDate =
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt());
var showTimeStr =
getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt());
var tempIndex = quoteMsg.content.indexOf(':');
var quoteContent = tempIndex == -1
? quoteMsg.content
: quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2);
return {
"quoteMsg": quoteMsg,
"refName": refName,
"showTimeStr": showTimeStr,
"quoteContent": quoteContent,
};
}
_textMsg(List<int> msgContent) {
List<Widget> showMsg = [];
var width = 0.0;
@@ -331,57 +426,12 @@ class _ChatPageItemState extends State<ChatPageItem>
if (widget.msg.refMsgContent != null &&
widget.msg.refMsgContent.length > 0) {
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(widget.msg.refMsgContent);
var refName = Provider.of<RefNameProvider>(context)
.getRefName(friendInfo.userId, friendInfo.nickName);
var msgDate =
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt());
var showTimeStr = getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt());
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13);
var nameWidhth = CustomUI.getRealTextWidht(refName, 13);
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36;
var tempIndex = quoteMsg.content.indexOf(':');
var quoteContent = tempIndex == -1
? quoteMsg.content
: quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2);
var contentWidht = _getTextWidth(quoteContent, fontSize: 13);
width = min(max(width, contentWidht), maxWidth);
showMsg.add(InkWell(
onTap: () {
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt());
},
child: Container(
padding: EdgeInsets.all(8),
margin: EdgeInsets.only(bottom: 5),
decoration: BoxDecoration(
color: Color(0xFFC4E0F5),
borderRadius: BorderRadius.circular(5.5)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Container(
constraints: BoxConstraints(maxWidth: 70),
child: Text(
refName,
style: TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
)),
SizedBox(width: 20),
Text(
showTimeStr,
style: TextStyle(fontSize: 13),
)
]),
SizedBox(height: 7.5),
Text(
quoteContent,
style: TextStyle(fontSize: 13),
)
],
),
)));
var quoteItem = getQuoteItem();
width = getQuoteContentWidth(quoteItem['quoteMsg'], quoteItem['refName'],
quoteItem['showTimeStr'], quoteItem['quoteContent']);
showMsg.add(getQuoteContent(quoteItem['quoteMsg'], quoteItem['refName'],
quoteItem['showTimeStr'], quoteItem['quoteContent'], true));
}
var contentWidth = _getTextWidth(textList[curTextType]);
if (contentWidth > width && contentWidth <= maxWidth) {
@@ -700,7 +750,6 @@ class _ChatPageItemState extends State<ChatPageItem>
List<String> actions = [
I18n.of(context).delete,
I18n.of(context).reply,
];
actionsFunc.add(() {
@@ -711,7 +760,6 @@ class _ChatPageItemState extends State<ChatPageItem>
MessageMgr().emit('Reply Select Message', widget.msg);
});
///转发
if (widget.msg.msgType == ChatType.TextChatType.value ||
widget.msg.msgType == ChatType.ImageChatType.value ||
@@ -753,10 +801,7 @@ class _ChatPageItemState extends State<ChatPageItem>
}
ShareExtend.share(FileCacheMgr.replacePath(path), type);
});
}
if (widget.msg.msgType == ChatType.TextChatType.value) {
@@ -868,58 +913,17 @@ class _ChatPageItemState extends State<ChatPageItem>
isUrl = true;
}
if (msg.refMsgContent != null && msg.refMsgContent.length > 0) {
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(msg.refMsgContent);
var refName = Provider.of<RefNameProvider>(context)
.getGroupRefName(msg.sessionId, quoteMsg.sendUserId);
var msgDate =
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt());
var showTimeStr = getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt());
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13);
var nameWidhth = CustomUI.getRealTextWidht(refName, 13);
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36;
var quoteContent =
quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2);
var contentWidht = _getTextWidth(quoteContent, fontSize: 13);
width = min(max(width, contentWidht), maxWidth);
showMsg.add(InkWell(
onTap: () {
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt());
},
child: Container(
padding: EdgeInsets.all(8),
margin: EdgeInsets.only(bottom: 5),
decoration: BoxDecoration(
color: Color(0xFFC4E0F5),
borderRadius: BorderRadius.circular(5.5)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Container(
constraints: BoxConstraints(maxWidth: 70),
child: Text(
refName,
style: TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
)),
SizedBox(width: 20),
Text(
showTimeStr,
style: TextStyle(fontSize: 13),
)
]),
SizedBox(height: 7.5),
Text(
quoteContent,
style: TextStyle(fontSize: 13),
)
],
),
)));
if (widget.msg.refMsgContent != null &&
widget.msg.refMsgContent.length > 0) {
var quoteItem = getQuoteItem();
width = getQuoteContentWidth(
quoteItem['quoteMsg'],
quoteItem['refName'],
quoteItem['showTimeStr'],
quoteItem['quoteContent']);
showMsg.add(getQuoteContent(quoteItem['quoteMsg'], quoteItem['refName'],
quoteItem['showTimeStr'], quoteItem['quoteContent'], false));
}
var contentWidth = _getTextWidth(textList[curTextType]);
@@ -927,28 +931,15 @@ class _ChatPageItemState extends State<ChatPageItem>
width = contentWidth;
}
showMsg.add(InkWell(
onTap: () {
if (msg.transTag == 1) {
return;
}
if (msg.transTag == 2 || msg.transTag == 3) {
setState(() {
curTextType += 1;
curTextType %= textList.length;
});
return;
}
},
child: Container(
constraints: BoxConstraints(maxWidth: maxWidth, minHeight: 22),
alignment: Alignment.centerLeft,
child: extendedText(
textList[curTextType],
color: isUrl ? Colors.blue : Constants.BlackTextColor,
hideKeyboard: widget.hideKeyboard,
fontSize: FontSize,
))));
showMsg.add(Container(
constraints: BoxConstraints(maxWidth: maxWidth, minHeight: 22),
alignment: Alignment.centerLeft,
child: extendedText(
textList[curTextType],
color: isUrl ? Colors.blue : Constants.BlackTextColor,
hideKeyboard: widget.hideKeyboard,
fontSize: FontSize,
)));
}
var minWidth = width + 20;
@@ -989,11 +980,26 @@ class _ChatPageItemState extends State<ChatPageItem>
: Container()
]);
return text;
return InkWell(
child: text,
onTap: () {
MessageMgr().emit('Keyboard Hide');
if (msg.transTag == 1) {
return;
}
if (msg.transTag == 2 || msg.transTag == 3) {
setState(() {
curTextType += 1;
curTextType %= textList.length;
});
return;
}
},
);
}
_translateItemWidget(int code, String title, Function onTap) {
Color color = onTap == null ? Constants.GreyTextColor : Color(0xFF087FF3);
Color color = onTap == null ? Color(0xFFC5C5C5) : Color(0xFF6A6A6A);
return InkWell(
onTap: onTap,
splashColor: Colors.red,
@@ -1192,7 +1198,6 @@ class _ChatPageItemState extends State<ChatPageItem>
),
),
);
}
_receiveVideo(BuildContext context, List<int> imgData,
@@ -1440,8 +1445,8 @@ class _ChatPageItemState extends State<ChatPageItem>
shape: BoxShape.circle,
color: isShow ? Color(0xFFFF7E00) : Color(0xFFCFCFCF),
),
width: 6,
height: 6,
width: 4,
height: 4,
);
}
@@ -1542,13 +1547,11 @@ class _ChatPageItemState extends State<ChatPageItem>
]);
}
Widget _buildServiceCard(bool isStart, Function callBack) {
String endStr = UserData().isTranslateUser?I18n.of(context).translation_butler_evaluation_tips2:I18n.of(context).translation_butler_evaluation_tips;
String endStr = UserData().isTranslateUser
? I18n.of(context).translation_butler_evaluation_tips2
: I18n.of(context).translation_butler_evaluation_tips;
return Container(
alignment: Alignment.center,
margin: EdgeInsets.all(10),
child: Card(
@@ -1562,52 +1565,53 @@ class _ChatPageItemState extends State<ChatPageItem>
padding: EdgeInsets.only(left: 10, right: 10, top: 15, bottom: 15),
child: Row(
children: <Widget>[
Expanded(child: Container( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
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
: endStr,
textScaleFactor: 1.0,
style: TextStyle(
color: Color(0xFF797979), fontSize: 13),
),
],
),)),
(isStart||UserData().isTranslateUser)
Expanded(
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
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
: endStr,
textScaleFactor: 1.0,
style: TextStyle(color: Color(0xFF797979), fontSize: 13),
),
],
),
)),
(isStart || UserData().isTranslateUser)
? 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);
}),
)),
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);
}),
)),
],
),
),
),
);
}
}

+ 140
- 135
lib/chat/group_chat_item.dart 查看文件

@@ -158,8 +158,8 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
showTimeStr =
DateUtils().getFormartData(timeSamp: sendTime, format: 'HH:mm');
} else {
showTimeStr = DateUtils()
.getFormartData(timeSamp: sendTime, format: 'yyyy/MM/dd HH:mm');
showTimeStr =
DateUtils().getFormartData(timeSamp: sendTime, format: 'MM/dd HH:mm');
}
return showTimeStr;
@@ -278,6 +278,101 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
);
}
double getQuoteContentWidth(QuoteMsg quoteMsg, String refName,
String showTimeStr, String quoteContent) {
double width;
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13);
var nameWidhth = CustomUI.getRealTextWidht(refName, 13);
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 59;
var contentWidht = _getTextWidth(quoteContent, fontSize: 13);
return min(max(width, contentWidht), maxWidth);
}
Widget getQuoteContent(QuoteMsg quoteMsg, String refName, String showTimeStr,
String quoteContent, bool isSend) {
var strColor;
var bgColor;
if (isSend) {
strColor = const Color(0xFF24343C);
bgColor = const Color(0xFFC4E0F5);
} else {
strColor = const Color(0xFF515151);
bgColor = const Color(0xFFEBEBEC);
}
return Container(
padding: EdgeInsets.only(left: 8, bottom: 8),
margin: EdgeInsets.only(bottom: 5, top: 2),
decoration:
BoxDecoration(color: bgColor, borderRadius: BorderRadius.circular(7)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Container(
constraints: BoxConstraints(maxWidth: 70),
child: Text(
refName,
style: TextStyle(fontSize: 13, color: strColor),
overflow: TextOverflow.ellipsis,
)),
SizedBox(width: 10),
Text(
showTimeStr,
style: TextStyle(fontSize: 13, color: strColor),
),
Expanded(child: SizedBox()),
InkWell(
onTap: () {
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt());
},
child: Container(
alignment: Alignment.center,
height: 27,
padding: EdgeInsets.only(
left: 10,
right: 10,
),
child: Icon(
IconData(0xe67e, fontFamily: Constants.IconFontFamily),
size: 13,
color: strColor,
)))
]),
Padding(
padding: EdgeInsets.only(right: 8),
child: Text(
quoteContent,
style: TextStyle(fontSize: 13, color: strColor),
),
),
],
),
);
}
Map getQuoteItem(MsgModel msgModel) {
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(widget.msg.refMsgContent);
var refName = Provider.of<RefNameProvider>(context)
.getGroupRefName(msgModel.sessionId, quoteMsg.sendUserId);
var msgDate =
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt());
var showTimeStr =
getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt());
var tempIndex = quoteMsg.content.indexOf(':');
var quoteContent = tempIndex == -1
? quoteMsg.content
: quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2);
return {
"quoteMsg": quoteMsg,
"refName": refName,
"showTimeStr": showTimeStr,
"quoteContent": quoteContent,
};
}
_textMsg(MsgModel msgModel) {
List<Widget> showMsg = [];
var width = 0.0;
@@ -294,61 +389,12 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
}
if (msgModel.refMsgContent != null && msgModel.refMsgContent.length > 0) {
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(msgModel.refMsgContent);
var refName = Provider.of<RefNameProvider>(context)
.getGroupRefName(msgModel.sessionId, quoteMsg.sendUserId);
var msgDate =
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt());
var showTimeStr =
getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt());
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13);
var nameWidhth = CustomUI.getRealTextWidht(refName, 13);
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36;
var tempIndex = quoteMsg.content.indexOf(':');
var quoteContent = tempIndex == -1
? quoteMsg.content
: quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2);
var contentWidht = _getTextWidth(quoteContent, fontSize: 13);
width = min(max(width, contentWidht), maxWidth);
showMsg.add(InkWell(
onTap: () {
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt());
},
child: Container(
padding: EdgeInsets.all(8),
margin: EdgeInsets.only(bottom: 5),
decoration: BoxDecoration(
color: Color(0xFFC4E0F5),
borderRadius: BorderRadius.circular(5.5)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Container(
constraints: BoxConstraints(maxWidth: 70),
child: Text(
refName,
style: TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
)),
SizedBox(width: 20),
Text(
showTimeStr,
style: TextStyle(fontSize: 13),
)
]),
SizedBox(height: 7.5),
Text(
quoteContent,
style: TextStyle(fontSize: 13),
)
],
),
)));
var quoteItem = getQuoteItem(msgModel);
width = getQuoteContentWidth(quoteItem['quoteMsg'], quoteItem['refName'],
quoteItem['showTimeStr'], quoteItem['quoteContent']);
showMsg.add(getQuoteContent(quoteItem['quoteMsg'], quoteItem['refName'],
quoteItem['showTimeStr'], quoteItem['quoteContent'], true));
}
var contentWidth = _getTextWidth(textList[curTextType]);
if (contentWidth > width && contentWidth <= maxWidth) {
@@ -823,8 +869,8 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
shape: BoxShape.circle,
color: isShow ? Color(0xFFFF7E00) : Color(0xFFCFCFCF),
),
width: 6,
height: 6,
width: 4,
height: 4,
);
}
@@ -838,58 +884,15 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
}
if (msg.refMsgContent != null && msg.refMsgContent.length > 0) {
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(msg.refMsgContent);
var refName = Provider.of<RefNameProvider>(context)
.getGroupRefName(msg.sessionId, quoteMsg.sendUserId);
var msgDate =
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt());
var showTimeStr =
getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt());
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13);
var nameWidhth = CustomUI.getRealTextWidht(refName, 13);
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36;
var quoteContent =
quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2);
var contentWidht = _getTextWidth(quoteContent, fontSize: 13);
width = min(max(width, contentWidht), maxWidth);
showMsg.add(InkWell(
onTap: () {
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt());
},
child: Container(
padding: EdgeInsets.all(8),
margin: EdgeInsets.only(bottom: 5),
decoration: BoxDecoration(
color: Color(0xFFC4E0F5),
borderRadius: BorderRadius.circular(5.5)),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(children: <Widget>[
Container(
constraints: BoxConstraints(maxWidth: 70),
child: Text(
refName,
style: TextStyle(fontSize: 13),
overflow: TextOverflow.ellipsis,
)),
SizedBox(width: 20),
Text(
showTimeStr,
style: TextStyle(fontSize: 13),
)
]),
SizedBox(height: 7.5),
Text(
quoteContent,
style: TextStyle(fontSize: 13),
)
],
),
)));
var quoteItem = getQuoteItem(msg);
width = getQuoteContentWidth(
quoteItem['quoteMsg'],
quoteItem['refName'],
quoteItem['showTimeStr'],
quoteItem['quoteContent']);
showMsg.add(getQuoteContent(quoteItem['quoteMsg'], quoteItem['refName'],
quoteItem['showTimeStr'], quoteItem['quoteContent'], false));
}
var contentWidth = _getTextWidth(textList[curTextType]);
@@ -897,28 +900,15 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
width = contentWidth;
}
showMsg.add(InkWell(
onTap: () {
if (msg.transTag == 1) {
return;
}
if (msg.transTag == 2 || msg.transTag == 3) {
setState(() {
curTextType += 1;
curTextType %= textList.length;
});
return;
}
},
child: Container(
constraints: BoxConstraints(maxWidth: maxWidth, minHeight: 22),
alignment: Alignment.centerLeft,
child: extendedText(
textList[curTextType],
color: isUrl ? Colors.blue : Constants.BlackTextColor,
hideKeyboard: widget.hideKeyboard,
fontSize: FontSize,
))));
showMsg.add(Container(
constraints: BoxConstraints(maxWidth: maxWidth, minHeight: 22),
alignment: Alignment.centerLeft,
child: extendedText(
textList[curTextType],
color: isUrl ? Colors.blue : Constants.BlackTextColor,
hideKeyboard: widget.hideKeyboard,
fontSize: FontSize,
)));
}
var minWidth = width + 20;
@@ -958,7 +948,22 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
: Container()
]);
return text;
return InkWell(
child: text,
onTap: () {
MessageMgr().emit('Keyboard Hide');
if (msg.transTag == 1) {
return;
}
if (msg.transTag == 2 || msg.transTag == 3) {
setState(() {
curTextType += 1;
curTextType %= textList.length;
});
return;
}
},
);
}
//用户评价人工翻译,差评
@@ -971,7 +976,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
}
_translateItemWidget(int code, String title, Function onTap) {
Color color = onTap == null ? Constants.GreyTextColor : Color(0xFF087FF3);
Color color = onTap == null ? Color(0xFFC5C5C5) : Color(0xFF6A6A6A);
return InkWell(
onTap: onTap,
splashColor: Colors.red,


+ 2
- 2
lib/chat/group_chat_view.dart 查看文件

@@ -182,9 +182,9 @@ class _GroupChatPageState extends State<GroupChatPage> {
jumIndex = msgList.length - 1;
}
await controller.scrollToIndex(jumIndex,
preferPosition: AutoScrollPosition.begin);
preferPosition: AutoScrollPosition.middle);
controller.highlight(jumIndex,
highlightDuration: new Duration(milliseconds: 500));
highlightDuration: new Duration(milliseconds: 100));
}
void _sendFile(File file) async {


+ 20
- 13
lib/chat/input_bar.dart 查看文件

@@ -32,10 +32,16 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'emoji_gif_text.dart';
import 'emoji_text.dart';
class AlterPostion {
int start;
int length;
AlterPostion(this.start, this.length);
}
class InputBar extends StatefulWidget {
final Function sendMsg;
final bool isTranslateHK;
InputBar({this.sendMsg,this.isTranslateHK=false});
InputBar({this.sendMsg, this.isTranslateHK = false});
@override
InputBarState createState() => InputBarState();
@@ -63,10 +69,11 @@ class InputBarState extends State<InputBar>
int lastTxtLen = 0;
List<AlterPostion> alterPosition = [];
@override
void initState() {
super.initState();
print('~~~~~~~~~~inputbar initState~~~~~~~~~~~');
pageController = new PageController();
getKeyboardHeight();
@@ -153,7 +160,7 @@ class InputBarState extends State<InputBar>
// SystemChannels.textInput.invokeMethod('TextInput.show');
}
_getRefShortText(){
_getRefShortText() {
if (refMsg == null) {
return null;
}
@@ -713,13 +720,10 @@ class InputBarState extends State<InputBar>
_sendPhotoFile(file);
}
}
} on Exception catch (e) {
print(e.toString());
}
// var photos = await PhotoPicker.pickAsset(
// context: context,
// themeColor: Color(0xFFF0F0F0),
@@ -744,8 +748,9 @@ class InputBarState extends State<InputBar>
friendId = Provider.of<int>(context);
}
ChatChannelType channelType =isGroup ? ChatChannelType.Group : ChatChannelType.Session;
if(widget.isTranslateHK){
ChatChannelType channelType =
isGroup ? ChatChannelType.Group : ChatChannelType.Session;
if (widget.isTranslateHK) {
channelType = ChatChannelType.TransHK;
print('聊天是 TransHK');
}
@@ -793,8 +798,9 @@ class InputBarState extends State<InputBar>
friendId = Provider.of<int>(context);
}
ChatChannelType channelType =isGroup ? ChatChannelType.Group : ChatChannelType.Session;
if(widget.isTranslateHK){
ChatChannelType channelType =
isGroup ? ChatChannelType.Group : ChatChannelType.Session;
if (widget.isTranslateHK) {
channelType = ChatChannelType.TransHK;
print('聊天是 TransHK');
}
@@ -853,8 +859,9 @@ class InputBarState extends State<InputBar>
}
}
ChatChannelType channelType =isGroup ? ChatChannelType.Group : ChatChannelType.Session;
if(widget.isTranslateHK){
ChatChannelType channelType =
isGroup ? ChatChannelType.Group : ChatChannelType.Session;
if (widget.isTranslateHK) {
channelType = ChatChannelType.TransHK;
print('聊天是 TransHK');
}
@@ -865,7 +872,7 @@ class InputBarState extends State<InputBar>
refMsg: refMsg,
refShortTxt: _getRefShortText(),
altUsers: alterUsers,
channelType: channelType);
channelType: channelType);
widget.sendMsg(msg);


+ 16
- 1
lib/data/UserData.dart 查看文件

@@ -1,3 +1,4 @@
import 'dart:async';
import 'dart:convert';
import 'package:amap_location/amap_location.dart';
@@ -5,6 +6,7 @@ import 'package:chat/data/constants.dart';
import 'package:chat/utils/HttpUtil.dart';
import 'package:crclib/crclib.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:vibration/vibration.dart';
import '../models/UserInfo.dart';
@@ -59,13 +61,15 @@ class UserData {
bool stationOpenSwitch = true; //开启电台开关
bool myProgramOpenSwitch = true; //我的节目开关
bool nearbyOpenSwitch = true; //附近的人开关
bool isTranslateUser = false ;
bool isTranslateUser = false;
List contactList = [];
bool isInChina = false;
int homemainIndex = 0;
String currentCity = '';
String deviceLanguageCode;
bool shockNoticSwitch = true; //震动通知
bool isShocking = false; //是否震动中
Map<String, dynamic> toJson() {
Map<String, dynamic> json = new Map<String, dynamic>();
@@ -236,4 +240,15 @@ class UserData {
return 'HoChiMinhCIty';
}
}
shock() {
//有震动通知
if (UserData().shockNoticSwitch && !UserData().isShocking) {
UserData().isShocking = true;
Vibration.vibrate();
Timer.periodic(Duration(seconds: 3), (timer) async {
UserData().isShocking = false;
});
}
}
}

+ 8
- 4
lib/data/chat_data_mgr.dart 查看文件

@@ -91,8 +91,8 @@ class ChatDataMgr {
}
//获取私聊记录
List<MsgModel> getRecord() {
var record = msgRecordMap[MsgHandler.curActiveSession];
List<MsgModel> getRecord({int sessionId}) {
var record = msgRecordMap[sessionId==null?MsgHandler.curActiveSession:sessionId];
if (record == null) {
record = [];
msgRecordMap[MsgHandler.curActiveSession] = record;
@@ -101,8 +101,8 @@ class ChatDataMgr {
}
//获取群聊记录
List<MsgModel> getGroupRecord() {
var record = groupRecordMap[MsgHandler.curActiveSession];
List<MsgModel> getGroupRecord({int sessionId}) {
var record = groupRecordMap[sessionId==null?MsgHandler.curActiveSession:sessionId];
if (record == null) {
record = [];
groupRecordMap[MsgHandler.curActiveSession] = record;
@@ -314,6 +314,10 @@ class ChatDataMgr {
print('数据为空,无法插入');
} else {
record.insert(0, msg);
int after = DateTime.now().millisecondsSinceEpoch-MsgHandler.time;
print('******插入数据 use $after');
print('******record length ${record.length} ${msg.sessionId}');
//record.add(msg);
SqlUtil.insert(msg);


+ 17
- 0
lib/generated/i18n.dart 查看文件

@@ -2531,6 +2531,8 @@ class I18n implements WidgetsLocalizations {
String get splash_tips_content4 => "Unobstructed travel chat";
/// "Worry-free your trip"
String get splash_tips_content5 => "Worry-free your trip";
/// "Vibration notification"
String get shock_notice => "Vibration notification";
}

class _I18n_en_US extends I18n {
@@ -6287,6 +6289,9 @@ class _I18n_vi_VN extends I18n {
/// "无忧你的旅行"
@override
String get splash_tips_content5 => "无忧你的旅行";
/// "震动通知"
@override
String get shock_notice => "震动通知";

@override
TextDirection get textDirection => TextDirection.ltr;
@@ -10039,6 +10044,9 @@ class _I18n_zh_HK extends I18n {
/// "无忧你的旅行"
@override
String get splash_tips_content5 => "无忧你的旅行";
/// "震動通知"
@override
String get shock_notice => "震動通知";

@override
TextDirection get textDirection => TextDirection.ltr;
@@ -13794,6 +13802,9 @@ class _I18n_zh_CN extends _I18n_zh_HK {
/// "无忧你的旅行"
@override
String get splash_tips_content5 => "无忧你的旅行";
/// "震动通知"
@override
String get shock_notice => "震动通知";

@override
TextDirection get textDirection => TextDirection.ltr;
@@ -17549,6 +17560,9 @@ class _I18n_ko_KR extends I18n {
/// "无忧你的旅行"
@override
String get splash_tips_content5 => "无忧你的旅行";
/// "震动通知"
@override
String get shock_notice => "震动通知";

@override
TextDirection get textDirection => TextDirection.ltr;
@@ -21301,6 +21315,9 @@ class _I18n_ja_JP extends I18n {
/// "无忧你的旅行"
@override
String get splash_tips_content5 => "无忧你的旅行";
/// "震动通知"
@override
String get shock_notice => "震动通知";

@override
TextDirection get textDirection => TextDirection.ltr;


+ 15
- 5
lib/home/MessagePushPage.dart 查看文件

@@ -37,6 +37,8 @@ class _MessagePushPageState extends State<MessagePushPage> {
bool womenAgree = false;
//邀请码申请成功
bool codeSucess = false;
//震动通知
bool shockNotic = false;
bool isLoadingFish = false;
@@ -59,6 +61,7 @@ class _MessagePushPageState extends State<MessagePushPage> {
if (resData['code'] == 0) {
privatyMsg = resData['data']['PrivacyChat'] == 1;
newDate = resData['data']['NewBroadcast'] == 1;
shockNotic = resData['data']['VibrationReminder'] == 1;
if (isMan) {
womenAgree = resData['data']['AcceptCheck'] == 1;
codeSucess = resData['data']['ApplySuccess'] == 1;
@@ -110,6 +113,7 @@ class _MessagePushPageState extends State<MessagePushPage> {
data['sign'] = TokenMgr().getSign(data);
data['privacyChat'] = privatyMsg ? 1 : 0;
data['newBroadcast'] = newDate ? 1 : 0;
data['vibrationReminder'] = shockNotic ? 1 : 0;
if (isMan) {
data['acceptCheck'] = womenAgree ? 1 : 0;
data['applySuccess'] = codeSucess ? 1 : 0;
@@ -132,6 +136,7 @@ class _MessagePushPageState extends State<MessagePushPage> {
UserData().acceptCheckSwitch = womenAgree;
UserData().checkPhotoSwitch = watchMyPicture;
UserData().codeSucessSwitch = codeSucess;
UserData().shockNoticSwitch = shockNotic;
}
} catch (e) {}
},
@@ -171,11 +176,11 @@ class _MessagePushPageState extends State<MessagePushPage> {
womenAgree = !womenAgree;
});
}),
// _buildHiddenButtom(I18n.of(context).applied_successfully, codeSucess, () {
// setState(() {
// codeSucess = !codeSucess;
// });
// }),
_buildHiddenButtom(I18n.of(context).shock_notice, shockNotic, () {
setState(() {
shockNotic = !shockNotic;
});
}),
];
List<Widget> women = [
_buildHiddenButtom(I18n.of(context).private_chat2, privatyMsg, () {
@@ -198,6 +203,11 @@ class _MessagePushPageState extends State<MessagePushPage> {
watchMyPicture = !watchMyPicture;
});
}),
_buildHiddenButtom(I18n.of(context).shock_notice, shockNotic, () {
setState(() {
shockNotic = !shockNotic;
});
}),
];
return new ListView(
children: isMan ? man : women,


+ 0
- 3
lib/home/homeMain.dart 查看文件

@@ -1,7 +1,6 @@
import 'dart:async';
import 'package:chat/chat/ChatPage.dart';
import 'package:chat/data/UserData.dart';
import 'package:chat/data/chat_data_mgr.dart';
import 'package:chat/data/constants.dart';
import 'package:chat/data/translate_hk_data_mgr.dart';
import 'package:chat/generated/i18n.dart';
@@ -9,10 +8,8 @@ import 'package:chat/home/SystemEditPage.dart';
import 'package:chat/home/find_page.dart';
import 'package:chat/home/realtimehelper/real_time_helper_page.dart';
import 'package:chat/home/unread_dot_widget.dart';
import 'package:chat/models/ChatMsg.dart';
import 'package:chat/models/UserInfo.dart';
import 'package:chat/models/ref_name_provider.dart';
import 'package:chat/proto/all.pbserver.dart';
import 'package:chat/utils/CustomUI.dart';
import 'package:chat/utils/HttpUtil.dart';
import 'package:chat/utils/MessageMgr.dart';


+ 22
- 17
lib/utils/msgHandler.dart 查看文件

@@ -124,12 +124,12 @@ class MsgHandler {
static createSendMsg(ChatType chatType, content,
{int extra,
int friendId,
String localFile,
MsgModel refMsg,
String refShortTxt,
List<int> altUsers,
ChatChannelType channelType = ChatChannelType.Session}) {
int friendId,
String localFile,
MsgModel refMsg,
String refShortTxt,
List<int> altUsers,
ChatChannelType channelType = ChatChannelType.Session}) {
MsgModel msg;
if (content is String) {
@@ -247,7 +247,7 @@ class MsgHandler {
seq.channelType = ChatChannelType.CSD;
} else {
seq.channelType =
isGroup ? ChatChannelType.Group : ChatChannelType.Session;
isGroup ? ChatChannelType.Group : ChatChannelType.Session;
}
NetWork().sendMsg(ComId.Chat, 5, seq);
@@ -257,7 +257,9 @@ class MsgHandler {
static int mLastClickTime = 0;
static int timeInterval = 2500;
// static int receivedCount=0;
static int time;
static handlerReceiveMsg(PushChat chat) async {
bool isGroup = false;
bool isTranslateHK = false;
if (chat.channelType == ChatChannelType.Group) {
@@ -272,17 +274,19 @@ class MsgHandler {
if (chat.sendUserId == 1) {
//更新消息
print('服务器更新消息');
MsgModel findMsg;
MsgModel findMsg;
int sessionId = chat.targetId;
var msgList;
if (isGroup) {
msgList = ChatDataMgr().getGroupRecord();
msgList = ChatDataMgr().getGroupRecord(sessionId: sessionId);
} else {
msgList = ChatDataMgr().getRecord();
msgList = ChatDataMgr().getRecord(sessionId: sessionId);
}
print('msgList ${msgList.length} ${MsgHandler.curActiveSession}');
for (var i = 0; i < msgList.length; i++) {
var msg = msgList[i];
print('msg.time ${msg.time} 服务器发来消息 ${chat.sendTime.toInt()}');
if (msg.time == chat.sendTime.toInt()) {
findMsg = msg;
}
@@ -417,7 +421,7 @@ class MsgHandler {
var myId = UserData().basicInfo.userId;
TransHKChatNotice notice = TransHKChatNotice.fromBuffer(chat.contentBuff);
BaseUserInfo friendId ;
TranslateHKMgr().isUser = myId== notice.employer.id; ///判断自己是翻译官还是用户
TranslateHKMgr().isUser = myId== notice.employer.id; ///判断自己是翻译官还是用户
if(myId== notice.employer.id){
friendId =notice.inter;
@@ -481,7 +485,8 @@ class MsgHandler {
}
} else {
//聊天消息
time = DateTime.now().millisecondsSinceEpoch;
print('******收到聊天消息 $time');
int sessionId = chat.targetId;
print('sessionId $sessionId');
if (isGroup) {
@@ -999,7 +1004,7 @@ class MsgHandler {
switch (type) {
case 'notice':
///由于极光本地推送点击事件无反应,暂时不走这,由远端推
///由于极光本地推送点击事件无反应,暂时不走这,由远端推
String messageJson = map['message'];
Map messageMap = json.decode(messageJson);
@@ -1133,9 +1138,9 @@ class MsgHandler {
Navigator.pushReplacement(context,
MaterialPageRoute<void>(builder: (BuildContext context) {
return GroupChatPage(
key: Key('GroupChat'), groupInfoModel: groupInfoModel);
}));
return GroupChatPage(
key: Key('GroupChat'), groupInfoModel: groupInfoModel);
}));
} else {
switch (res.errorCode) {
case 3007:


+ 7
- 0
pubspec.lock 查看文件

@@ -1117,6 +1117,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.8"
vibration:
dependency: "direct main"
description:
name: vibration
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.4"
video_player:
dependency: "direct main"
description:


+ 2
- 0
pubspec.yaml 查看文件

@@ -181,6 +181,8 @@ dependencies:
device_info: ^0.4.2+1
#跳转到指定索引
scroll_to_index: any
#震动反馈
vibration: ^1.2.4

dev_dependencies:
flutter_test:


正在加载...
取消
保存