@@ -3,6 +3,7 @@ import 'dart:io'; | |||
import 'package:chat/home/audio_chat_view.dart'; | |||
import 'package:chat/utils/screen.dart'; | |||
import 'package:chat/utils/upload_util.dart'; | |||
import 'package:chat/utils/white_opacity_anim.dart'; | |||
import 'package:fixnum/fixnum.dart'; | |||
import 'package:cached_network_image/cached_network_image.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:flutter/cupertino.dart'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:flutter/services.dart'; | |||
import 'package:oktoast/oktoast.dart'; | |||
import 'package:provider/provider.dart'; | |||
import 'package:scrollable_positioned_list/scrollable_positioned_list.dart'; | |||
import '../r.dart'; | |||
import 'ChatPageItem.dart'; | |||
import 'input_bar.dart'; | |||
@@ -62,7 +63,10 @@ class ChatPage extends StatefulWidget { | |||
} | |||
class _ChatPageState extends State<ChatPage> { | |||
ScrollController _scrollCtrl = ScrollController(); | |||
final ItemScrollController itemScrollController = ItemScrollController(); | |||
final ItemPositionsListener itemPositionListener = | |||
ItemPositionsListener.create(); | |||
//ScrollController _scrollCtrl = ScrollController(); | |||
MessageMgr msgMgr = MessageMgr(); | |||
@@ -77,6 +81,8 @@ class _ChatPageState extends State<ChatPage> { | |||
//统计聊天时长 | |||
int startTime; | |||
int jumpTime; | |||
@override | |||
void dispose() { | |||
var endTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; | |||
@@ -86,15 +92,36 @@ class _ChatPageState extends State<ChatPage> { | |||
msgMgr.off('New Chat Message', receiveMsg); | |||
msgMgr.off('Keyboard Hide', dealWithKeyboardHide); | |||
msgMgr.off('Delete Select Message', _deleteItem); | |||
msgMgr.off('Jump to Msg', jumpToMsg); | |||
MsgHandler.curActiveSession = 0; | |||
SoundUtils().stop(); | |||
nickNameController.dispose(); | |||
_scrollCtrl.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 | |||
void initState() { | |||
super.initState(); | |||
@@ -110,6 +137,7 @@ class _ChatPageState extends State<ChatPage> { | |||
msgMgr.on('Keyboard Hide', dealWithKeyboardHide); | |||
msgMgr.on('Send CoinBag', _sendCoin); | |||
msgMgr.on('Delete Select Message', _deleteItem); | |||
msgMgr.on('Jump to Msg', jumpToMsg); | |||
} | |||
void _sendFile(File file) async { | |||
@@ -366,7 +394,10 @@ class _ChatPageState extends State<ChatPage> { | |||
? _buildTranslationButler() | |||
: Container(), | |||
Expanded(child: _buildMessageList()), | |||
InputBar(sendMsg: sendMsg,isTranslateHK: widget.isTranslateButler,), | |||
InputBar( | |||
sendMsg: sendMsg, | |||
isTranslateHK: widget.isTranslateButler, | |||
), | |||
], | |||
))), | |||
behavior: HitTestBehavior.translucent, | |||
@@ -475,7 +506,7 @@ class _ChatPageState extends State<ChatPage> { | |||
return Container(); | |||
} | |||
Widget button = Container( | |||
Widget button = Container( | |||
key: mykey, | |||
color: Colors.blue, | |||
width: 60, | |||
@@ -485,14 +516,13 @@ class _ChatPageState extends State<ChatPage> { | |||
return GestureDetector( | |||
onHorizontalDragUpdate: dragEvent, | |||
onVerticalDragUpdate: dragEvent, | |||
onTap: (){ | |||
onTap: () { | |||
setState(() { | |||
isShowAudio = !isShowAudio; | |||
isShowZoomButton = !isShowZoomButton; | |||
}); | |||
}, | |||
child: Container( | |||
child: Transform.translate( | |||
offset: Offset(dx, dy), | |||
child: Align( | |||
@@ -585,7 +615,6 @@ class _ChatPageState extends State<ChatPage> { | |||
); | |||
} | |||
Widget _buildMessageList() { | |||
return Container( | |||
alignment: Alignment.topCenter, | |||
@@ -600,13 +629,15 @@ class _ChatPageState extends State<ChatPage> { | |||
)) | |||
: NotificationListener( | |||
child: Scrollbar( | |||
child: ListView.builder( | |||
reverse: true, | |||
shrinkWrap: true, | |||
child: ScrollablePositionedList.builder( | |||
physics: new ClampingScrollPhysics(), | |||
itemCount: msgList.length, | |||
controller: _scrollCtrl, | |||
padding: EdgeInsets.all(8.0), | |||
itemBuilder: _buildItem, | |||
itemScrollController: itemScrollController, | |||
itemPositionsListener: itemPositionListener, | |||
//padding: EdgeInsets.all(8.0), | |||
reverse: true, | |||
hitCallback: hideKeyBoard, | |||
)), | |||
onNotification: (notification) { | |||
if (notification is ScrollNotification) { | |||
@@ -628,7 +659,6 @@ class _ChatPageState extends State<ChatPage> { | |||
} | |||
sendMsg(MsgModel msg) { | |||
// if(widget.isTranslateButler){ ///翻译管家聊天通道 | |||
// msg.channelType = ChatChannelType.TransHK.value; | |||
// } | |||
@@ -648,12 +678,8 @@ class _ChatPageState extends State<ChatPage> { | |||
MsgHandler.sendChatMsg(msg); | |||
if (mounted) { | |||
setState(() {}); | |||
if (_scrollCtrl.hasClients) { | |||
_scrollCtrl.animateTo(0, | |||
duration: new Duration(milliseconds: 500), curve: Curves.ease); | |||
} | |||
itemScrollController.jumpTo(index: 0); | |||
} | |||
// testBig(msg); | |||
} | |||
MsgModel msg; | |||
@@ -677,10 +703,6 @@ class _ChatPageState extends State<ChatPage> { | |||
void receiveMsg(args) { | |||
if (mounted) { | |||
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]; | |||
return ChatPageItem( | |||
if (msg.time == jumpTime) { | |||
return WhiteOpacityAnim( | |||
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(); | |||
bool isLongPressed = false; | |||
double maxWidth = Screen.width - 140; | |||
@override | |||
void initState() { | |||
super.initState(); | |||
@@ -146,10 +148,10 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
} | |||
} | |||
getTodayTime(msgDate) { | |||
getTodayTime(msgDate, {var sendTime}) { | |||
String showTimeStr; | |||
var sendTime = widget.msg.time; | |||
sendTime = sendTime ?? widget.msg.time; | |||
var today = DateTime.now(); | |||
//今天 | |||
if (msgDate.year == today.year && | |||
@@ -188,7 +190,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
return Container( | |||
width: Screen.width, | |||
margin: const EdgeInsets.symmetric(vertical: 10.0), | |||
margin: const EdgeInsets.symmetric(vertical: 18.0,horizontal: 8), | |||
child: Column( | |||
children: <Widget>[ | |||
showTime == null | |||
@@ -259,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(); | |||
@@ -293,8 +297,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
// } | |||
// } | |||
} | |||
return Container(); | |||
} | |||
@@ -313,55 +315,100 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
} | |||
_textMsg(List<int> msgContent) { | |||
List<Widget> showMsg = []; | |||
var width = 0.0; | |||
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), | |||
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), | |||
decoration: BoxDecoration( | |||
color: isLongPressed ? Colors.grey[300] : SendMsgBg, | |||
border: Border.all(color: Color(0xFFB9CBD7), width: 0.6), | |||
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() { | |||
@@ -504,7 +551,9 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
_imgMsg(List<int> imgData) { | |||
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( | |||
child: ClipRRect( | |||
@@ -651,7 +700,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
List<String> actions = [ | |||
I18n.of(context).delete, | |||
I18n.of(context).reply, | |||
]; | |||
actionsFunc.add(() { | |||
@@ -662,53 +710,48 @@ 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|| | |||
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(() { | |||
print('转发消息'); | |||
if(widget.msg.msgType == ChatType.FileChatType.value && widget.msg.localFile==null){ | |||
if (widget.msg.msgType == ChatType.FileChatType.value && | |||
widget.msg.localFile == null) { | |||
showToast('请先下载文件'); | |||
return ; | |||
return; | |||
} | |||
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); | |||
actionsFunc.add(() async{ | |||
actionsFunc.add(() async { | |||
UploadUtil().copyFileUrl(widget.msg, context); | |||
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'; | |||
}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'; | |||
} | |||
ShareExtend.share(FileCacheMgr.replacePath(path), type); | |||
}); | |||
} | |||
if (widget.msg.msgType == ChatType.TextChatType.value) { | |||
@@ -736,18 +779,17 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
}); | |||
} | |||
// 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, | |||
actions: actions, | |||
onTap: ()async{ | |||
if(isUrl){ | |||
onTap: () async { | |||
if (isUrl) { | |||
if (await canLaunch(textList[curTextType])) { | |||
launch(textList[curTextType]); | |||
} | |||
@@ -784,9 +826,9 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
return extendedText(text, hideKeyboard: widget.hideKeyboard); | |||
} | |||
double _getTextWidth(String text) { | |||
double _getTextWidth(String text, {double fontSize: FontSize}) { | |||
var tp = TextPainter( | |||
text: TextSpan(style: TextStyle(fontSize: FontSize), text: text), | |||
text: TextSpan(style: TextStyle(fontSize: fontSize), text: text), | |||
textAlign: TextAlign.left, | |||
textDirection: TextDirection.ltr, | |||
textScaleFactor: 1, | |||
@@ -813,11 +855,70 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
_receiveText(MsgModel msg) { | |||
List<Widget> showMsg = []; | |||
double width = 0.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( | |||
@@ -834,8 +935,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
} | |||
}, | |||
child: Container( | |||
constraints: | |||
BoxConstraints(maxWidth: Screen.width - 140, minHeight: 22), | |||
constraints: BoxConstraints(maxWidth: maxWidth, minHeight: 22), | |||
alignment: Alignment.centerLeft, | |||
child: extendedText( | |||
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) { | |||
minWidth = 200; | |||
showMsg.add(Padding( | |||
@@ -857,7 +955,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
showMsg.add(tranWidget); | |||
} | |||
///todo | |||
Widget text = Stack(children: <Widget>[ | |||
Container( | |||
width: width + 20, | |||
@@ -871,7 +968,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
color: isLongPressed ? Colors.grey[300] : Colors.white, | |||
borderRadius: BorderRadius.all(Radius.circular(ChatRadius))), | |||
), | |||
msg.transTag != 1 | |||
msg.transTag != 1 && msg.transTag != 0 | |||
? Positioned( | |||
right: 5, | |||
top: 5, | |||
@@ -885,34 +982,7 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
: 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) { | |||
@@ -950,14 +1020,17 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
if (transTag == 1) { | |||
//机器翻译中 | |||
userTranslateWidget = _translateItemWidget(0xe670, I18n.of(context).man_retranslate, null); | |||
userTranslateWidget = | |||
_translateItemWidget(0xe670, I18n.of(context).man_retranslate, null); | |||
machineTranslateWidget = | |||
_translateItemWidget(0xe671, I18n.of(context).robotTranslate, null); | |||
} 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(() { | |||
curTextType += 1; | |||
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(() { | |||
curTextType += 1; | |||
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(() { | |||
curTextType = textList.length - 1; | |||
}); | |||
@@ -1086,15 +1161,16 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
} | |||
_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(); | |||
return DownloadItem( | |||
isAutoDown: false, | |||
msg: widget.msg, | |||
onFinishTap: (){ | |||
onFinishTap: () { | |||
widget.hideKeyboard(); | |||
showFullImg(context, widget.msg); | |||
}, | |||
@@ -1109,7 +1185,6 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
), | |||
), | |||
); | |||
} | |||
_receiveVideo(BuildContext context, List<int> imgData, | |||
@@ -1459,10 +1534,8 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
]); | |||
} | |||
Widget _buildServiceCard(bool isStart, Function callBack) { | |||
return Container( | |||
alignment: Alignment.center, | |||
margin: EdgeInsets.all(10), | |||
child: Card( | |||
@@ -1500,28 +1573,27 @@ class _ChatPageItemState extends State<ChatPageItem> | |||
isStart | |||
? Container() | |||
: Expanded( | |||
child: Container( | |||
margin: EdgeInsets.only(left: 15), | |||
height: 30, | |||
child: RaisedButton( | |||
color: Color(0xff3875E9), | |||
shape: RoundedRectangleBorder( | |||
borderRadius: | |||
BorderRadius.all(Radius.circular(10))), | |||
child: Text( | |||
I18n.of(context).translation_butler_evaluation, | |||
textScaleFactor: 1.0, | |||
style: TextStyle(color: Colors.white, fontSize: 15), | |||
), | |||
onPressed: () { | |||
CustomUI.buildTranslationEvaluationDialog(context); | |||
}), | |||
)), | |||
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/models/ChatMsg.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/r.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:multi_image_picker/multi_image_picker.dart'; | |||
import 'package:oktoast/oktoast.dart'; | |||
import 'package:photo_manager/photo_manager.dart'; | |||
import 'package:chat/utils/MessageMgr.dart'; | |||
class CompanyServerPage extends StatefulWidget { | |||
@@ -36,7 +36,6 @@ import 'package:chat/utils/video_anim.dart'; | |||
import 'package:dio/dio.dart'; | |||
import 'package:flutter/cupertino.dart'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:path_provider/path_provider.dart'; | |||
import 'package:provider/provider.dart'; | |||
import 'package:oktoast/oktoast.dart'; | |||
import 'package:chat/utils/HttpUtil.dart'; | |||
@@ -147,10 +146,10 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
} | |||
} | |||
getTodayTime(msgDate) { | |||
getTodayTime(msgDate, {var sendTime}) { | |||
String showTimeStr; | |||
var sendTime = widget.msg.time; | |||
sendTime = sendTime ?? widget.msg.time; | |||
var today = DateTime.now(); | |||
//今天 | |||
if (msgDate.year == today.year && | |||
@@ -189,6 +188,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
return Container( | |||
width: Screen.width, | |||
color: Colors.white.withOpacity(0), | |||
margin: const EdgeInsets.symmetric(vertical: 10.0), | |||
child: Column( | |||
children: <Widget>[ | |||
@@ -301,14 +301,19 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
var msgDate = | |||
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; | |||
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( | |||
onTap: () { | |||
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt()); | |||
@@ -338,7 +343,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
]), | |||
SizedBox(height: 7.5), | |||
Text( | |||
quoteMsg.content.substring(quoteMsg.content.indexOf(':') + 2), | |||
quoteContent, | |||
style: TextStyle(fontSize: 13), | |||
) | |||
], | |||
@@ -778,17 +783,6 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
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}) { | |||
var tp = TextPainter( | |||
text: TextSpan( | |||
@@ -850,14 +844,16 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
var msgDate = | |||
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; | |||
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( | |||
onTap: () { | |||
MessageMgr().emit('Jump to Msg', quoteMsg.sendTime.toInt()); | |||
@@ -887,8 +883,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||
]), | |||
SizedBox(height: 7.5), | |||
Text( | |||
quoteMsg.content | |||
.substring(quoteMsg.content.indexOf(':') + 2), | |||
quoteContent, | |||
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/sql_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:flutter/cupertino.dart'; | |||
import 'package:flutter/material.dart'; | |||
@@ -75,6 +76,8 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||
String alterUserName = ''; | |||
int jumpTime; | |||
@override | |||
void dispose() { | |||
var endTime = DateTime.now().millisecondsSinceEpoch ~/ 1000; | |||
@@ -160,11 +163,12 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||
} | |||
jumpToMsg(time) { | |||
var screenItemNums = itemPositionListener.itemPositions.value.length; | |||
//var screenItemNums = itemPositionListener.itemPositions.value.length; | |||
jumpTime = time; | |||
int jumIndex = 0; | |||
for (int i = 0; i < msgList.length; i++) { | |||
if (time == msgList[i].time) { | |||
jumIndex = i - screenItemNums + 2; | |||
jumIndex = i - 1; // - screenItemNums + 2; | |||
break; | |||
} | |||
} | |||
@@ -174,7 +178,8 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||
if (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 { | |||
@@ -516,9 +521,10 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||
MsgHandler.insertMsgToDB(msg); | |||
MsgHandler.sendChatMsg(msg); | |||
if (mounted) { | |||
setState(() {}); | |||
setState(() { | |||
itemScrollController.jumpTo(index: 0); | |||
}); | |||
} | |||
itemScrollController.jumpTo(index: 0); | |||
} | |||
MsgModel msg; | |||
@@ -564,18 +570,29 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||
} | |||
MsgModel msg = msgList[index]; | |||
var result; | |||
if (msg.from == 0) { | |||
return GroupChatPageItem( | |||
result = GroupChatPageItem( | |||
key: Key(msg.time.toString()), msg: msg, lastMsgTime: lastMsgTime); | |||
} else { | |||
return GroupChatPageItem( | |||
result = GroupChatPageItem( | |||
key: Key(msg.time.toString()), | |||
msg: msg, | |||
memberModel: widget.groupInfoModel.getMember(msg.from), | |||
hideKeyboard: readOnly, | |||
lastMsgTime: lastMsgTime); | |||
} | |||
if (msg.time == jumpTime) { | |||
result = WhiteOpacityAnim( | |||
key: Key(msg.time.toString()), | |||
child: result, | |||
animFinishCallback: () { | |||
jumpTime = null; | |||
}, | |||
); | |||
} | |||
return result; | |||
} | |||
quiteGroup() { | |||
@@ -2,9 +2,7 @@ import 'dart:convert'; | |||
import 'dart:io'; | |||
import 'dart:typed_data'; | |||
import 'package:chat/chat/ChatPageItem.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/util_keyboard.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/group_info_model.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/utils/CustomUI.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/screen.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/services.dart'; | |||
import 'package:flutter_screenutil/flutter_screenutil.dart'; | |||
import 'package:multi_image_picker/multi_image_picker.dart'; | |||
import 'package:oktoast/oktoast.dart'; | |||
import 'package:photo_manager/photo_manager.dart'; | |||
import 'package:provider/provider.dart'; | |||
import 'package:shared_preferences/shared_preferences.dart'; | |||
import 'emoji_gif_text.dart'; | |||
import 'emoji_text.dart'; | |||
import 'my_special_text_span_builder.dart'; | |||
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(); | |||
@@ -161,7 +154,7 @@ class InputBarState extends State<InputBar> | |||
// SystemChannels.textInput.invokeMethod('TextInput.show'); | |||
} | |||
_getRefShortText() { | |||
_getRefShortText(){ | |||
if (refMsg == null) { | |||
return null; | |||
} | |||
@@ -217,11 +210,19 @@ class InputBarState extends State<InputBar> | |||
break; | |||
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; | |||
@@ -237,8 +238,7 @@ class InputBarState extends State<InputBar> | |||
Widget centerWidget; | |||
Widget input = Container( | |||
child: | |||
TextField( | |||
child: TextField( | |||
// textSelectionControls: ExtendedMaterialTextSelectionControls(), | |||
keyboardAppearance: Brightness.light, | |||
onChanged: (String messageText) { | |||
@@ -708,17 +708,16 @@ class InputBarState extends State<InputBar> | |||
for (var i = 0; i < resultList.length; i++) { | |||
Asset photoEntity = resultList[i]; | |||
ByteData byteData = await photoEntity.getByteData(); | |||
File file = await FileCacheMgr().writeFile('temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', byteData.buffer.asInt8List(0)); | |||
File file = await FileCacheMgr().writeFile( | |||
'temp-photo-${DateTime.now().millisecondsSinceEpoch}-${photoEntity.name}', | |||
byteData.buffer.asInt8List(0)); | |||
_sendPhotoFile(file); | |||
} | |||
} | |||
} on Exception catch (e) { | |||
print(e.toString()); | |||
print(e.toString()); | |||
} | |||
// var photos = await PhotoPicker.pickAsset( | |||
// context: context, | |||
// themeColor: Color(0xFFF0F0F0), | |||
@@ -767,7 +766,7 @@ class InputBarState extends State<InputBar> | |||
if (imgSize > ImgSizeLimit) { | |||
print('图片大于 $ImgSizeLimit,压缩'); | |||
//发送压缩图 WidgetUtil.getCompressImg(path,quality: 80,percentage: 80); | |||
sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path ); | |||
sendImg = await WidgetUtil.getCompressImg(imgFile.absolute.path); | |||
isNeedUpload = true; | |||
} else { | |||
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; | |||
print('聊天是 TransHK'); | |||
} | |||
@@ -3,7 +3,6 @@ import 'package:chat/data/constants.dart'; | |||
import 'package:chat/generated/i18n.dart'; | |||
import 'package:chat/utils/HttpUtil.dart'; | |||
import 'package:chat/utils/MessageMgr.dart'; | |||
import 'package:chat/utils/msgHandler.dart'; | |||
import 'package:chat/utils/screen.dart'; | |||
import 'package:flutter/material.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{ | |||
@@ -12,8 +12,6 @@ import 'package:chat/home/SelectPage.dart'; | |||
import 'package:chat/home/VerificationCenter.dart'; | |||
import 'package:chat/home/VipPage.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/CustomUI.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:oktoast/oktoast.dart'; | |||
import 'package:photo_manager/photo_manager.dart'; | |||
import 'package:provider/provider.dart'; | |||
import 'package:shared_preferences/shared_preferences.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/constants.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/HttpUtil.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:oktoast/oktoast.dart'; | |||
import 'package:photo_manager/photo_manager.dart'; | |||
import '../data/UserData.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/ref_name_provider.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/app_navigator.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:oktoast/oktoast.dart'; | |||
import 'package:permission_handler/permission_handler.dart'; | |||
import 'package:photo_manager/photo_manager.dart'; | |||
import 'package:provider/provider.dart'; | |||
import 'package:share/share.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/models/UserInfo.dart'; | |||
import 'package:chat/models/ref_name_provider.dart'; | |||
import 'package:chat/proto/transhousekeeper.pb.dart'; | |||
import 'package:chat/utils/CustomUI.dart'; | |||
import 'package:chat/utils/HttpUtil.dart'; | |||
import 'package:chat/utils/MessageMgr.dart'; | |||
@@ -34,7 +33,6 @@ import 'package:shared_preferences/shared_preferences.dart'; | |||
import 'package:chat/utils/my_bottom_navigation_bar.dart' as myBottm; | |||
import 'friend_page.dart'; | |||
import 'group_chat_page.dart'; | |||
class NavigationIconView { | |||
final BottomNavigationBarItem item; | |||
@@ -1,36 +1,22 @@ | |||
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/chat_data_mgr.dart'; | |||
import 'package:chat/data/group_data_mgr.dart'; | |||
import 'package:chat/data/translate_hk_data_mgr.dart'; | |||
import 'package:chat/home/add_friend.dart'; | |||
import 'package:chat/home/group_announcement.dart'; | |||
import 'package:chat/home/group_manage_page.dart'; | |||
import 'package:chat/models/group_info_model.dart'; | |||
import 'package:chat/models/money_change.dart'; | |||
import 'package:chat/models/ref_name_provider.dart'; | |||
import 'package:chat/utils/LoadingDialog.dart'; | |||
import 'package:chat/utils/MessageMgr.dart'; | |||
import 'package:chat/utils/group_member_model.dart'; | |||
import 'package:chat/utils/msgHandler.dart'; | |||
import 'package:chat/utils/screen.dart'; | |||
import 'package:chat/utils/sp_utils.dart'; | |||
import 'package:flutter/cupertino.dart'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:flutter/services.dart'; | |||
import 'package:oktoast/oktoast.dart'; | |||
import 'package:provider/provider.dart'; | |||
import '../../data/constants.dart'; | |||
import '../../generated/i18n.dart'; | |||
import '../../r.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; | |||
class TranslationButlerPage extends StatefulWidget { | |||
@@ -29,13 +29,11 @@ class TravelEvaluationPageState extends State<TravelEvaluationPage> { | |||
@override | |||
void initState() { | |||
// TODO: implement initState | |||
super.initState(); | |||
} | |||
@override | |||
void didChangeDependencies() { | |||
// TODO: implement didChangeDependencies | |||
super.didChangeDependencies(); | |||
posList = [ | |||
EvaluationBean(1, I18n.of(context).translation_pos_1), | |||
@@ -56,7 +54,6 @@ class TravelEvaluationPageState extends State<TravelEvaluationPage> { | |||
@override | |||
Widget build(BuildContext context) { | |||
// TODO: implement build | |||
List<Widget> evaluationWidget = getItem(isGood ? posList : negList); | |||
@@ -1389,12 +1389,13 @@ class CustomUI { | |||
I18n.of(context) | |||
.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(), | |||
)); | |||
} | |||
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 '../utils/TokenMgr.dart'; | |||
import 'package:http_parser/http_parser.dart'; | |||
import 'package:chat/utils/friend_list_mgr.dart'; | |||
class HttpUtil { | |||
static HttpUtil _instance; | |||
@@ -14,7 +14,7 @@ class CountDownButton extends StatefulWidget{ | |||
@override | |||
State<StatefulWidget> createState() { | |||
// TODO: implement createState | |||
return CountDownButtonState(); | |||
} | |||
@@ -44,7 +44,6 @@ class CountDownButtonState extends State<CountDownButton> { | |||
} | |||
@override | |||
void initState() { | |||
// TODO: implement initState | |||
super.initState(); | |||
secondsPassed = widget.countDownTime; | |||
timer = Timer.periodic(Duration(seconds: 1), (Timer t){ | |||
@@ -54,14 +53,12 @@ class CountDownButtonState extends State<CountDownButton> { | |||
@override | |||
void dispose() { | |||
// TODO: implement dispose | |||
super.dispose(); | |||
timer?.cancel(); | |||
} | |||
@override | |||
Widget build(BuildContext context) { | |||
// TODO: implement build | |||
// ~/ 取整操作 | |||
int seconds = secondsPassed % 60; | |||
int minutes = secondsPassed ~/ 60; | |||
@@ -1,5 +1,4 @@ | |||
import 'dart:io'; | |||
import 'dart:typed_data'; | |||
import 'package:path/path.dart' as p; | |||
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:chat/data/group_data_mgr.dart'; | |||
import 'package:chat/models/group_info_model.dart'; | |||
import 'package:chat/utils/screen.dart'; | |||
import 'package:flutter/material.dart'; | |||
import 'package:flutter/rendering.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/generated/i18n.dart'; | |||
import 'package:chat/home/IndexPage.dart'; | |||
import 'package:chat/home/realtimehelper/translation_butler_page.dart'; | |||
import 'package:chat/models/ChatMsg.dart'; | |||
import 'package:chat/models/group_info_model.dart'; | |||
import 'package:chat/proto/all.pbserver.dart'; | |||
@@ -26,7 +25,6 @@ import 'package:flutter/material.dart'; | |||
import 'package:oktoast/oktoast.dart'; | |||
import 'package:fixnum/fixnum.dart'; | |||
import 'LoadingDialog.dart'; | |||
import 'MessageMgr.dart'; | |||
const MaxMsgContentSize = 1024 * 1024 * 3; | |||
@@ -414,7 +412,7 @@ class MsgHandler { | |||
channelType: ChatChannelType.Group.value); | |||
} | |||
} | |||
else if(isTranslateHK){ //TODO ddddd | |||
else if(isTranslateHK){ | |||
var myId = UserData().basicInfo.userId; | |||
TransHKChatNotice notice = TransHKChatNotice.fromBuffer(chat.contentBuff); | |||
BaseUserInfo friendId ; | |||
@@ -1,7 +1,6 @@ | |||
import 'dart:typed_data'; | |||
import 'dart:io'; | |||
import 'package:chat/map/location_result.dart'; | |||
import 'package:chat/utils/screen.dart'; | |||
import 'package:flutter/services.dart'; | |||
import 'package:flutter_native_image/flutter_native_image.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), | |||
); | |||
} | |||
} |