@@ -284,9 +284,9 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
if (msg.contains(' ]')) { | if (msg.contains(' ]')) { | ||||
msg = msg.replaceAll(' ]', ']'); | msg = msg.replaceAll(' ]', ']'); | ||||
} | } | ||||
bool isUrl =false; | |||||
if(textList[curTextType].contains('http') ){ | |||||
isUrl =true; | |||||
bool isUrl = false; | |||||
if (textList[curTextType].contains('http')) { | |||||
isUrl = true; | |||||
} | } | ||||
Widget text = Container( | Widget text = Container( | ||||
constraints: BoxConstraints(maxWidth: Screen.width - 120), | constraints: BoxConstraints(maxWidth: Screen.width - 120), | ||||
@@ -294,7 +294,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
msg, | msg, | ||||
hideKeyboard: widget.hideKeyboard, | hideKeyboard: widget.hideKeyboard, | ||||
fontSize: FontSize, | fontSize: FontSize, | ||||
color: isUrl?Colors.blue:SendMsgText, | |||||
color: isUrl ? Colors.blue : SendMsgText, | |||||
), | ), | ||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), | padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), | ||||
decoration: BoxDecoration( | decoration: BoxDecoration( | ||||
@@ -472,7 +472,9 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
_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( | ||||
@@ -484,7 +486,7 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
width: imgSize.width, | width: imgSize.width, | ||||
child: Image( | child: Image( | ||||
fit: BoxFit.contain, | fit: BoxFit.contain, | ||||
image:provider, | |||||
image: provider, | |||||
), | ), | ||||
)), | )), | ||||
borderRadius: BorderRadius.circular(5), | borderRadius: BorderRadius.circular(5), | ||||
@@ -586,46 +588,46 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
MessageMgr().emit('Delete Select Message', widget.msg); | MessageMgr().emit('Delete 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); | |||||
actionsFunc.add(() async{ | |||||
actions.add(I18n.of(context).copy_download_url); | |||||
actionsFunc.add(() async { | |||||
//如果是文件增加复制下载地址 | //如果是文件增加复制下载地址 | ||||
String path = widget.msg.localFile; | |||||
UploadUtil().copyFileUrl(widget.msg, context); | |||||
String type='file'; | |||||
if(path.contains('mp4') ||path.contains('mp3')){ | |||||
type = 'video'; | |||||
}else if(path.contains('png')||path.contains('jpg')||path.contains('jpeg')||path.contains('JPG')||path.contains('PNG')){ | |||||
type = 'image'; | |||||
} | |||||
ShareExtend.share(FileCacheMgr.replacePath(path), type); | |||||
String path = widget.msg.localFile; | |||||
UploadUtil().copyFileUrl(widget.msg, context); | |||||
String type = 'file'; | |||||
if (path.contains('mp4') || path.contains('mp3')) { | |||||
type = 'video'; | |||||
} else if (path.contains('png') || | |||||
path.contains('jpg') || | |||||
path.contains('jpeg') || | |||||
path.contains('JPG') || | |||||
path.contains('PNG')) { | |||||
type = 'image'; | |||||
} | |||||
ShareExtend.share(FileCacheMgr.replacePath(path), type); | |||||
}); | }); | ||||
} | } | ||||
if (widget.msg.msgType == ChatType.TextChatType.value) { | if (widget.msg.msgType == ChatType.TextChatType.value) { | ||||
@@ -639,8 +641,6 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
}); | }); | ||||
} | } | ||||
if (widget.msg.msgType == ChatType.ShortVoiceChatType.value) { | if (widget.msg.msgType == ChatType.ShortVoiceChatType.value) { | ||||
var soundPlayMode = | var soundPlayMode = | ||||
Provider.of<KeyboardIndexProvider>(context).soundPlayMode; | Provider.of<KeyboardIndexProvider>(context).soundPlayMode; | ||||
@@ -656,23 +656,22 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
} | } | ||||
// 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){ | |||||
if (await canLaunch(textList[curTextType])) { | |||||
launch(textList[curTextType]); | |||||
onTap: () async { | |||||
if (isUrl) { | |||||
if (await canLaunch(textList[curTextType])) { | |||||
launch(textList[curTextType]); | |||||
} | |||||
} | } | ||||
} | |||||
}, | }, | ||||
onLongPressStart: () { | onLongPressStart: () { | ||||
isLongPressed = true; | isLongPressed = true; | ||||
@@ -771,24 +770,33 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
///单文字 | ///单文字 | ||||
} | } | ||||
blueDot(bool isShow) { | |||||
return Container( | |||||
margin: EdgeInsets.only(right: 5), | |||||
decoration: BoxDecoration( | |||||
shape: BoxShape.circle, | |||||
color: isShow ? Color(0xFFFF7E00) : Color(0xFFCFCFCF), | |||||
), | |||||
width: 6, | |||||
height: 6, | |||||
); | |||||
} | |||||
_receiveText(MsgModel msg) { | _receiveText(MsgModel msg) { | ||||
List<Widget> showMsg = []; | List<Widget> showMsg = []; | ||||
if (textList.length > 0) { | if (textList.length > 0) { | ||||
bool isUrl =false; | |||||
if(textList[curTextType].contains('http') ){ | |||||
isUrl =true; | |||||
bool isUrl = false; | |||||
if (textList[curTextType].contains('http')) { | |||||
isUrl = true; | |||||
} | } | ||||
showMsg.add(Container( | showMsg.add(Container( | ||||
constraints: | constraints: | ||||
BoxConstraints(maxWidth: Screen.width - 140, minHeight: 22), | BoxConstraints(maxWidth: Screen.width - 140, minHeight: 22), | ||||
alignment: Alignment.centerLeft, | alignment: Alignment.centerLeft, | ||||
child: extendedText( | child: extendedText( | ||||
textList[curTextType], | textList[curTextType], | ||||
color: isUrl?Colors.blue:Constants.BlackTextColor, | |||||
color: isUrl ? Colors.blue : Constants.BlackTextColor, | |||||
hideKeyboard: widget.hideKeyboard, | hideKeyboard: widget.hideKeyboard, | ||||
fontSize: FontSize, | fontSize: FontSize, | ||||
))); | ))); | ||||
@@ -806,18 +814,32 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
showMsg.add(tranWidget); | showMsg.add(tranWidget); | ||||
} | } | ||||
Widget text = Container( | |||||
width: width + 20, | |||||
constraints: | |||||
BoxConstraints(maxWidth: Screen.width - 120, minWidth: minWidth), | |||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), | |||||
child: Column( | |||||
crossAxisAlignment: CrossAxisAlignment.start, children: showMsg), | |||||
decoration: BoxDecoration( | |||||
border: Border.all(color: ReciveBorderColor, width: 0.5), | |||||
color: isLongPressed ? Colors.grey[300] : Colors.white, | |||||
borderRadius: BorderRadius.all(Radius.circular(ChatRadius))), | |||||
); | |||||
Widget text = Stack(children: <Widget>[ | |||||
Container( | |||||
width: width + 20, | |||||
constraints: | |||||
BoxConstraints(maxWidth: Screen.width - 120, minWidth: minWidth), | |||||
padding: EdgeInsets.symmetric(horizontal: 9, vertical: 10.5), | |||||
child: Column( | |||||
crossAxisAlignment: CrossAxisAlignment.start, children: showMsg), | |||||
decoration: BoxDecoration( | |||||
border: Border.all(color: ReciveBorderColor, width: 0.5), | |||||
color: isLongPressed ? Colors.grey[300] : Colors.white, | |||||
borderRadius: BorderRadius.all(Radius.circular(ChatRadius))), | |||||
), | |||||
// msg.transTag != 0 | |||||
// ? Positioned( | |||||
// right: 5, | |||||
// top: 5, | |||||
// child: Container( | |||||
// child: Row(children: <Widget>[ | |||||
// blueDot(true), | |||||
// blueDot(true), | |||||
// blueDot(true), | |||||
// blueDot(true), | |||||
// ]))) | |||||
// : Container() | |||||
]); | |||||
if (msg.refMsgContent != null && msg.refMsgContent.length > 0) { | if (msg.refMsgContent != null && msg.refMsgContent.length > 0) { | ||||
QuoteMsg quoteMsg = QuoteMsg.fromBuffer(msg.refMsgContent); | QuoteMsg quoteMsg = QuoteMsg.fromBuffer(msg.refMsgContent); | ||||
@@ -1047,14 +1069,16 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
_receiveImg(BuildContext context, List<int> imgData, {String downloadData}) { | _receiveImg(BuildContext context, List<int> imgData, {String downloadData}) { | ||||
// ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); | // ImageProvider provider = MemoryImage(Uint8List.fromList(imgData)); | ||||
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); | ||||
}, | }, | ||||
@@ -1070,7 +1094,6 @@ class _GroupChatPageItemState extends State<GroupChatPageItem> | |||||
), | ), | ||||
), | ), | ||||
); | ); | ||||
} | } | ||||
_receiveVideo(BuildContext context, List<int> imgData, | _receiveVideo(BuildContext context, List<int> imgData, | ||||
@@ -29,6 +29,7 @@ import 'package:flutter/cupertino.dart'; | |||||
import 'package:flutter/material.dart'; | import 'package:flutter/material.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 'input_bar.dart'; | import 'input_bar.dart'; | ||||
import 'package:chat/models/ref_name_provider.dart'; | import 'package:chat/models/ref_name_provider.dart'; | ||||
@@ -48,6 +49,10 @@ class GroupChatPage extends StatefulWidget { | |||||
class _GroupChatPageState extends State<GroupChatPage> { | class _GroupChatPageState extends State<GroupChatPage> { | ||||
ScrollController _scrollCtrl = ScrollController(); | ScrollController _scrollCtrl = ScrollController(); | ||||
final ItemScrollController itemScrollController = ItemScrollController(); | |||||
final ItemPositionsListener itemPositionListener = | |||||
ItemPositionsListener.create(); | |||||
MessageMgr msgMgr = MessageMgr(); | MessageMgr msgMgr = MessageMgr(); | ||||
List<MsgModel> msgList; | List<MsgModel> msgList; | ||||
@@ -113,10 +118,12 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
channelType: ChatChannelType.Group); | channelType: ChatChannelType.Group); | ||||
msg.extraInfo = originMsg.extraInfo; | msg.extraInfo = originMsg.extraInfo; | ||||
// msg.extraFile = originMsg.extraFile; | // msg.extraFile = originMsg.extraFile; | ||||
if(originMsg.extraFile==null ||originMsg.extraFile.contains('http')){ | |||||
if (originMsg.extraFile == null || | |||||
originMsg.extraFile.contains('http')) { | |||||
msg.extraFile = originMsg.extraFile; | msg.extraFile = originMsg.extraFile; | ||||
}else{ | |||||
msg.extraFile = UploadUtil().getFullUrl(originMsg.extraFile, originMsg.sessionId, originMsg.channelType); | |||||
} else { | |||||
msg.extraFile = UploadUtil().getFullUrl( | |||||
originMsg.extraFile, originMsg.sessionId, originMsg.channelType); | |||||
} | } | ||||
msg.localFile = originMsg.localFile; | msg.localFile = originMsg.localFile; | ||||
if (msg.localFile != null) { | if (msg.localFile != null) { | ||||
@@ -126,6 +133,12 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
sendMsg(msg); | sendMsg(msg); | ||||
} | } | ||||
}); | }); | ||||
itemPositionListener.itemPositions.addListener(() { | |||||
print(itemPositionListener.itemPositions.value); | |||||
//itemScrollController.jumpTo(index: 1, alignment: -0.02208835341365462); | |||||
//-0.02208835341365462, itemTrailingEdge: 0.12650602409638553 | |||||
}); | |||||
} | } | ||||
void _sendFile(File file) async { | void _sendFile(File file) async { | ||||
@@ -254,11 +267,33 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
centerTitle: false, | centerTitle: false, | ||||
actions: actions), | actions: actions), | ||||
body: SafeArea( | body: SafeArea( | ||||
child: Column( | |||||
child: Stack( | |||||
children: <Widget>[ | children: <Widget>[ | ||||
NetStateWidget(), | |||||
Expanded(child: _buildMessageList()), | |||||
InputBar(sendMsg: sendMsg), | |||||
Column( | |||||
children: <Widget>[ | |||||
NetStateWidget(), | |||||
Expanded(child: _buildMessageList()), | |||||
InputBar(sendMsg: sendMsg), | |||||
], | |||||
), | |||||
// Positioned( | |||||
// top: 32.5, | |||||
// right: 0, | |||||
// child: Container( | |||||
// decoration: BoxDecoration( | |||||
// boxShadow: [ | |||||
// BoxShadow( | |||||
// color: Color(0x33000000), //阴影颜色 | |||||
// blurRadius: 10.0, //阴影大小 | |||||
// ) | |||||
// ], | |||||
// borderRadius: BorderRadius.only( | |||||
// topLeft: Radius.circular(80), | |||||
// bottomLeft: Radius.circular(80)), | |||||
// color: Colors.white, | |||||
// ), | |||||
// width: 120, | |||||
// height: 39)) | |||||
], | ], | ||||
))), | ))), | ||||
behavior: HitTestBehavior.translucent, | behavior: HitTestBehavior.translucent, | ||||
@@ -295,13 +330,13 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
for (var i = 0; i < msgList.length; i++) { | for (var i = 0; i < msgList.length; i++) { | ||||
MsgModel msg = msgList[i]; | MsgModel msg = msgList[i]; | ||||
double itemHeight = 40; | |||||
double itemHeight = 70; | |||||
switch (ChatType.valueOf(msg.msgType)) { | switch (ChatType.valueOf(msg.msgType)) { | ||||
case ChatType.TextChatType: | case ChatType.TextChatType: | ||||
if (msg.from == myId) { | |||||
var text = utf8.decode(msg.msgContent); | |||||
itemHeight = 21 + _getTextHeight(text); | |||||
} else {} | |||||
//if (msg.from == myId) { | |||||
var text = utf8.decode(msg.msgContent); | |||||
itemHeight = 21 + _getTextHeight(text); | |||||
//} else {} | |||||
break; | break; | ||||
case ChatType.ShortVoiceChatType: | case ChatType.ShortVoiceChatType: | ||||
if (msg.from == myId) { | if (msg.from == myId) { | ||||
@@ -383,14 +418,25 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
style: TextStyle(color: Colors.grey), | style: TextStyle(color: Colors.grey), | ||||
)) | )) | ||||
: Scrollbar( | : Scrollbar( | ||||
child: ListView.builder( | |||||
reverse: true, | |||||
shrinkWrap: true, | |||||
itemCount: msgList.length, | |||||
controller: _scrollCtrl, | |||||
padding: EdgeInsets.all(8.0), | |||||
itemBuilder: _buildItem, | |||||
)), | |||||
child: | |||||
// ScrollablePositionedList.builder( | |||||
// itemCount: msgList.length, | |||||
// itemBuilder: _buildItem, | |||||
// itemScrollController: itemScrollController, | |||||
// itemPositionsListener: itemPositionListener, | |||||
// padding: EdgeInsets.all(8.0), | |||||
// reverse: true, | |||||
// ) | |||||
ListView.builder( | |||||
reverse: true, | |||||
shrinkWrap: true, | |||||
itemCount: msgList.length, | |||||
controller: _scrollCtrl, | |||||
padding: EdgeInsets.all(8.0), | |||||
itemBuilder: _buildItem, | |||||
) | |||||
), | |||||
); | ); | ||||
} | } | ||||
@@ -445,11 +491,13 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
return; | return; | ||||
} | } | ||||
if (mounted) { | if (mounted) { | ||||
setState(() {}); | |||||
if (_scrollCtrl.hasClients) { | |||||
_scrollCtrl.animateTo(0, | |||||
duration: new Duration(milliseconds: 500), curve: Curves.ease); | |||||
} | |||||
setState(() { | |||||
//itemScrollController.jumpTo(index: 3); | |||||
if (_scrollCtrl.hasClients) { | |||||
// _scrollCtrl.animateTo(0, | |||||
// duration: new Duration(milliseconds: 500), curve: Curves.ease); | |||||
} | |||||
}); | |||||
} | } | ||||
} | } | ||||
@@ -463,6 +511,7 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
Widget _buildItem(BuildContext context, int index) { | Widget _buildItem(BuildContext context, int index) { | ||||
var lastMsgTime; | var lastMsgTime; | ||||
if (index < msgList.length - 1) { | if (index < msgList.length - 1) { | ||||
lastMsgTime = msgList[index + 1].time; | lastMsgTime = msgList[index + 1].time; | ||||
} | } | ||||
@@ -538,7 +587,7 @@ class _GroupChatPageState extends State<GroupChatPage> { | |||||
height: 60, | height: 60, | ||||
alignment: Alignment.center, | alignment: Alignment.center, | ||||
child: Text(I18n.of(context).cancel, | child: Text(I18n.of(context).cancel, | ||||
textScaleFactor: 1.0, | |||||
textScaleFactor: 1.0, | |||||
style: TextStyle(fontSize: 18, color: Color(0xff4B4B4B))), | style: TextStyle(fontSize: 18, color: Color(0xff4B4B4B))), | ||||
), | ), | ||||
) | ) | ||||
@@ -652,7 +652,7 @@ class InputBarState extends State<InputBar> | |||||
if (member != null) { | if (member != null) { | ||||
print('选中的成员~~~~~~~~~~~~ ${member.refName}'); | print('选中的成员~~~~~~~~~~~~ ${member.refName}'); | ||||
_textCtrl.text = '${_textCtrl.text}${member.refName} '; | |||||
_textCtrl.text = '${_textCtrl.text}${member.refName} '; | |||||
alterMemberList.add(member); | alterMemberList.add(member); | ||||
} | } | ||||
@@ -4,6 +4,7 @@ import 'package:chat/utils/CustomUI.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:oktoast/oktoast.dart'; | ||||
import 'package:wifi_info_plugin/wifi_info_plugin.dart'; | |||||
import '../utils/ShadowButton.dart'; | import '../utils/ShadowButton.dart'; | ||||
import '../utils/HttpUtil.dart'; | import '../utils/HttpUtil.dart'; | ||||
import 'package:dio/dio.dart'; | import 'package:dio/dio.dart'; | ||||
@@ -24,7 +25,7 @@ class _BindCodePageState extends State<BindCodePage> { | |||||
backgroundColor: AppColors.NewAppbarBgColor, | backgroundColor: AppColors.NewAppbarBgColor, | ||||
title: Text( | title: Text( | ||||
I18n.of(context).bind_code, | I18n.of(context).bind_code, | ||||
style: TextStyle(color:AppColors.NewAppbarTextColor ), | |||||
style: TextStyle(color: AppColors.NewAppbarTextColor), | |||||
textScaleFactor: 1.0, | textScaleFactor: 1.0, | ||||
), | ), | ||||
leading: CustomUI.buildCustomLeading(context), | leading: CustomUI.buildCustomLeading(context), | ||||
@@ -43,11 +44,13 @@ class _BindCodePageState extends State<BindCodePage> { | |||||
resizeToAvoidBottomPadding: false, | resizeToAvoidBottomPadding: false, | ||||
); | ); | ||||
} | } | ||||
@override | @override | ||||
void initState() { | |||||
void initState() { | |||||
super.initState(); | super.initState(); | ||||
print('BindCodePage initState'); | |||||
print('BindCodePage initState'); | |||||
} | } | ||||
@override | @override | ||||
void dispose() { | void dispose() { | ||||
super.dispose(); | super.dispose(); | ||||
@@ -93,7 +96,7 @@ class _BindCodePageState extends State<BindCodePage> { | |||||
), | ), | ||||
Expanded( | Expanded( | ||||
child: TextField( | child: TextField( | ||||
keyboardAppearance: Brightness.light, | |||||
keyboardAppearance: Brightness.light, | |||||
style: | style: | ||||
TextStyle(fontSize: 14, textBaseline: TextBaseline.alphabetic), | TextStyle(fontSize: 14, textBaseline: TextBaseline.alphabetic), | ||||
decoration: new InputDecoration( | decoration: new InputDecoration( | ||||
@@ -139,6 +142,18 @@ class _BindCodePageState extends State<BindCodePage> { | |||||
"agentId": int.parse(_code), | "agentId": int.parse(_code), | ||||
}; | }; | ||||
data['sign'] = TokenMgr().getSign(data); | data['sign'] = TokenMgr().getSign(data); | ||||
data['lng'] = UserData().longitude; | |||||
data['lat'] = UserData().latitude; | |||||
try { | |||||
WifiInfoWrapper wifiObject = await WifiInfoPlugin.wifiDetails; | |||||
if (wifiObject != null) { | |||||
data['routerName'] = wifiObject.ssid; | |||||
data['mac'] = wifiObject.bssId; | |||||
} | |||||
} catch (e) { | |||||
print(e); | |||||
} | |||||
Response res = await HttpUtil() | Response res = await HttpUtil() | ||||
.post('user/bind/agent', data: data, isShowLoading: true); | .post('user/bind/agent', data: data, isShowLoading: true); | ||||
@@ -146,21 +146,33 @@ class _GroupItemState extends State<GroupItem> { | |||||
? Container() | ? Container() | ||||
: Row( | : Row( | ||||
children: <Widget>[ | children: <Widget>[ | ||||
Text( | |||||
widget.groupInfoModel.lastMsg != null && | |||||
widget.groupInfoModel.messageFree == | |||||
1 && | |||||
ChatDataMgr() | |||||
.groupUnreadProvider | |||||
.getUnreadCount(widget | |||||
.groupInfoModel | |||||
.lastMsg | |||||
.sessionId) > | |||||
0 | |||||
? '[${ChatDataMgr().groupUnreadProvider.getUnreadCount(widget.groupInfoModel.lastMsg.sessionId)}${I18n.of(context).article}] ' | |||||
: "", | |||||
textScaleFactor: 1.0, | |||||
style: AppStyles.DescStyle), | |||||
//有人@你就优先展示 | |||||
ChatDataMgr() | |||||
.groupUnreadProvider | |||||
.getHavaAlterme(widget | |||||
.groupInfoModel.lastMsg.sessionId) | |||||
? Text( | |||||
'[有人@我]', | |||||
textScaleFactor: 1.0, | |||||
style: TextStyle( | |||||
color: Colors.red, fontSize: 12), | |||||
) | |||||
: Text( | |||||
widget.groupInfoModel.lastMsg != null && | |||||
widget.groupInfoModel | |||||
.messageFree == | |||||
1 && | |||||
ChatDataMgr() | |||||
.groupUnreadProvider | |||||
.getUnreadCount(widget | |||||
.groupInfoModel | |||||
.lastMsg | |||||
.sessionId) > | |||||
0 | |||||
? '[${ChatDataMgr().groupUnreadProvider.getUnreadCount(widget.groupInfoModel.lastMsg.sessionId)}${I18n.of(context).article}] ' | |||||
: "", | |||||
textScaleFactor: 1.0, | |||||
style: AppStyles.DescStyle), | |||||
Container( | Container( | ||||
constraints: BoxConstraints( | constraints: BoxConstraints( | ||||
maxWidth: Screen.width - 160), | maxWidth: Screen.width - 160), | ||||
@@ -4,6 +4,9 @@ class UnreadCountProvider { | |||||
//未读消息条数管理 | //未读消息条数管理 | ||||
Map<int, int> unreadCountMap = {}; | Map<int, int> unreadCountMap = {}; | ||||
//是否有@我的消息 | |||||
Map<int, bool> isHaveAlterme = {}; | |||||
updateUnreadCount(int sessionId, int count) { | updateUnreadCount(int sessionId, int count) { | ||||
if (unreadCountMap[sessionId] == null) { | if (unreadCountMap[sessionId] == null) { | ||||
unreadCountMap[sessionId] = 0; | unreadCountMap[sessionId] = 0; | ||||
@@ -13,6 +16,14 @@ class UnreadCountProvider { | |||||
MessageMgr().emit('Update UnreadCount', sessionId); | MessageMgr().emit('Update UnreadCount', sessionId); | ||||
} | } | ||||
getHavaAlterme(int sessionId) { | |||||
return isHaveAlterme[sessionId] ?? false; | |||||
} | |||||
setAlterMe(int sessionId){ | |||||
isHaveAlterme[sessionId] = true; | |||||
} | |||||
clear() { | clear() { | ||||
unreadCountMap.clear(); | unreadCountMap.clear(); | ||||
} | } | ||||
@@ -34,6 +45,7 @@ class UnreadCountProvider { | |||||
print('消除未读标记:$sessionId'); | print('消除未读标记:$sessionId'); | ||||
int count = getUnreadCount(sessionId); | int count = getUnreadCount(sessionId); | ||||
isHaveAlterme[sessionId] = false; | |||||
if (count > 0) { | if (count > 0) { | ||||
unreadCountMap[sessionId] = 0; | unreadCountMap[sessionId] = 0; | ||||
@@ -44,9 +44,9 @@ class HttpUtil { | |||||
//static const String BaseUrl = 'http://192.168.0.223:7001/'; | //static const String BaseUrl = 'http://192.168.0.223:7001/'; | ||||
//static const String BaseUrl = 'http://192.168.0.207:9080/'; | //static const String BaseUrl = 'http://192.168.0.207:9080/'; | ||||
// static const String BaseUrl = 'http://120.79.107.63:9080/'; | |||||
static const String BaseUrl = 'http://120.79.107.63:9080/'; | |||||
//static const String BaseUrl = 'http://192.168.0.177:9016/'; | //static const String BaseUrl = 'http://192.168.0.177:9016/'; | ||||
static const String BaseUrl = 'https://datasm.chengyouhd.com/'; | |||||
//static const String BaseUrl = 'https://datasm.chengyouhd.com/'; | |||||
static HttpUtil _getInstance() { | static HttpUtil _getInstance() { | ||||
if (_instance == null) { | if (_instance == null) { | ||||
@@ -241,7 +241,6 @@ class MsgHandler { | |||||
seq.targetId = curActiveSession; | seq.targetId = curActiveSession; | ||||
if (curActiveSession == 10000) { | if (curActiveSession == 10000) { | ||||
seq.channelType = ChatChannelType.CSD; | seq.channelType = ChatChannelType.CSD; | ||||
} else { | } else { | ||||
seq.channelType = | seq.channelType = | ||||
@@ -251,7 +250,7 @@ class MsgHandler { | |||||
NetWork().sendMsg(ComId.Chat, 5, seq); | NetWork().sendMsg(ComId.Chat, 5, seq); | ||||
} | } | ||||
static int tempGroupId=0; | |||||
static int tempGroupId = 0; | |||||
static int mLastClickTime = 0; | static int mLastClickTime = 0; | ||||
static int timeInterval = 2500; | static int timeInterval = 2500; | ||||
// static int receivedCount=0; | // static int receivedCount=0; | ||||
@@ -405,7 +404,8 @@ class MsgHandler { | |||||
chat.contentBuff, chat.sendTime.toInt(), chat.targetId, | chat.contentBuff, chat.sendTime.toInt(), chat.targetId, | ||||
channelType: ChatChannelType.Group.value); | channelType: ChatChannelType.Group.value); | ||||
} | } | ||||
} else {//私聊通知消息 | |||||
} else { | |||||
//私聊通知消息 | |||||
if (chat.cType == ChatType.RedWalletChatType) { | if (chat.cType == ChatType.RedWalletChatType) { | ||||
//系统红包通知消息 | //系统红包通知消息 | ||||
RedWallet wallet = RedWallet.fromBuffer(chat.contentBuff); | RedWallet wallet = RedWallet.fromBuffer(chat.contentBuff); | ||||
@@ -430,13 +430,11 @@ class MsgHandler { | |||||
print('未知私聊通知消息'); | print('未知私聊通知消息'); | ||||
} | } | ||||
} | } | ||||
} else { //聊天消息 | |||||
} else { | |||||
//聊天消息 | |||||
// receivedCount++; | // receivedCount++; | ||||
int sessionId = chat.targetId; | int sessionId = chat.targetId; | ||||
print('sessionId $sessionId'); | print('sessionId $sessionId'); | ||||
if (isGroup) { | if (isGroup) { | ||||
@@ -447,12 +445,12 @@ class MsgHandler { | |||||
if (groupInfo != null) { | if (groupInfo != null) { | ||||
showGroup = groupInfo.messageFree == 0; | showGroup = groupInfo.messageFree == 0; | ||||
} | } | ||||
if (showGroup ) { | |||||
if (showGroup) { | |||||
int nowTime = DateTime.now().millisecondsSinceEpoch; | int nowTime = DateTime.now().millisecondsSinceEpoch; | ||||
if (nowTime - mLastClickTime < timeInterval && tempGroupId==sessionId) { //2秒内同一群不重复弹出 | |||||
if (nowTime - mLastClickTime < timeInterval && | |||||
tempGroupId == sessionId) { | |||||
//2秒内同一群不重复弹出 | |||||
return; | return; | ||||
} | } | ||||
@@ -479,8 +477,6 @@ class MsgHandler { | |||||
// print('当前收到消息条数$receivedCount $content'); | // print('当前收到消息条数$receivedCount $content'); | ||||
// } | // } | ||||
if (chat.hasTencentTranslate()) { | if (chat.hasTencentTranslate()) { | ||||
msgModel.translateContent = chat.tencentTranslate; | msgModel.translateContent = chat.tencentTranslate; | ||||
} | } | ||||
@@ -515,6 +511,7 @@ class MsgHandler { | |||||
for (var i = 0; i < msgModel.altUsers.length; i++) { | for (var i = 0; i < msgModel.altUsers.length; i++) { | ||||
if (msgModel.altUsers[i] == myId) { | if (msgModel.altUsers[i] == myId) { | ||||
print('有人@了你'); | print('有人@了你'); | ||||
ChatDataMgr().groupUnreadProvider.setAlterMe(sessionId); | |||||
//to do | //to do | ||||
} | } | ||||
} | } | ||||
@@ -558,11 +555,10 @@ class MsgHandler { | |||||
} | } | ||||
} | } | ||||
if (msgModel.sessionId == 10000 ) { | |||||
print('收到反馈小助手消息'); | |||||
} | |||||
if (msgModel.sessionId == 10000) { | |||||
print('收到反馈小助手消息'); | |||||
} | |||||
if (msgModel.sessionId == curActiveSession) { | if (msgModel.sessionId == curActiveSession) { | ||||
MessageMgr().emit('New Chat Message', msgModel.sessionId); | MessageMgr().emit('New Chat Message', msgModel.sessionId); | ||||
} | } | ||||
} | } | ||||
@@ -595,7 +591,6 @@ class MsgHandler { | |||||
switch (notice.changeType) { | switch (notice.changeType) { | ||||
case GroupChangeType.AddMember: | case GroupChangeType.AddMember: | ||||
if (optId.id == myId) { | if (optId.id == myId) { | ||||
var otherNames = ''; | var otherNames = ''; | ||||
for (var i = 0; i < optedIds.length; i++) { | for (var i = 0; i < optedIds.length; i++) { | ||||
@@ -915,21 +910,19 @@ class MsgHandler { | |||||
handlerAgreeMember(content); | handlerAgreeMember(content); | ||||
} else if (msgId == 228) { | } else if (msgId == 228) { | ||||
handlerUpdateMemberMsgFree(content); | handlerUpdateMemberMsgFree(content); | ||||
}else if (msgId == 230) { | |||||
} else if (msgId == 230) { | |||||
handlerGroupIsShowMenberNiceName(content); | handlerGroupIsShowMenberNiceName(content); | ||||
} | } | ||||
break; | break; | ||||
case ComId.TranslateOrder: | case ComId.TranslateOrder: | ||||
if(msgId==2){ | |||||
if (msgId == 2) { | |||||
handlerCreateTranslateOrder(content); | handlerCreateTranslateOrder(content); | ||||
}else if(msgId ==4){ | |||||
} else if (msgId == 4) { | |||||
handlerReceiveOrder(content); | handlerReceiveOrder(content); | ||||
}else if(msgId ==6){ | |||||
} else if (msgId == 6) { | |||||
handlerCancelTranslateOrder(content); | handlerCancelTranslateOrder(content); | ||||
}else if(msgId==50){ | |||||
} else if (msgId == 50) { | |||||
handlerDeliveryInterpreterOrderPush(content); | handlerDeliveryInterpreterOrderPush(content); | ||||
} | } | ||||
break; | break; | ||||
@@ -970,7 +963,7 @@ class MsgHandler { | |||||
NetWork().singOut(); | NetWork().singOut(); | ||||
UserData().reset(); | UserData().reset(); | ||||
break; | break; | ||||
case 'blacklist': | |||||
case 'blacklist': | |||||
String messageJson = map['message']; | String messageJson = map['message']; | ||||
Map messageMap = json.decode(messageJson); | Map messageMap = json.decode(messageJson); | ||||
if (messageMap['Status'] == 0) { | if (messageMap['Status'] == 0) { | ||||
@@ -1209,24 +1202,21 @@ class MsgHandler { | |||||
NetWork().sendMsg(ComId.Chat, 225, seq); | NetWork().sendMsg(ComId.Chat, 225, seq); | ||||
} | } | ||||
//是否显示群昵称 | //是否显示群昵称 | ||||
static setGroupIsShowMenberNiceNameReq(int groupId, bool isShow) { | |||||
static setGroupIsShowMenberNiceNameReq(int groupId, bool isShow) { | |||||
print('设置是否显示群昵称 groupId:$groupId isShow: $isShow'); | print('设置是否显示群昵称 groupId:$groupId isShow: $isShow'); | ||||
var seq = SetGroupIsShowMenberNiceNameReq.create(); | var seq = SetGroupIsShowMenberNiceNameReq.create(); | ||||
seq.groupId = groupId; | seq.groupId = groupId; | ||||
seq.isShowMenberNiceName=isShow; | |||||
seq.isShowMenberNiceName = isShow; | |||||
NetWork().sendMsg(ComId.Chat, 229, seq); | NetWork().sendMsg(ComId.Chat, 229, seq); | ||||
} | } | ||||
//发布翻译管家帮助订单 | //发布翻译管家帮助订单 | ||||
static sendCreateTranslateOrder(int fromLanguage,int toLanguage,int scences,String extraDesc) { | |||||
debugPrint('发布翻译管家帮助订单 fromLanguage:$fromLanguage toLanguage: $toLanguage | ${fromLanguage|toLanguage}' ); | |||||
static sendCreateTranslateOrder( | |||||
int fromLanguage, int toLanguage, int scences, String extraDesc) { | |||||
debugPrint( | |||||
'发布翻译管家帮助订单 fromLanguage:$fromLanguage toLanguage: $toLanguage | ${fromLanguage | toLanguage}'); | |||||
// var seq = IssueInterpreterOrderReq.create(); | // var seq = IssueInterpreterOrderReq.create(); | ||||
// seq.tLanguage = fromLanguage|toLanguage; | // seq.tLanguage = fromLanguage|toLanguage; | ||||
// | // | ||||
@@ -1247,9 +1237,7 @@ class MsgHandler { | |||||
} | } | ||||
//撤销订单消息 | //撤销订单消息 | ||||
static sendCancelTranslateOrder( String orderId) { | |||||
static sendCancelTranslateOrder(String orderId) { | |||||
// debugPrint('取消订单 fromLanguage:$orderId' ); | // debugPrint('取消订单 fromLanguage:$orderId' ); | ||||
// var seq = CancellationInterpreterOrderReq.create(); | // var seq = CancellationInterpreterOrderReq.create(); | ||||
// seq.orderId = orderId; | // seq.orderId = orderId; | ||||
@@ -1277,10 +1265,8 @@ class MsgHandler { | |||||
// print('OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}'); | // print('OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}'); | ||||
} | } | ||||
//接收订单请求 | //接收订单请求 | ||||
static sendReceiveOrder( String orderId) { | |||||
static sendReceiveOrder(String orderId) { | |||||
// debugPrint('接收订单消息请求 orderId:$orderId' ); | // debugPrint('接收订单消息请求 orderId:$orderId' ); | ||||
// var seq = ReceivingInterpreterOrderReq.create(); | // var seq = ReceivingInterpreterOrderReq.create(); | ||||
// seq.orderId = orderId; | // seq.orderId = orderId; | ||||
@@ -1301,8 +1287,6 @@ class MsgHandler { | |||||
// } | // } | ||||
} | } | ||||
//消息免打扰请求结果 | //消息免打扰请求结果 | ||||
static handlerGroupIsShowMenberNiceName(List<int> msgContent) { | static handlerGroupIsShowMenberNiceName(List<int> msgContent) { | ||||
print('设置是否显示群昵称'); | print('设置是否显示群昵称'); | ||||
@@ -1315,8 +1299,6 @@ class MsgHandler { | |||||
} | } | ||||
} | } | ||||
//消息免打扰请求结果 | //消息免打扰请求结果 | ||||
static handlerUpdateMemberMsgFree(List<int> msgContent) { | static handlerUpdateMemberMsgFree(List<int> msgContent) { | ||||
print('消息免打扰请求结果'); | print('消息免打扰请求结果'); | ||||
@@ -1329,8 +1311,6 @@ class MsgHandler { | |||||
} | } | ||||
} | } | ||||
//群主批准其他人加入群结果 | //群主批准其他人加入群结果 | ||||
static handlerAgreeMember(List<int> msgContent) { | static handlerAgreeMember(List<int> msgContent) { | ||||
print('群主批准其他人加入群结果'); | print('群主批准其他人加入群结果'); | ||||
@@ -1357,8 +1337,6 @@ class MsgHandler { | |||||
NetWork().sendMsg(ComId.Chat, 227, seq); | NetWork().sendMsg(ComId.Chat, 227, seq); | ||||
} | } | ||||
//请求群列表求结果 | //请求群列表求结果 | ||||
static handlerGetGroupListRes(List<int> msgContent) async { | static handlerGetGroupListRes(List<int> msgContent) async { | ||||
var res = QueryUserRelationGroupRes.fromBuffer(msgContent); | var res = QueryUserRelationGroupRes.fromBuffer(msgContent); | ||||
@@ -916,6 +916,13 @@ packages: | |||||
url: "https://pub.flutter-io.cn" | url: "https://pub.flutter-io.cn" | ||||
source: hosted | source: hosted | ||||
version: "0.22.6" | version: "0.22.6" | ||||
scrollable_positioned_list: | |||||
dependency: "direct main" | |||||
description: | |||||
name: scrollable_positioned_list | |||||
url: "https://pub.flutter-io.cn" | |||||
source: hosted | |||||
version: "0.1.2" | |||||
share: | share: | ||||
dependency: "direct main" | dependency: "direct main" | ||||
description: | description: | ||||
@@ -1161,4 +1168,4 @@ packages: | |||||
version: "2.2.0" | version: "2.2.0" | ||||
sdks: | sdks: | ||||
dart: ">=2.6.0 <3.0.0" | dart: ">=2.6.0 <3.0.0" | ||||
flutter: ">=1.12.13+hotfix.4 <2.0.0" | |||||
flutter: ">=1.12.13+hotfix.5 <2.0.0" |
@@ -177,6 +177,7 @@ dependencies: | |||||
share_extend: ^1.1.1 | share_extend: ^1.1.1 | ||||
#多图片选择 | #多图片选择 | ||||
multi_image_picker: ^4.6.4 | multi_image_picker: ^4.6.4 | ||||
scrollable_positioned_list: ^0.1.2 | |||||
dev_dependencies: | dev_dependencies: | ||||
flutter_test: | flutter_test: | ||||