@@ -3,6 +3,7 @@ import 'dart:io'; | |||||
import 'package:chat/home/audio_chat_view.dart'; | import 'package:chat/home/audio_chat_view.dart'; | ||||
import 'package:chat/utils/screen.dart'; | import 'package:chat/utils/screen.dart'; | ||||
import 'package:chat/utils/upload_util.dart'; | import 'package:chat/utils/upload_util.dart'; | ||||
import 'package:chat/utils/white_opacity_anim.dart'; | |||||
import 'package:fixnum/fixnum.dart'; | import 'package:fixnum/fixnum.dart'; | ||||
import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
import 'package:chat/chat/translate_state.dart'; | import 'package:chat/chat/translate_state.dart'; | ||||
@@ -35,9 +36,9 @@ import 'package:dio/dio.dart'; | |||||
import 'package:extended_text/extended_text.dart'; | import 'package:extended_text/extended_text.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:flutter/services.dart'; | |||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; | |||||
import '../r.dart'; | import '../r.dart'; | ||||
import 'ChatPageItem.dart'; | import 'ChatPageItem.dart'; | ||||
import 'input_bar.dart'; | import 'input_bar.dart'; | ||||
@@ -62,7 +63,10 @@ class ChatPage extends StatefulWidget { | |||||
} | } | ||||
class _ChatPageState extends State<ChatPage> { | class _ChatPageState extends State<ChatPage> { | ||||
ScrollController _scrollCtrl = ScrollController(); | |||||
final ItemScrollController itemScrollController = ItemScrollController(); | |||||
final ItemPositionsListener itemPositionListener = | |||||
ItemPositionsListener.create(); | |||||
//ScrollController _scrollCtrl = ScrollController(); | |||||
MessageMgr msgMgr = MessageMgr(); | MessageMgr msgMgr = MessageMgr(); | ||||
@@ -77,6 +81,8 @@ class _ChatPageState extends State<ChatPage> { | |||||
//统计聊天时长 | //统计聊天时长 | ||||
int startTime; | int startTime; | ||||
int jumpTime; | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
var endTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; | var endTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; | ||||
@@ -86,15 +92,36 @@ class _ChatPageState extends State<ChatPage> { | |||||
msgMgr.off('New Chat Message', receiveMsg); | msgMgr.off('New Chat Message', receiveMsg); | ||||
msgMgr.off('Keyboard Hide', dealWithKeyboardHide); | msgMgr.off('Keyboard Hide', dealWithKeyboardHide); | ||||
msgMgr.off('Delete Select Message', _deleteItem); | msgMgr.off('Delete Select Message', _deleteItem); | ||||
msgMgr.off('Jump to Msg', jumpToMsg); | |||||
MsgHandler.curActiveSession = 0; | MsgHandler.curActiveSession = 0; | ||||
SoundUtils().stop(); | SoundUtils().stop(); | ||||
nickNameController.dispose(); | nickNameController.dispose(); | ||||
_scrollCtrl.dispose(); | |||||
super.dispose(); | super.dispose(); | ||||
} | } | ||||
jumpToMsg(time) { | |||||
//var screenItemNums = itemPositionListener.itemPositions.value.length; | |||||
int jumIndex = 0; | |||||
jumpTime = time; | |||||
for (int i = 0; i < msgList.length; i++) { | |||||
if (time == msgList[i].time) { | |||||
jumIndex = i - 1; // - screenItemNums + 2; | |||||
break; | |||||
} | |||||
} | |||||
if (jumIndex < 0) { | |||||
jumIndex = 0; | |||||
} | |||||
if (jumIndex > msgList.length - 1) { | |||||
jumIndex = msgList.length - 1; | |||||
} | |||||
setState(() { | |||||
itemScrollController.scrollTo( | |||||
index: jumIndex, duration: new Duration(microseconds: 1)); | |||||
}); | |||||
} | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
super.initState(); | super.initState(); | ||||
@@ -110,6 +137,7 @@ class _ChatPageState extends State<ChatPage> { | |||||
msgMgr.on('Keyboard Hide', dealWithKeyboardHide); | msgMgr.on('Keyboard Hide', dealWithKeyboardHide); | ||||
msgMgr.on('Send CoinBag', _sendCoin); | msgMgr.on('Send CoinBag', _sendCoin); | ||||
msgMgr.on('Delete Select Message', _deleteItem); | msgMgr.on('Delete Select Message', _deleteItem); | ||||
msgMgr.on('Jump to Msg', jumpToMsg); | |||||
} | } | ||||
void _sendFile(File file) async { | void _sendFile(File file) async { | ||||
@@ -366,7 +394,10 @@ class _ChatPageState extends State<ChatPage> { | |||||
? _buildTranslationButler() | ? _buildTranslationButler() | ||||
: Container(), | : Container(), | ||||
Expanded(child: _buildMessageList()), | Expanded(child: _buildMessageList()), | ||||
InputBar(sendMsg: sendMsg,isTranslateHK: widget.isTranslateButler,), | |||||
InputBar( | |||||
sendMsg: sendMsg, | |||||
isTranslateHK: widget.isTranslateButler, | |||||
), | |||||
], | ], | ||||
))), | ))), | ||||
behavior: HitTestBehavior.translucent, | behavior: HitTestBehavior.translucent, | ||||
@@ -475,7 +506,7 @@ class _ChatPageState extends State<ChatPage> { | |||||
return Container(); | return Container(); | ||||
} | } | ||||
Widget button = Container( | |||||
Widget button = Container( | |||||
key: mykey, | key: mykey, | ||||
color: Colors.blue, | color: Colors.blue, | ||||
width: 60, | width: 60, | ||||
@@ -485,14 +516,13 @@ class _ChatPageState extends State<ChatPage> { | |||||
return GestureDetector( | return GestureDetector( | ||||
onHorizontalDragUpdate: dragEvent, | onHorizontalDragUpdate: dragEvent, | ||||
onVerticalDragUpdate: dragEvent, | onVerticalDragUpdate: dragEvent, | ||||
onTap: (){ | |||||
onTap: () { | |||||
setState(() { | setState(() { | ||||
isShowAudio = !isShowAudio; | isShowAudio = !isShowAudio; | ||||
isShowZoomButton = !isShowZoomButton; | isShowZoomButton = !isShowZoomButton; | ||||
}); | }); | ||||
}, | }, | ||||
child: Container( | child: Container( | ||||
child: Transform.translate( | child: Transform.translate( | ||||
offset: Offset(dx, dy), | offset: Offset(dx, dy), | ||||
child: Align( | child: Align( | ||||
@@ -585,7 +615,6 @@ class _ChatPageState extends State<ChatPage> { | |||||
); | ); | ||||
} | } | ||||
Widget _buildMessageList() { | Widget _buildMessageList() { | ||||
return Container( | return Container( | ||||
alignment: Alignment.topCenter, | alignment: Alignment.topCenter, | ||||
@@ -600,13 +629,15 @@ class _ChatPageState extends State<ChatPage> { | |||||
)) | )) | ||||
: NotificationListener( | : NotificationListener( | ||||
child: Scrollbar( | child: Scrollbar( | ||||
child: ListView.builder( | |||||
reverse: true, | |||||
shrinkWrap: true, | |||||
child: ScrollablePositionedList.builder( | |||||
physics: new ClampingScrollPhysics(), | |||||
itemCount: msgList.length, | itemCount: msgList.length, | ||||
controller: _scrollCtrl, | |||||
padding: EdgeInsets.all(8.0), | |||||
itemBuilder: _buildItem, | itemBuilder: _buildItem, | ||||
itemScrollController: itemScrollController, | |||||
itemPositionsListener: itemPositionListener, | |||||
//padding: EdgeInsets.all(8.0), | |||||
reverse: true, | |||||
hitCallback: hideKeyBoard, | |||||
)), | )), | ||||
onNotification: (notification) { | onNotification: (notification) { | ||||
if (notification is ScrollNotification) { | if (notification is ScrollNotification) { | ||||
@@ -628,7 +659,6 @@ class _ChatPageState extends State<ChatPage> { | |||||
} | } | ||||
sendMsg(MsgModel msg) { | sendMsg(MsgModel msg) { | ||||
// if(widget.isTranslateButler){ ///翻译管家聊天通道 | // if(widget.isTranslateButler){ ///翻译管家聊天通道 | ||||
// msg.channelType = ChatChannelType.TransHK.value; | // msg.channelType = ChatChannelType.TransHK.value; | ||||
// } | // } | ||||
@@ -648,12 +678,8 @@ class _ChatPageState extends State<ChatPage> { | |||||
MsgHandler.sendChatMsg(msg); | MsgHandler.sendChatMsg(msg); | ||||
if (mounted) { | if (mounted) { | ||||
setState(() {}); | setState(() {}); | ||||
if (_scrollCtrl.hasClients) { | |||||
_scrollCtrl.animateTo(0, | |||||
duration: new Duration(milliseconds: 500), curve: Curves.ease); | |||||
} | |||||
itemScrollController.jumpTo(index: 0); | |||||
} | } | ||||
// testBig(msg); | |||||
} | } | ||||
MsgModel msg; | MsgModel msg; | ||||
@@ -677,10 +703,6 @@ class _ChatPageState extends State<ChatPage> { | |||||
void receiveMsg(args) { | void receiveMsg(args) { | ||||
if (mounted) { | if (mounted) { | ||||
setState(() {}); | setState(() {}); | ||||
if (_scrollCtrl.hasClients) { | |||||
_scrollCtrl.animateTo(0, | |||||
duration: new Duration(milliseconds: 500), curve: Curves.ease); | |||||
} | |||||
} | } | ||||
} | } | ||||
@@ -699,11 +721,26 @@ class _ChatPageState extends State<ChatPage> { | |||||
} | } | ||||
MsgModel msg = msgList[index]; | MsgModel msg = msgList[index]; | ||||
return ChatPageItem( | |||||
if (msg.time == jumpTime) { | |||||
return WhiteOpacityAnim( | |||||
key: Key(msg.time.toString()), | key: Key(msg.time.toString()), | ||||
msg: msg, | |||||
hideKeyboard: readOnly, | |||||
friendInfo: friendInfo, | |||||
lastMsgTime: lastMsgTime); | |||||
child: ChatPageItem( | |||||
key: Key(msg.time.toString()), | |||||
msg: msg, | |||||
hideKeyboard: readOnly, | |||||
friendInfo: friendInfo, | |||||
lastMsgTime: lastMsgTime), | |||||
animFinishCallback: () { | |||||
jumpTime = null; | |||||
}, | |||||
); | |||||
} else { | |||||
return ChatPageItem( | |||||
key: Key(msg.time.toString()), | |||||
msg: msg, | |||||
hideKeyboard: readOnly, | |||||
friendInfo: friendInfo, | |||||
lastMsgTime: lastMsgTime); | |||||
} | |||||
} | } | ||||
} | } |
@@ -90,6 +90,8 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
CancelToken _cancelToken = CancelToken(); | CancelToken _cancelToken = CancelToken(); | ||||
bool isLongPressed = false; | bool isLongPressed = false; | ||||
double maxWidth = Screen.width - 140; | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
super.initState(); | super.initState(); | ||||
@@ -146,10 +148,10 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
} | } | ||||
} | } | ||||
getTodayTime(msgDate) { | |||||
getTodayTime(msgDate, {var sendTime}) { | |||||
String showTimeStr; | String showTimeStr; | ||||
var sendTime = widget.msg.time; | |||||
sendTime = sendTime ?? widget.msg.time; | |||||
var today = DateTime.now(); | var today = DateTime.now(); | ||||
//今天 | //今天 | ||||
if (msgDate.year == today.year && | if (msgDate.year == today.year && | ||||
@@ -188,7 +190,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
return Container( | return Container( | ||||
width: Screen.width, | width: Screen.width, | ||||
margin: const EdgeInsets.symmetric(vertical: 10.0), | |||||
margin: const EdgeInsets.symmetric(vertical: 18.0,horizontal: 8), | |||||
child: Column( | child: Column( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
showTime == null | showTime == null | ||||
@@ -259,16 +261,18 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
///todo 翻译管家系统通知消息 | ///todo 翻译管家系统通知消息 | ||||
print('这里应该要有翻译管家'); | 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, () {}); | return _buildServiceCard(true, () {}); | ||||
}else if(res.noticeType==TransHKChatNoticeType.EndChat){ | |||||
} else if (res.noticeType == TransHKChatNoticeType.EndChat) { | |||||
///翻译服务结束 | ///翻译服务结束 | ||||
return _buildServiceCard(false, () {}); | return _buildServiceCard(false, () {}); | ||||
}else{ | |||||
} else { | |||||
return Container(); | return Container(); | ||||
} | } | ||||
// return Container(); | // return Container(); | ||||
@@ -293,8 +297,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
// } | // } | ||||
// } | // } | ||||
} | } | ||||
return Container(); | return Container(); | ||||
} | } | ||||
@@ -313,55 +315,100 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
} | } | ||||
_textMsg(List<int> msgContent) { | _textMsg(List<int> msgContent) { | ||||
List<Widget> showMsg = []; | |||||
var width = 0.0; | |||||
var msg = utf8.decode(msgContent); | var msg = utf8.decode(msgContent); | ||||
bool isUrl =false; | |||||
if(textList[curTextType].contains('http') ){ | |||||
isUrl =true; | |||||
if (msg.contains('[ ')) { | |||||
msg = msg.replaceAll('[ ', '['); | |||||
} | |||||
if (msg.contains(' ]')) { | |||||
msg = msg.replaceAll(' ]', ']'); | |||||
} | |||||
bool isUrl = false; | |||||
if (textList[curTextType].contains('http')) { | |||||
isUrl = true; | |||||
} | |||||
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 contentWidth = _getTextWidth(textList[curTextType]); | |||||
if (contentWidth > width && contentWidth <= maxWidth) { | |||||
width = contentWidth; | |||||
} | } | ||||
Widget text = Container( | |||||
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, | |||||
))); | |||||
return Container( | |||||
constraints: BoxConstraints(maxWidth: Screen.width - 120), | constraints: BoxConstraints(maxWidth: Screen.width - 120), | ||||
child: extendedText( | |||||
msg, | |||||
hideKeyboard: widget.hideKeyboard, | |||||
fontSize: FontSize, | |||||
color: isUrl?Colors.blue:Colors.black, | |||||
), | |||||
width: width + 20, | |||||
child: Column( | |||||
crossAxisAlignment: CrossAxisAlignment.start, children: showMsg), | |||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), | padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
color: isLongPressed ? Colors.grey[300] : SendMsgBg, | color: isLongPressed ? Colors.grey[300] : SendMsgBg, | ||||
border: Border.all(color: Color(0xFFB9CBD7), width: 0.6), | border: Border.all(color: Color(0xFFB9CBD7), width: 0.6), | ||||
borderRadius: BorderRadius.all(Radius.circular(ChatRadius))), | borderRadius: BorderRadius.all(Radius.circular(ChatRadius))), | ||||
); | ); | ||||
if (widget.msg.refMsgContent != null && | |||||
widget.msg.refMsgContent.length > 0) { | |||||
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(widget.msg.refMsgContent); | |||||
return Column( | |||||
mainAxisSize: MainAxisSize.min, | |||||
crossAxisAlignment: CrossAxisAlignment.end, | |||||
children: <Widget>[ | |||||
text, | |||||
SizedBox(height: 2), | |||||
Container( | |||||
constraints: BoxConstraints(maxWidth: Screen.width - 120), | |||||
padding: EdgeInsets.symmetric(vertical: 1, horizontal: 3), | |||||
child: Text( | |||||
quoteMsg.content, | |||||
maxLines: 1, | |||||
textScaleFactor: 1.0, | |||||
overflow: TextOverflow.ellipsis, | |||||
style: TextStyle(fontSize: 12), | |||||
), | |||||
decoration: BoxDecoration( | |||||
color: Colors.grey[300], | |||||
borderRadius: BorderRadius.circular(5)), | |||||
) | |||||
], | |||||
); | |||||
} else { | |||||
return text; | |||||
} | |||||
} | } | ||||
_soundMsg() { | _soundMsg() { | ||||
@@ -504,7 +551,9 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
_imgMsg(List<int> imgData) { | _imgMsg(List<int> imgData) { | ||||
var imgSize = _getImgSize(); | var imgSize = _getImgSize(); | ||||
ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); | |||||
ImageProvider provider = MemoryImage(widget.msg.localFile == null | |||||
? Uint8List.fromList(imgData) | |||||
: File(widget.msg.localFile).readAsBytesSync()); | |||||
return GestureDetector( | return GestureDetector( | ||||
child: ClipRRect( | child: ClipRRect( | ||||
@@ -651,7 +700,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
List<String> actions = [ | List<String> actions = [ | ||||
I18n.of(context).delete, | I18n.of(context).delete, | ||||
I18n.of(context).reply, | I18n.of(context).reply, | ||||
]; | ]; | ||||
actionsFunc.add(() { | actionsFunc.add(() { | ||||
@@ -662,53 +710,48 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
MessageMgr().emit('Reply Select Message', widget.msg); | MessageMgr().emit('Reply Select Message', widget.msg); | ||||
}); | }); | ||||
///转发 | ///转发 | ||||
if (widget.msg.msgType == ChatType.TextChatType.value|| | |||||
widget.msg.msgType == ChatType.ImageChatType.value|| | |||||
widget.msg.msgType == ChatType.ShortVideoChatType.value|| | |||||
widget.msg.msgType == ChatType.PlaceChatType.value|| | |||||
widget.msg.msgType == ChatType.EmoticonType.value|| | |||||
widget.msg.msgType == ChatType.FileChatType.value | |||||
){ | |||||
actions.add( I18n.of(context).forward); | |||||
if (widget.msg.msgType == ChatType.TextChatType.value || | |||||
widget.msg.msgType == ChatType.ImageChatType.value || | |||||
widget.msg.msgType == ChatType.ShortVideoChatType.value || | |||||
widget.msg.msgType == ChatType.PlaceChatType.value || | |||||
widget.msg.msgType == ChatType.EmoticonType.value || | |||||
widget.msg.msgType == ChatType.FileChatType.value) { | |||||
actions.add(I18n.of(context).forward); | |||||
actionsFunc.add(() { | actionsFunc.add(() { | ||||
print('转发消息'); | print('转发消息'); | ||||
if(widget.msg.msgType == ChatType.FileChatType.value && widget.msg.localFile==null){ | |||||
if (widget.msg.msgType == ChatType.FileChatType.value && | |||||
widget.msg.localFile == null) { | |||||
showToast('请先下载文件'); | showToast('请先下载文件'); | ||||
return ; | |||||
return; | |||||
} | } | ||||
AppNavigator.pushForwardPage(context, widget.msg); | AppNavigator.pushForwardPage(context, widget.msg); | ||||
}); | }); | ||||
} | } | ||||
if (widget.msg.msgType == ChatType.FileChatType.value &&widget.msg.localFile!=null) { | |||||
if (widget.msg.msgType == ChatType.FileChatType.value && | |||||
widget.msg.localFile != null) { | |||||
//分享文件 | //分享文件 | ||||
actions.add(I18n.of(context).copy_download_url); | actions.add(I18n.of(context).copy_download_url); | ||||
actionsFunc.add(() async{ | |||||
actionsFunc.add(() async { | |||||
UploadUtil().copyFileUrl(widget.msg, context); | UploadUtil().copyFileUrl(widget.msg, context); | ||||
String path = widget.msg.localFile; | String path = widget.msg.localFile; | ||||
String type='file'; | |||||
if(path.contains('mp4') ||path.contains('mp3')){ | |||||
String type = 'file'; | |||||
if (path.contains('mp4') || path.contains('mp3')) { | |||||
type = 'video'; | type = 'video'; | ||||
}else if(path.contains('png')||path.contains('jpg')||path.contains('jpeg')||path.contains('JPG')||path.contains('PNG')){ | |||||
} else if (path.contains('png') || | |||||
path.contains('jpg') || | |||||
path.contains('jpeg') || | |||||
path.contains('JPG') || | |||||
path.contains('PNG')) { | |||||
type = 'image'; | type = 'image'; | ||||
} | } | ||||
ShareExtend.share(FileCacheMgr.replacePath(path), type); | ShareExtend.share(FileCacheMgr.replacePath(path), type); | ||||
}); | }); | ||||
} | } | ||||
if (widget.msg.msgType == ChatType.TextChatType.value) { | if (widget.msg.msgType == ChatType.TextChatType.value) { | ||||
@@ -736,18 +779,17 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
}); | }); | ||||
} | } | ||||
// String date2 = DateTime.fromMillisecondsSinceEpoch(widget.msg.time).toString(); | // String date2 = DateTime.fromMillisecondsSinceEpoch(widget.msg.time).toString(); | ||||
bool isUrl =false; | |||||
if(widget.msg.msgType==ChatType.TextChatType.value ){ | |||||
if( textList[curTextType].contains('http')){ | |||||
isUrl =true; | |||||
bool isUrl = false; | |||||
if (widget.msg.msgType == ChatType.TextChatType.value) { | |||||
if (textList[curTextType].contains('http')) { | |||||
isUrl = true; | |||||
} | } | ||||
} | } | ||||
return WPopupMenu( | |||||
return WPopupMenu( | |||||
child: item, | child: item, | ||||
actions: actions, | actions: actions, | ||||
onTap: ()async{ | |||||
if(isUrl){ | |||||
onTap: () async { | |||||
if (isUrl) { | |||||
if (await canLaunch(textList[curTextType])) { | if (await canLaunch(textList[curTextType])) { | ||||
launch(textList[curTextType]); | launch(textList[curTextType]); | ||||
} | } | ||||
@@ -784,9 +826,9 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
return extendedText(text, hideKeyboard: widget.hideKeyboard); | return extendedText(text, hideKeyboard: widget.hideKeyboard); | ||||
} | } | ||||
double _getTextWidth(String text) { | |||||
double _getTextWidth(String text, {double fontSize: FontSize}) { | |||||
var tp = TextPainter( | var tp = TextPainter( | ||||
text: TextSpan(style: TextStyle(fontSize: FontSize), text: text), | |||||
text: TextSpan(style: TextStyle(fontSize: fontSize), text: text), | |||||
textAlign: TextAlign.left, | textAlign: TextAlign.left, | ||||
textDirection: TextDirection.ltr, | textDirection: TextDirection.ltr, | ||||
textScaleFactor: 1, | textScaleFactor: 1, | ||||
@@ -813,11 +855,70 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
_receiveText(MsgModel msg) { | _receiveText(MsgModel msg) { | ||||
List<Widget> showMsg = []; | List<Widget> showMsg = []; | ||||
double width = 0.0; | |||||
if (textList.length > 0) { | if (textList.length > 0) { | ||||
bool isUrl = false; | |||||
if (textList[curTextType].contains('http')) { | |||||
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); | |||||
bool isUrl =false; | |||||
if(textList[curTextType].contains('http') ){ | |||||
isUrl =true; | |||||
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 contentWidth = _getTextWidth(textList[curTextType]); | |||||
if (contentWidth > width && contentWidth <= maxWidth) { | |||||
width = contentWidth; | |||||
} | } | ||||
showMsg.add(InkWell( | showMsg.add(InkWell( | ||||
@@ -834,8 +935,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
} | } | ||||
}, | }, | ||||
child: Container( | child: Container( | ||||
constraints: | |||||
BoxConstraints(maxWidth: Screen.width - 140, minHeight: 22), | |||||
constraints: BoxConstraints(maxWidth: maxWidth, minHeight: 22), | |||||
alignment: Alignment.centerLeft, | alignment: Alignment.centerLeft, | ||||
child: extendedText( | child: extendedText( | ||||
textList[curTextType], | textList[curTextType], | ||||
@@ -845,9 +945,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
)))); | )))); | ||||
} | } | ||||
var width = _getTextWidth(textList[curTextType]); | |||||
var minWidth = width; | |||||
var minWidth = width + 20; | |||||
if (msg.transTag != 0) { | if (msg.transTag != 0) { | ||||
minWidth = 200; | minWidth = 200; | ||||
showMsg.add(Padding( | showMsg.add(Padding( | ||||
@@ -857,7 +955,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
showMsg.add(tranWidget); | showMsg.add(tranWidget); | ||||
} | } | ||||
///todo | |||||
Widget text = Stack(children: <Widget>[ | Widget text = Stack(children: <Widget>[ | ||||
Container( | Container( | ||||
width: width + 20, | width: width + 20, | ||||
@@ -871,7 +968,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
color: isLongPressed ? Colors.grey[300] : Colors.white, | color: isLongPressed ? Colors.grey[300] : Colors.white, | ||||
borderRadius: BorderRadius.all(Radius.circular(ChatRadius))), | borderRadius: BorderRadius.all(Radius.circular(ChatRadius))), | ||||
), | ), | ||||
msg.transTag != 1 | |||||
msg.transTag != 1 && msg.transTag != 0 | |||||
? Positioned( | ? Positioned( | ||||
right: 5, | right: 5, | ||||
top: 5, | top: 5, | ||||
@@ -885,34 +982,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
: Container() | : Container() | ||||
]); | ]); | ||||
if (msg.refMsgContent != null && msg.refMsgContent.length > 0) { | |||||
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(msg.refMsgContent); | |||||
return Column( | |||||
mainAxisSize: MainAxisSize.min, | |||||
crossAxisAlignment: CrossAxisAlignment.start, | |||||
children: <Widget>[ | |||||
text, | |||||
SizedBox(height: 2), | |||||
Container( | |||||
constraints: BoxConstraints(maxWidth: Screen.width - 120), | |||||
padding: EdgeInsets.symmetric(vertical: 1, horizontal: 3), | |||||
child: Text( | |||||
quoteMsg.content, | |||||
maxLines: 1, | |||||
textScaleFactor: 1.0, | |||||
overflow: TextOverflow.ellipsis, | |||||
style: TextStyle(fontSize: 12), | |||||
), | |||||
decoration: BoxDecoration( | |||||
color: Colors.grey[300], | |||||
borderRadius: BorderRadius.circular(5)), | |||||
) | |||||
], | |||||
); | |||||
} else { | |||||
return text; | |||||
} | |||||
return text; | |||||
} | } | ||||
_translateItemWidget(int code, String title, Function onTap) { | _translateItemWidget(int code, String title, Function onTap) { | ||||
@@ -950,14 +1020,17 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
if (transTag == 1) { | if (transTag == 1) { | ||||
//机器翻译中 | //机器翻译中 | ||||
userTranslateWidget = _translateItemWidget(0xe670, I18n.of(context).man_retranslate, null); | |||||
userTranslateWidget = | |||||
_translateItemWidget(0xe670, I18n.of(context).man_retranslate, null); | |||||
machineTranslateWidget = | machineTranslateWidget = | ||||
_translateItemWidget(0xe671, I18n.of(context).robotTranslate, null); | _translateItemWidget(0xe671, I18n.of(context).robotTranslate, null); | ||||
} else if (transTag == 2) { | } else if (transTag == 2) { | ||||
//人工翻译中 | //人工翻译中 | ||||
userTranslateWidget = _translateItemWidget(0xe670, I18n.of(context).ManTranslate, null); | |||||
machineTranslateWidget = _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { | |||||
userTranslateWidget = | |||||
_translateItemWidget(0xe670, I18n.of(context).ManTranslate, null); | |||||
machineTranslateWidget = | |||||
_translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { | |||||
setState(() { | setState(() { | ||||
curTextType += 1; | curTextType += 1; | ||||
curTextType %= textList.length; | curTextType %= textList.length; | ||||
@@ -1009,7 +1082,8 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
}); | }); | ||||
} | } | ||||
}); | }); | ||||
machineTranslateWidget = _translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { | |||||
machineTranslateWidget = | |||||
_translateItemWidget(0xe671, I18n.of(context).robot_retranslate, () { | |||||
setState(() { | setState(() { | ||||
curTextType += 1; | curTextType += 1; | ||||
curTextType %= textList.length; | curTextType %= textList.length; | ||||
@@ -1064,7 +1138,8 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
)) | )) | ||||
], | ], | ||||
))); | ))); | ||||
machineTranslateWidget = _translateItemWidget(0xe675, I18n.of(context).see_original, () { | |||||
machineTranslateWidget = | |||||
_translateItemWidget(0xe675, I18n.of(context).see_original, () { | |||||
setState(() { | setState(() { | ||||
curTextType = textList.length - 1; | curTextType = textList.length - 1; | ||||
}); | }); | ||||
@@ -1086,15 +1161,16 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
} | } | ||||
_receiveImg(BuildContext context, List<int> imgData, {String downloadData}) { | _receiveImg(BuildContext context, List<int> imgData, {String downloadData}) { | ||||
ImageProvider provider = MemoryImage(widget.msg.localFile==null?Uint8List.fromList(imgData):File(widget.msg.localFile).readAsBytesSync()); | |||||
ImageProvider provider = MemoryImage(widget.msg.localFile == null | |||||
? Uint8List.fromList(imgData) | |||||
: File(widget.msg.localFile).readAsBytesSync()); | |||||
var imgSize = _getImgSize(); | var imgSize = _getImgSize(); | ||||
return DownloadItem( | return DownloadItem( | ||||
isAutoDown: false, | isAutoDown: false, | ||||
msg: widget.msg, | msg: widget.msg, | ||||
onFinishTap: (){ | |||||
onFinishTap: () { | |||||
widget.hideKeyboard(); | widget.hideKeyboard(); | ||||
showFullImg(context, widget.msg); | showFullImg(context, widget.msg); | ||||
}, | }, | ||||
@@ -1109,7 +1185,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
), | ), | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
_receiveVideo(BuildContext context, List<int> imgData, | _receiveVideo(BuildContext context, List<int> imgData, | ||||
@@ -1459,10 +1534,8 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
]); | ]); | ||||
} | } | ||||
Widget _buildServiceCard(bool isStart, Function callBack) { | Widget _buildServiceCard(bool isStart, Function callBack) { | ||||
return Container( | return Container( | ||||
alignment: Alignment.center, | alignment: Alignment.center, | ||||
margin: EdgeInsets.all(10), | margin: EdgeInsets.all(10), | ||||
child: Card( | child: Card( | ||||
@@ -1500,28 +1573,27 @@ class _ChatPageItemState extends State<ChatPageItem> | |||||
isStart | isStart | ||||
? Container() | ? Container() | ||||
: Expanded( | : 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); | |||||
}), | |||||
)), | |||||
], | ], | ||||
), | ), | ||||
), | ), | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
} | } |
@@ -7,8 +7,6 @@ import 'package:chat/data/constants.dart'; | |||||
import 'package:chat/generated/i18n.dart'; | import 'package:chat/generated/i18n.dart'; | ||||
import 'package:chat/models/ChatMsg.dart'; | import 'package:chat/models/ChatMsg.dart'; | ||||
import 'package:chat/models/UserInfo.dart'; | import 'package:chat/models/UserInfo.dart'; | ||||
import 'package:chat/photo/entity/options.dart'; | |||||
import 'package:chat/photo/photo.dart'; | |||||
import 'package:chat/proto/chat.pb.dart'; | import 'package:chat/proto/chat.pb.dart'; | ||||
import 'package:chat/r.dart'; | import 'package:chat/r.dart'; | ||||
import 'package:chat/utils/CustomUI.dart'; | import 'package:chat/utils/CustomUI.dart'; | ||||
@@ -23,7 +21,6 @@ import 'package:flutter/services.dart'; | |||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||||
import 'package:multi_image_picker/multi_image_picker.dart'; | import 'package:multi_image_picker/multi_image_picker.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:photo_manager/photo_manager.dart'; | |||||
import 'package:chat/utils/MessageMgr.dart'; | import 'package:chat/utils/MessageMgr.dart'; | ||||
class CompanyServerPage extends StatefulWidget { | class CompanyServerPage extends StatefulWidget { | ||||
@@ -36,7 +36,6 @@ import 'package:chat/utils/video_anim.dart'; | |||||
import 'package:dio/dio.dart'; | import 'package:dio/dio.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:path_provider/path_provider.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:chat/utils/HttpUtil.dart'; | import 'package:chat/utils/HttpUtil.dart'; | ||||
@@ -147,10 +146,10 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
} | } | ||||
} | } | ||||
getTodayTime(msgDate) { | |||||
getTodayTime(msgDate, {var sendTime}) { | |||||
String showTimeStr; | String showTimeStr; | ||||
var sendTime = widget.msg.time; | |||||
sendTime = sendTime ?? widget.msg.time; | |||||
var today = DateTime.now(); | var today = DateTime.now(); | ||||
//今天 | //今天 | ||||
if (msgDate.year == today.year && | if (msgDate.year == today.year && | ||||
@@ -189,6 +188,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
return Container( | return Container( | ||||
width: Screen.width, | width: Screen.width, | ||||
color: Colors.white.withOpacity(0), | |||||
margin: const EdgeInsets.symmetric(vertical: 10.0), | margin: const EdgeInsets.symmetric(vertical: 10.0), | ||||
child: Column( | child: Column( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
@@ -301,14 +301,19 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
var msgDate = | var msgDate = | ||||
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt()); | DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt()); | ||||
var showTimeStr = getTodayTime(msgDate); | |||||
var showTimeStr = | |||||
getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt()); | |||||
var timetWidth = _getRealTextWidht(showTimeStr, fontSize: 13); | |||||
var nameWidhth = _getRealTextWidht(refName, fontSize: 13); | |||||
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13); | |||||
var nameWidhth = CustomUI.getRealTextWidht(refName, 13); | |||||
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36; | width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36; | ||||
if (width > maxWidth) { | |||||
width = maxWidth; | |||||
} | |||||
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( | showMsg.add(InkWell( | ||||
onTap: () { | onTap: () { | ||||
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt()); | MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt()); | ||||
@@ -338,7 +343,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
]), | ]), | ||||
SizedBox(height: 7.5), | SizedBox(height: 7.5), | ||||
Text( | Text( | ||||
quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2), | |||||
quoteContent, | |||||
style: TextStyle(fontSize: 13), | style: TextStyle(fontSize: 13), | ||||
) | ) | ||||
], | ], | ||||
@@ -778,17 +783,6 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
selectionEnabled: false, hideKeyboard: widget.hideKeyboard)); | selectionEnabled: false, hideKeyboard: widget.hideKeyboard)); | ||||
} | } | ||||
double _getRealTextWidht(String text, {double fontSize = FontSize}) { | |||||
TextPainter _textPainter = TextPainter( | |||||
maxLines: 2, | |||||
text: TextSpan( | |||||
text: text, | |||||
style: TextStyle(fontSize: fontSize, color: Colors.black)), | |||||
textDirection: TextDirection.ltr) | |||||
..layout(); | |||||
return _textPainter.width; | |||||
} | |||||
double _getTextWidth(String text, {double fontSize = FontSize}) { | double _getTextWidth(String text, {double fontSize = FontSize}) { | ||||
var tp = TextPainter( | var tp = TextPainter( | ||||
text: TextSpan( | text: TextSpan( | ||||
@@ -850,14 +844,16 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
var msgDate = | var msgDate = | ||||
DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt()); | DateTime.fromMillisecondsSinceEpoch(quoteMsg.sendTime.toInt()); | ||||
var showTimeStr = getTodayTime(msgDate); | |||||
var showTimeStr = | |||||
getTodayTime(msgDate, sendTime: quoteMsg.sendTime.toInt()); | |||||
var timetWidth = _getRealTextWidht(showTimeStr, fontSize: 13); | |||||
var nameWidhth = _getRealTextWidht(refName, fontSize: 13); | |||||
var timetWidth = CustomUI.getRealTextWidht(showTimeStr, 13); | |||||
var nameWidhth = CustomUI.getRealTextWidht(refName, 13); | |||||
width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36; | width = timetWidth + (nameWidhth > 70 ? 70 : nameWidhth) + 36; | ||||
if (width > maxWidth) { | |||||
width = maxWidth; | |||||
} | |||||
var quoteContent = | |||||
quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2); | |||||
var contentWidht = _getTextWidth(quoteContent, fontSize: 13); | |||||
width = min(max(width, contentWidht), maxWidth); | |||||
showMsg.add(InkWell( | showMsg.add(InkWell( | ||||
onTap: () { | onTap: () { | ||||
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt()); | MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt()); | ||||
@@ -887,8 +883,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
]), | ]), | ||||
SizedBox(height: 7.5), | SizedBox(height: 7.5), | ||||
Text( | Text( | ||||
quoteMsg.content | |||||
.substring(quoteMsg.content.indexOf(':') + 2), | |||||
quoteContent, | |||||
style: TextStyle(fontSize: 13), | style: TextStyle(fontSize: 13), | ||||
) | ) | ||||
], | ], | ||||
@@ -24,6 +24,7 @@ import 'package:chat/utils/sound_util.dart'; | |||||
import 'package:chat/utils/sp_utils.dart'; | import 'package:chat/utils/sp_utils.dart'; | ||||
import 'package:chat/utils/sql_util.dart'; | import 'package:chat/utils/sql_util.dart'; | ||||
import 'package:chat/utils/upload_util.dart'; | import 'package:chat/utils/upload_util.dart'; | ||||
import 'package:chat/utils/white_opacity_anim.dart'; | |||||
import 'package:extended_text/extended_text.dart'; | import 'package:extended_text/extended_text.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
@@ -75,6 +76,8 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
String alterUserName = ''; | String alterUserName = ''; | ||||
int jumpTime; | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
var endTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; | var endTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; | ||||
@@ -160,11 +163,12 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
} | } | ||||
jumpToMsg(time) { | jumpToMsg(time) { | ||||
var screenItemNums = itemPositionListener.itemPositions.value.length; | |||||
//var screenItemNums = itemPositionListener.itemPositions.value.length; | |||||
jumpTime = time; | |||||
int jumIndex = 0; | int jumIndex = 0; | ||||
for (int i = 0; i < msgList.length; i++) { | for (int i = 0; i < msgList.length; i++) { | ||||
if (time == msgList[i].time) { | if (time == msgList[i].time) { | ||||
jumIndex = i - screenItemNums + 2; | |||||
jumIndex = i - 1; // - screenItemNums + 2; | |||||
break; | break; | ||||
} | } | ||||
} | } | ||||
@@ -174,7 +178,8 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
if (jumIndex > msgList.length - 1) { | if (jumIndex > msgList.length - 1) { | ||||
jumIndex = msgList.length - 1; | jumIndex = msgList.length - 1; | ||||
} | } | ||||
itemScrollController.jumpTo(index: jumIndex); | |||||
itemScrollController.scrollTo( | |||||
index: jumIndex, duration: new Duration(microseconds: 1)); | |||||
} | } | ||||
void _sendFile(File file) async { | void _sendFile(File file) async { | ||||
@@ -516,9 +521,10 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
MsgHandler.insertMsgToDB(msg); | MsgHandler.insertMsgToDB(msg); | ||||
MsgHandler.sendChatMsg(msg); | MsgHandler.sendChatMsg(msg); | ||||
if (mounted) { | if (mounted) { | ||||
setState(() {}); | |||||
setState(() { | |||||
itemScrollController.jumpTo(index: 0); | |||||
}); | |||||
} | } | ||||
itemScrollController.jumpTo(index: 0); | |||||
} | } | ||||
MsgModel msg; | MsgModel msg; | ||||
@@ -564,18 +570,29 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
} | } | ||||
MsgModel msg = msgList[index]; | MsgModel msg = msgList[index]; | ||||
var result; | |||||
if (msg.from == 0) { | if (msg.from == 0) { | ||||
return GroupChatPageItem( | |||||
result = GroupChatPageItem( | |||||
key: Key(msg.time.toString()), msg: msg, lastMsgTime: lastMsgTime); | key: Key(msg.time.toString()), msg: msg, lastMsgTime: lastMsgTime); | ||||
} else { | } else { | ||||
return GroupChatPageItem( | |||||
result = GroupChatPageItem( | |||||
key: Key(msg.time.toString()), | key: Key(msg.time.toString()), | ||||
msg: msg, | msg: msg, | ||||
memberModel: widget.groupInfoModel.getMember(msg.from), | memberModel: widget.groupInfoModel.getMember(msg.from), | ||||
hideKeyboard: readOnly, | hideKeyboard: readOnly, | ||||
lastMsgTime: lastMsgTime); | lastMsgTime: lastMsgTime); | ||||
} | } | ||||
if (msg.time == jumpTime) { | |||||
result = WhiteOpacityAnim( | |||||
key: Key(msg.time.toString()), | |||||
child: result, | |||||
animFinishCallback: () { | |||||
jumpTime = null; | |||||
}, | |||||
); | |||||
} | |||||
return result; | |||||
} | } | ||||
quiteGroup() { | quiteGroup() { | ||||
@@ -2,9 +2,7 @@ import 'dart:convert'; | |||||
import 'dart:io'; | import 'dart:io'; | ||||
import 'dart:typed_data'; | import 'dart:typed_data'; | ||||
import 'package:chat/chat/ChatPageItem.dart'; | |||||
import 'package:chat/chat/keyboard_icon.dart'; | import 'package:chat/chat/keyboard_icon.dart'; | ||||
import 'package:chat/chat/my_extended_text_selection_controls.dart'; | |||||
import 'package:chat/chat/record_view.dart'; | import 'package:chat/chat/record_view.dart'; | ||||
import 'package:chat/chat/util_keyboard.dart'; | import 'package:chat/chat/util_keyboard.dart'; | ||||
import 'package:chat/data/UserData.dart'; | import 'package:chat/data/UserData.dart'; | ||||
@@ -14,8 +12,6 @@ import 'package:chat/home/alter_select_view.dart'; | |||||
import 'package:chat/models/ChatMsg.dart'; | import 'package:chat/models/ChatMsg.dart'; | ||||
import 'package:chat/models/group_info_model.dart'; | import 'package:chat/models/group_info_model.dart'; | ||||
import 'package:chat/models/keyboard_provider.dart'; | import 'package:chat/models/keyboard_provider.dart'; | ||||
import 'package:chat/photo/entity/options.dart'; | |||||
import 'package:chat/photo/photo.dart'; | |||||
import 'package:chat/proto/all.pbserver.dart'; | import 'package:chat/proto/all.pbserver.dart'; | ||||
import 'package:chat/utils/CustomUI.dart'; | import 'package:chat/utils/CustomUI.dart'; | ||||
import 'package:chat/utils/MessageMgr.dart'; | import 'package:chat/utils/MessageMgr.dart'; | ||||
@@ -26,24 +22,21 @@ import 'package:chat/utils/keyboard_utils.dart'; | |||||
import 'package:chat/utils/msgHandler.dart'; | import 'package:chat/utils/msgHandler.dart'; | ||||
import 'package:chat/utils/screen.dart'; | import 'package:chat/utils/screen.dart'; | ||||
import 'package:chat/utils/sound_util.dart'; | import 'package:chat/utils/sound_util.dart'; | ||||
import 'package:extended_text_field/extended_text_field.dart'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:flutter/services.dart'; | import 'package:flutter/services.dart'; | ||||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||||
import 'package:multi_image_picker/multi_image_picker.dart'; | import 'package:multi_image_picker/multi_image_picker.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:photo_manager/photo_manager.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:shared_preferences/shared_preferences.dart'; | import 'package:shared_preferences/shared_preferences.dart'; | ||||
import 'emoji_gif_text.dart'; | import 'emoji_gif_text.dart'; | ||||
import 'emoji_text.dart'; | import 'emoji_text.dart'; | ||||
import 'my_special_text_span_builder.dart'; | |||||
class InputBar extends StatefulWidget { | class InputBar extends StatefulWidget { | ||||
final Function sendMsg; | final Function sendMsg; | ||||
final bool isTranslateHK; | final bool isTranslateHK; | ||||
InputBar({this.sendMsg,this.isTranslateHK=false}); | |||||
InputBar({this.sendMsg, this.isTranslateHK = false}); | |||||
@override | @override | ||||
InputBarState createState() => InputBarState(); | InputBarState createState() => InputBarState(); | ||||
@@ -161,7 +154,7 @@ class InputBarState extends State<InputBar> | |||||
// SystemChannels.textInput.invokeMethod('TextInput.show'); | // SystemChannels.textInput.invokeMethod('TextInput.show'); | ||||
} | } | ||||
_getRefShortText() { | |||||
_getRefShortText(){ | |||||
if (refMsg == null) { | if (refMsg == null) { | ||||
return null; | return null; | ||||
} | } | ||||
@@ -217,11 +210,19 @@ class InputBarState extends State<InputBar> | |||||
break; | break; | ||||
default: | default: | ||||
} | } | ||||
GroupInfoModel groupInfoModel = Provider.of<GroupInfoModel>(context); | |||||
var member = groupInfoModel.getMember(refMsg.from); | |||||
return '${member.refName}: $desc'; | |||||
if (refMsg.channelType == ChatChannelType.Group.value) { | |||||
GroupInfoModel groupInfoModel = Provider.of<GroupInfoModel>(context); | |||||
var member = groupInfoModel.getMember(refMsg.from); | |||||
return '${member.refName}: $desc'; | |||||
//} | |||||
//else if (refMsg.channelType == ChatChannelType.Session.value) { | |||||
// UserInfo info = await HttpUtil().getFriendInfo(refMsg.from); | |||||
// var refName = Provider.of<RefNameProvider>(context) | |||||
// .getRefName(info.userId, info.nickName); | |||||
// return '$refName: $desc'; | |||||
} else { | |||||
return desc; | |||||
} | |||||
} | } | ||||
bool isReceiver = false; | bool isReceiver = false; | ||||
@@ -237,8 +238,7 @@ class InputBarState extends State<InputBar> | |||||
Widget centerWidget; | Widget centerWidget; | ||||
Widget input = Container( | Widget input = Container( | ||||
child: | |||||
TextField( | |||||
child: TextField( | |||||
// textSelectionControls: ExtendedMaterialTextSelectionControls(), | // textSelectionControls: ExtendedMaterialTextSelectionControls(), | ||||
keyboardAppearance: Brightness.light, | keyboardAppearance: Brightness.light, | ||||
onChanged: (String messageText) { | onChanged: (String messageText) { | ||||
@@ -708,17 +708,16 @@ class InputBarState extends State<InputBar> | |||||
for (var i = 0; i < resultList.length; i++) { | for (var i = 0; i < resultList.length; i++) { | ||||
Asset photoEntity = resultList[i]; | Asset photoEntity = resultList[i]; | ||||
ByteData byteData = await photoEntity.getByteData(); | ByteData byteData = await photoEntity.getByteData(); | ||||
File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', byteData.buffer.asInt8List(0)); | |||||
File file = await FileCacheMgr().writeFile( | |||||
'temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', | |||||
byteData.buffer.asInt8List(0)); | |||||
_sendPhotoFile(file); | _sendPhotoFile(file); | ||||
} | } | ||||
} | } | ||||
} on Exception catch (e) { | } on Exception catch (e) { | ||||
print(e.toString()); | |||||
print(e.toString()); | |||||
} | } | ||||
// var photos = await PhotoPicker.pickAsset( | // var photos = await PhotoPicker.pickAsset( | ||||
// context: context, | // context: context, | ||||
// themeColor: Color(0xFFF0F0F0), | // themeColor: Color(0xFFF0F0F0), | ||||
@@ -767,7 +766,7 @@ class InputBarState extends State<InputBar> | |||||
if (imgSize > ImgSizeLimit) { | if (imgSize > ImgSizeLimit) { | ||||
print('图片大于 $ImgSizeLimit,压缩'); | print('图片大于 $ImgSizeLimit,压缩'); | ||||
//发送压缩图 WidgetUtil.getCompressImg(path,quality: 80,percentage: 80); | //发送压缩图 WidgetUtil.getCompressImg(path,quality: 80,percentage: 80); | ||||
sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path ); | |||||
sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path); | |||||
isNeedUpload = true; | isNeedUpload = true; | ||||
} else { | } else { | ||||
sendImg = imgFile.readAsBytesSync(); | sendImg = imgFile.readAsBytesSync(); | ||||
@@ -841,8 +840,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; | channelType = ChatChannelType.TransHK; | ||||
print('聊天是 TransHK'); | print('聊天是 TransHK'); | ||||
} | } | ||||
@@ -3,7 +3,6 @@ import 'package:chat/data/constants.dart'; | |||||
import 'package:chat/generated/i18n.dart'; | import 'package:chat/generated/i18n.dart'; | ||||
import 'package:chat/utils/HttpUtil.dart'; | import 'package:chat/utils/HttpUtil.dart'; | ||||
import 'package:chat/utils/MessageMgr.dart'; | import 'package:chat/utils/MessageMgr.dart'; | ||||
import 'package:chat/utils/msgHandler.dart'; | |||||
import 'package:chat/utils/screen.dart'; | import 'package:chat/utils/screen.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
@@ -1,14 +1,4 @@ | |||||
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{ | class TranslateOrder{ | ||||
@@ -12,8 +12,6 @@ import 'package:chat/home/SelectPage.dart'; | |||||
import 'package:chat/home/VerificationCenter.dart'; | import 'package:chat/home/VerificationCenter.dart'; | ||||
import 'package:chat/home/VipPage.dart'; | import 'package:chat/home/VipPage.dart'; | ||||
import 'package:chat/models/money_change.dart'; | import 'package:chat/models/money_change.dart'; | ||||
import 'package:chat/photo/entity/options.dart'; | |||||
import 'package:chat/photo/photo.dart'; | |||||
import 'package:chat/utils/ChargeMoney.dart'; | import 'package:chat/utils/ChargeMoney.dart'; | ||||
import 'package:chat/utils/CustomUI.dart'; | import 'package:chat/utils/CustomUI.dart'; | ||||
import 'package:chat/utils/HttpUtil.dart'; | import 'package:chat/utils/HttpUtil.dart'; | ||||
@@ -31,7 +29,6 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; | |||||
import 'package:multi_image_picker/multi_image_picker.dart'; | import 'package:multi_image_picker/multi_image_picker.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:photo_manager/photo_manager.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:shared_preferences/shared_preferences.dart'; | import 'package:shared_preferences/shared_preferences.dart'; | ||||
import '../utils/ShadowButton.dart'; | import '../utils/ShadowButton.dart'; | ||||
@@ -6,8 +6,6 @@ import 'package:chat/data/UserData.dart'; | |||||
import 'package:chat/data/WebData.dart'; | import 'package:chat/data/WebData.dart'; | ||||
import 'package:chat/data/constants.dart'; | import 'package:chat/data/constants.dart'; | ||||
import 'package:chat/generated/i18n.dart'; | import 'package:chat/generated/i18n.dart'; | ||||
import 'package:chat/photo/entity/options.dart'; | |||||
import 'package:chat/photo/photo.dart'; | |||||
import 'package:chat/utils/CustomUI.dart'; | import 'package:chat/utils/CustomUI.dart'; | ||||
import 'package:chat/utils/HttpUtil.dart'; | import 'package:chat/utils/HttpUtil.dart'; | ||||
import 'package:chat/utils/PicSwiper.dart'; | import 'package:chat/utils/PicSwiper.dart'; | ||||
@@ -18,7 +16,6 @@ import 'package:flutter/material.dart'; | |||||
import 'package:multi_image_picker/multi_image_picker.dart'; | import 'package:multi_image_picker/multi_image_picker.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:photo_manager/photo_manager.dart'; | |||||
import '../data/UserData.dart'; | import '../data/UserData.dart'; | ||||
import '../utils/TokenMgr.dart'; | import '../utils/TokenMgr.dart'; | ||||
@@ -6,8 +6,6 @@ import 'package:chat/home/rich_title.dart'; | |||||
import 'package:chat/models/money_change.dart'; | import 'package:chat/models/money_change.dart'; | ||||
import 'package:chat/models/ref_name_provider.dart'; | import 'package:chat/models/ref_name_provider.dart'; | ||||
import 'package:chat/models/voucher_change.dart'; | import 'package:chat/models/voucher_change.dart'; | ||||
import 'package:chat/photo/entity/options.dart'; | |||||
import 'package:chat/photo/photo.dart'; | |||||
import 'package:chat/utils/ChargeMoney.dart'; | import 'package:chat/utils/ChargeMoney.dart'; | ||||
import 'package:chat/utils/app_navigator.dart'; | import 'package:chat/utils/app_navigator.dart'; | ||||
import 'package:chat/utils/blacklist_mgr.dart'; | import 'package:chat/utils/blacklist_mgr.dart'; | ||||
@@ -42,7 +40,6 @@ import 'package:image_picker/image_picker.dart'; | |||||
import 'package:multi_image_picker/multi_image_picker.dart'; | import 'package:multi_image_picker/multi_image_picker.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:permission_handler/permission_handler.dart'; | import 'package:permission_handler/permission_handler.dart'; | ||||
import 'package:photo_manager/photo_manager.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import 'package:share/share.dart'; | import 'package:share/share.dart'; | ||||
import '../utils/FullWithButton.dart'; | import '../utils/FullWithButton.dart'; | ||||
@@ -9,7 +9,6 @@ import 'package:chat/home/realtimehelper/real_time_helper_page.dart'; | |||||
import 'package:chat/home/unread_dot_widget.dart'; | import 'package:chat/home/unread_dot_widget.dart'; | ||||
import 'package:chat/models/UserInfo.dart'; | import 'package:chat/models/UserInfo.dart'; | ||||
import 'package:chat/models/ref_name_provider.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/CustomUI.dart'; | ||||
import 'package:chat/utils/HttpUtil.dart'; | import 'package:chat/utils/HttpUtil.dart'; | ||||
import 'package:chat/utils/MessageMgr.dart'; | import 'package:chat/utils/MessageMgr.dart'; | ||||
@@ -34,7 +33,6 @@ import 'package:shared_preferences/shared_preferences.dart'; | |||||
import 'package:chat/utils/my_bottom_navigation_bar.dart' as myBottm; | import 'package:chat/utils/my_bottom_navigation_bar.dart' as myBottm; | ||||
import 'friend_page.dart'; | import 'friend_page.dart'; | ||||
import 'group_chat_page.dart'; | |||||
class NavigationIconView { | class NavigationIconView { | ||||
final BottomNavigationBarItem item; | final BottomNavigationBarItem item; | ||||
@@ -1,36 +1,22 @@ | |||||
import 'dart:async'; | import 'dart:async'; | ||||
import 'package:cached_network_image/cached_network_image.dart'; | |||||
import 'package:chat/chat/ChatPage.dart'; | |||||
import 'package:chat/data/UserData.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/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/group_info_model.dart'; | ||||
import 'package:chat/models/money_change.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/MessageMgr.dart'; | ||||
import 'package:chat/utils/group_member_model.dart'; | |||||
import 'package:chat/utils/msgHandler.dart'; | import 'package:chat/utils/msgHandler.dart'; | ||||
import 'package:chat/utils/screen.dart'; | import 'package:chat/utils/screen.dart'; | ||||
import 'package:chat/utils/sp_utils.dart'; | import 'package:chat/utils/sp_utils.dart'; | ||||
import 'package:flutter/cupertino.dart'; | import 'package:flutter/cupertino.dart'; | ||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:flutter/services.dart'; | import 'package:flutter/services.dart'; | ||||
import 'package:oktoast/oktoast.dart'; | |||||
import 'package:provider/provider.dart'; | import 'package:provider/provider.dart'; | ||||
import '../../data/constants.dart'; | import '../../data/constants.dart'; | ||||
import '../../generated/i18n.dart'; | import '../../generated/i18n.dart'; | ||||
import '../../r.dart'; | import '../../r.dart'; | ||||
import '../../utils/CustomUI.dart'; | import '../../utils/CustomUI.dart'; | ||||
import '../../utils/FullWithButton.dart'; | |||||
import '../../utils/app_navigator.dart'; | |||||
import '../create_group_view.dart'; | |||||
import 'package:chat/utils/PopUpMenu.dart' as myPop; | import 'package:chat/utils/PopUpMenu.dart' as myPop; | ||||
class TranslationButlerPage extends StatefulWidget { | class TranslationButlerPage extends StatefulWidget { | ||||
@@ -29,13 +29,11 @@ class TravelEvaluationPageState extends State<TravelEvaluationPage> { | |||||
@override | @override | ||||
void initState() { | void initState() { | ||||
// TODO: implement initState | |||||
super.initState(); | super.initState(); | ||||
} | } | ||||
@override | @override | ||||
void didChangeDependencies() { | void didChangeDependencies() { | ||||
// TODO: implement didChangeDependencies | |||||
super.didChangeDependencies(); | super.didChangeDependencies(); | ||||
posList = [ | posList = [ | ||||
EvaluationBean(1, I18n.of(context).translation_pos_1), | EvaluationBean(1, I18n.of(context).translation_pos_1), | ||||
@@ -56,7 +54,6 @@ class TravelEvaluationPageState extends State<TravelEvaluationPage> { | |||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
// TODO: implement build | |||||
List<Widget> evaluationWidget = getItem(isGood ? posList : negList); | List<Widget> evaluationWidget = getItem(isGood ? posList : negList); | ||||
@@ -1389,12 +1389,13 @@ class CustomUI { | |||||
I18n.of(context) | I18n.of(context) | ||||
.translation_butler_dialog_start_service, | .translation_butler_dialog_start_service, | ||||
() { | () { | ||||
Navigator.of(context).pop(); | |||||
},onPress: (){ | |||||
MsgHandler.sendReceiveOrder(); | |||||
Navigator.of(context).pop(); | |||||
},), | |||||
Navigator.of(context).pop(); | |||||
}, | |||||
onPress: () { | |||||
MsgHandler.sendReceiveOrder(); | |||||
Navigator.of(context).pop(); | |||||
}, | |||||
), | |||||
) | ) | ||||
], | ], | ||||
), | ), | ||||
@@ -1412,4 +1413,15 @@ class CustomUI { | |||||
child: TravelEvaluationPage(), | child: TravelEvaluationPage(), | ||||
)); | )); | ||||
} | } | ||||
static double getRealTextWidht(String text, double fontSize) { | |||||
TextPainter _textPainter = TextPainter( | |||||
maxLines: 2, | |||||
text: TextSpan( | |||||
text: text, | |||||
style: TextStyle(fontSize: fontSize, color: Colors.black)), | |||||
textDirection: TextDirection.ltr) | |||||
..layout(); | |||||
return _textPainter.width; | |||||
} | |||||
} | } |
@@ -36,7 +36,6 @@ import 'dart:io'; | |||||
import '../data/UserData.dart'; | import '../data/UserData.dart'; | ||||
import '../utils/TokenMgr.dart'; | import '../utils/TokenMgr.dart'; | ||||
import 'package:http_parser/http_parser.dart'; | import 'package:http_parser/http_parser.dart'; | ||||
import 'package:chat/utils/friend_list_mgr.dart'; | |||||
class HttpUtil { | class HttpUtil { | ||||
static HttpUtil _instance; | static HttpUtil _instance; | ||||
@@ -14,7 +14,7 @@ class CountDownButton extends StatefulWidget{ | |||||
@override | @override | ||||
State<StatefulWidget> createState() { | State<StatefulWidget> createState() { | ||||
// TODO: implement createState | |||||
return CountDownButtonState(); | return CountDownButtonState(); | ||||
} | } | ||||
@@ -44,7 +44,6 @@ class CountDownButtonState extends State<CountDownButton> { | |||||
} | } | ||||
@override | @override | ||||
void initState() { | void initState() { | ||||
// TODO: implement initState | |||||
super.initState(); | super.initState(); | ||||
secondsPassed = widget.countDownTime; | secondsPassed = widget.countDownTime; | ||||
timer = Timer.periodic(Duration(seconds: 1), (Timer t){ | timer = Timer.periodic(Duration(seconds: 1), (Timer t){ | ||||
@@ -54,14 +53,12 @@ class CountDownButtonState extends State<CountDownButton> { | |||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
// TODO: implement dispose | |||||
super.dispose(); | super.dispose(); | ||||
timer?.cancel(); | timer?.cancel(); | ||||
} | } | ||||
@override | @override | ||||
Widget build(BuildContext context) { | Widget build(BuildContext context) { | ||||
// TODO: implement build | |||||
// ~/ 取整操作 | // ~/ 取整操作 | ||||
int seconds = secondsPassed % 60; | int seconds = secondsPassed % 60; | ||||
int minutes = secondsPassed ~/ 60; | int minutes = secondsPassed ~/ 60; | ||||
@@ -1,5 +1,4 @@ | |||||
import 'dart:io'; | import 'dart:io'; | ||||
import 'dart:typed_data'; | |||||
import 'package:path/path.dart' as p; | import 'package:path/path.dart' as p; | ||||
import 'package:path_provider/path_provider.dart'; | import 'package:path_provider/path_provider.dart'; | ||||
@@ -5,7 +5,6 @@ import 'dart:ui'; | |||||
import 'package:cached_network_image/cached_network_image.dart'; | import 'package:cached_network_image/cached_network_image.dart'; | ||||
import 'package:chat/data/group_data_mgr.dart'; | import 'package:chat/data/group_data_mgr.dart'; | ||||
import 'package:chat/models/group_info_model.dart'; | import 'package:chat/models/group_info_model.dart'; | ||||
import 'package:chat/utils/screen.dart'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.dart'; | ||||
import 'package:flutter/rendering.dart'; | import 'package:flutter/rendering.dart'; | ||||
import 'package:flutter/widgets.dart'; | import 'package:flutter/widgets.dart'; | ||||
@@ -9,7 +9,6 @@ import 'package:chat/data/group_data_mgr.dart'; | |||||
import 'package:chat/data/translate_hk_data_mgr.dart'; | import 'package:chat/data/translate_hk_data_mgr.dart'; | ||||
import 'package:chat/generated/i18n.dart'; | import 'package:chat/generated/i18n.dart'; | ||||
import 'package:chat/home/IndexPage.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/ChatMsg.dart'; | ||||
import 'package:chat/models/group_info_model.dart'; | import 'package:chat/models/group_info_model.dart'; | ||||
import 'package:chat/proto/all.pbserver.dart'; | import 'package:chat/proto/all.pbserver.dart'; | ||||
@@ -26,7 +25,6 @@ import 'package:flutter/material.dart'; | |||||
import 'package:oktoast/oktoast.dart'; | import 'package:oktoast/oktoast.dart'; | ||||
import 'package:fixnum/fixnum.dart'; | import 'package:fixnum/fixnum.dart'; | ||||
import 'LoadingDialog.dart'; | |||||
import 'MessageMgr.dart'; | import 'MessageMgr.dart'; | ||||
const MaxMsgContentSize = 1024 * 1024 * 3; | const MaxMsgContentSize = 1024 * 1024 * 3; | ||||
@@ -414,7 +412,7 @@ class MsgHandler { | |||||
channelType: ChatChannelType.Group.value); | channelType: ChatChannelType.Group.value); | ||||
} | } | ||||
} | } | ||||
else if(isTranslateHK){ //TODO ddddd | |||||
else if(isTranslateHK){ | |||||
var myId = UserData().basicInfo.userId; | var myId = UserData().basicInfo.userId; | ||||
TransHKChatNotice notice = TransHKChatNotice.fromBuffer(chat.contentBuff); | TransHKChatNotice notice = TransHKChatNotice.fromBuffer(chat.contentBuff); | ||||
BaseUserInfo friendId ; | BaseUserInfo friendId ; | ||||
@@ -1,7 +1,6 @@ | |||||
import 'dart:typed_data'; | import 'dart:typed_data'; | ||||
import 'dart:io'; | import 'dart:io'; | ||||
import 'package:chat/map/location_result.dart'; | import 'package:chat/map/location_result.dart'; | ||||
import 'package:chat/utils/screen.dart'; | |||||
import 'package:flutter/services.dart'; | import 'package:flutter/services.dart'; | ||||
import 'package:flutter_native_image/flutter_native_image.dart'; | import 'package:flutter_native_image/flutter_native_image.dart'; | ||||
//import 'package:flutter_image_compress/flutter_image_compress.dart'; | //import 'package:flutter_image_compress/flutter_image_compress.dart'; | ||||
@@ -0,0 +1,52 @@ | |||||
import 'package:flutter/material.dart'; | |||||
class WhiteOpacityAnim extends StatefulWidget { | |||||
final Widget child; | |||||
final animFinishCallback; | |||||
WhiteOpacityAnim( | |||||
{Key key, @required this.child, @required this.animFinishCallback}); | |||||
@override | |||||
_WhiteOpacityAnimState createState() => _WhiteOpacityAnimState(); | |||||
} | |||||
class _WhiteOpacityAnimState extends State<WhiteOpacityAnim> | |||||
with SingleTickerProviderStateMixin { | |||||
Animation<double> _animation; | |||||
AnimationController _controller; | |||||
@override | |||||
void initState() { | |||||
super.initState(); | |||||
// 启动动画controller | |||||
_controller = new AnimationController( | |||||
duration: Duration(milliseconds: 1000), vsync: this); | |||||
_controller.addStatusListener((AnimationStatus status) { | |||||
setState(() {}); | |||||
if (status == AnimationStatus.completed) { | |||||
widget.animFinishCallback(); | |||||
} | |||||
}); | |||||
_animation = new Tween<double>(begin: 1, end: 0).animate(_controller) | |||||
..addListener(() { | |||||
setState(() {}); | |||||
}); | |||||
_controller.forward(); | |||||
} | |||||
@override | |||||
void dispose() { | |||||
_controller.stop(); | |||||
_controller.dispose(); | |||||
super.dispose(); | |||||
} | |||||
@override | |||||
Widget build(BuildContext context) { | |||||
return Container( | |||||
child: widget.child, | |||||
color: Colors.white.withOpacity(_animation.value), | |||||
); | |||||
} | |||||
} |