From bde32e73a611340949fd2137587d898c7aa0a9b8 Mon Sep 17 00:00:00 2001 From: kaciya Date: Mon, 16 Mar 2020 15:53:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AC=E5=8F=91=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ios/Flutter/flutter_export_environment.sh | 11 +- lib/chat/ChatPage.dart | 29 +- lib/chat/ChatPageItem.dart | 6 + lib/chat/group_chat_view.dart | 13 + lib/chat/util_keyboard.dart | 64 ++- lib/data/UserData.dart | 1 - lib/generated/i18n.dart | 71 +--- lib/home/AddProgram.dart | 10 +- lib/home/ConversActionPage.dart | 1 - lib/home/DiscoverPage.dart | 2 + lib/home/EditData.dart | 3 +- lib/home/InfoList.dart | 433 +++++++++++++++++++- lib/home/MoneyPageOld.dart | 1 - lib/home/Myprogram.dart | 1 - lib/home/ProfilePage.dart | 104 +++-- lib/home/ProgramDetail.dart | 10 +- lib/home/SearchPage.dart | 2 +- lib/home/WhiteAndBlackList.dart | 15 +- lib/home/create_group_view.dart | 4 +- lib/home/daily_bonus_page.dart | 4 +- lib/home/forward_view.dart | 135 +++++++ lib/home/friend_page.dart | 4 + lib/home/homeMain.dart | 4 +- lib/home/last_chat_item.dart | 19 - lib/home/last_chat_record_widget.dart | 4 +- lib/home/money_detail.dart | 1 - lib/home/my_qr.dart | 15 +- lib/main.dart | 9 - lib/utils/ChargeMoney.dart | 2 +- lib/utils/CustomUI.dart | 36 +- lib/utils/HttpUtil.dart | 103 +---- lib/utils/MessageBox.dart | 14 +- lib/utils/NetUtil.dart | 59 ++- lib/utils/TempUserCard.dart | 466 ++++++++++++---------- lib/utils/UserCard.dart | 29 +- lib/utils/app_navigator.dart | 41 +- lib/utils/file_preview_local.dart | 134 +++++++ lib/utils/local_notification_util.dart | 1 - lib/utils/msgHandler.dart | 18 +- lib/utils/receive_share_file.dart | 29 +- lib/utils/screen.dart | 5 - lib/utils/screen_shot.dart | 24 -- 42 files changed, 1284 insertions(+), 653 deletions(-) create mode 100644 lib/home/forward_view.dart create mode 100644 lib/utils/file_preview_local.dart diff --git a/ios/Flutter/flutter_export_environment.sh b/ios/Flutter/flutter_export_environment.sh index 4496333..44e2188 100755 --- a/ios/Flutter/flutter_export_environment.sh +++ b/ios/Flutter/flutter_export_environment.sh @@ -1,11 +1,10 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/Users/random/sdk/flutter_sdk" -export "FLUTTER_APPLICATION_PATH=/Users/random/code/flutter/project/qunliao" -export "FLUTTER_TARGET=/Users/random/code/flutter/project/qunliao/lib/main.dart" +export "FLUTTER_ROOT=D:\flutter\src\flutter" +export "FLUTTER_APPLICATION_PATH=E:\ChatScr\Chat\Hibok" +export "FLUTTER_TARGET=lib\main.dart" export "FLUTTER_BUILD_DIR=build" -export "SYMROOT=${SOURCE_ROOT}/../build/ios" -export "FLUTTER_FRAMEWORK_DIR=/Users/random/sdk/flutter_sdk/bin/cache/artifacts/engine/ios" +export "SYMROOT=${SOURCE_ROOT}/../build\ios" +export "FLUTTER_FRAMEWORK_DIR=D:\flutter\src\flutter\bin\cache\artifacts\engine\ios" export "FLUTTER_BUILD_NAME=1.0.5" export "FLUTTER_BUILD_NUMBER=6" -export "TRACK_WIDGET_CREATION=true" diff --git a/lib/chat/ChatPage.dart b/lib/chat/ChatPage.dart index 3b2e3c0..75752de 100644 --- a/lib/chat/ChatPage.dart +++ b/lib/chat/ChatPage.dart @@ -17,7 +17,6 @@ import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/TokenMgr.dart'; import 'package:chat/utils/analyze_utils.dart'; import 'package:chat/utils/app_navigator.dart'; -import 'package:chat/utils/blacklist_mgr.dart'; import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/net_state_widget.dart'; @@ -37,7 +36,6 @@ import 'input_bar.dart'; import 'package:chat/utils/PopUpMenu.dart' as myPop; import 'package:chat/models/money_change.dart'; - class ChatPage extends StatefulWidget { final int friendId; final int enterType; // 0默认 1图片 @@ -196,15 +194,22 @@ class _ChatPageState extends State { WidgetsBinding.instance.addPostFrameCallback((_) { if (widget.enterType == 1) { print('接收到的:${widget.enterContent}'); - - File file = new File(widget.enterContent); - if(file.existsSync()){ - print('接收到的文件--存在'); - }else{ - print('接收到的文件--不存在'); + _sendFile(File(widget.enterContent)); + } else if (widget.enterType == 2) { + //转发消息 + + MsgModel originMsg = widget.enterContent; + MsgModel msg = MsgHandler.createSendMsg( + ChatType.valueOf(originMsg.msgType), originMsg.msgContent); + msg.extraInfo = originMsg.extraInfo; + msg.extraFile = originMsg.extraFile; + msg.localFile = originMsg.localFile; + msg.friendId = widget.friendId; + if (msg.localFile != null) { + msg.state = MsgState.Uploaded; } - _sendFile(File(widget.enterContent)); + sendMsg(msg); } }); } @@ -473,12 +478,12 @@ class _ChatPageState extends State { sendMsg(MsgModel msg) { print('对方是否拉黑你 ${friendInfo.isBlackened}'); - if (BlacklistMgr.isBlaklistMe(friendInfo.userId)) { - showToast(I18n.of(context).you_are_blaklisted); + if (friendInfo.isBlackened) { + showToast('对方已拉黑了你'); return; } - if (BlacklistMgr.isInMyblaklist(friendInfo.userId)) { + if (friendInfo.isBlackList) { showToast(I18n.of(context).reject_message); return; } diff --git a/lib/chat/ChatPageItem.dart b/lib/chat/ChatPageItem.dart index 50cb465..3f20504 100644 --- a/lib/chat/ChatPageItem.dart +++ b/lib/chat/ChatPageItem.dart @@ -614,6 +614,7 @@ class _ChatPageItemState extends State List actions = [ I18n.of(context).delete, I18n.of(context).reply, + '转发' ]; actionsFunc.add(() { @@ -623,6 +624,11 @@ class _ChatPageItemState extends State print('发送引用的消息'); MessageMgr().emit('Reply Select Message', widget.msg); }); + actionsFunc.add(() { + print('转发消息'); + AppNavigator.pushForwardPage(context, widget.msg); + }); + if (widget.msg.msgType == ChatType.TextChatType.value) { actions.insert(0, I18n.of(context).copy); diff --git a/lib/chat/group_chat_view.dart b/lib/chat/group_chat_view.dart index 64856ee..cf76619 100644 --- a/lib/chat/group_chat_view.dart +++ b/lib/chat/group_chat_view.dart @@ -106,6 +106,19 @@ class _GroupChatPageState extends State { if (widget.enterType == 1) { print('接收到的:${widget.enterContent}'); _sendFile(File(widget.enterContent)); + } else if (widget.enterType == 2) { + //转发消息 + MsgModel originMsg = widget.enterContent; + MsgModel msg = MsgHandler.createSendMsg( + ChatType.valueOf(originMsg.msgType), originMsg.msgContent,channelType: ChatChannelType.Group); + msg.extraInfo = originMsg.extraInfo; + msg.extraFile = originMsg.extraFile; + msg.localFile = originMsg.localFile; + if (msg.localFile != null) { + msg.state = MsgState.Uploaded; + } + + sendMsg(msg); } }); } diff --git a/lib/chat/util_keyboard.dart b/lib/chat/util_keyboard.dart index 81dc032..1c38dc0 100644 --- a/lib/chat/util_keyboard.dart +++ b/lib/chat/util_keyboard.dart @@ -15,7 +15,6 @@ import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/LoadingDialog.dart'; import 'package:chat/utils/app_navigator.dart'; -import 'package:chat/utils/blacklist_mgr.dart'; import 'package:chat/utils/image_util.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/screen.dart'; @@ -164,16 +163,6 @@ class UtilKeyboard extends StatelessWidget { return; } - if (BlacklistMgr.isBlaklistMe(info.userId)) { - showToast(I18n.of(context).you_are_blaklisted); - return; - } - - if (BlacklistMgr.isInMyblaklist(info.userId)) { - showToast(I18n.of(context).reject_message); - return; - } - //对方关闭陌生人消息,则提示 if (!info.isCanStrangerNews) { showToast(I18n.of(context).stranger_close_tips); @@ -304,38 +293,39 @@ class UtilKeyboard extends StatelessWidget { int fileSize = file.lengthSync(); print('选择的文件 ${file.path} 大小 $fileSize'); - if (fileSize > 33 * 1024 * 1024) { - showToast('文件大于33M'); - return; - } + if (fileSize > 33 * 1024 * 1024) { + showToast('文件大于33M'); + return; + } - int friendId = 0; - if (!isGroup) { - friendId = Provider.of(context); - } + int friendId = 0; + if (!isGroup) { + friendId = Provider.of(context); + } - var fileName = file.path.split('/').last; - print('fileName $fileName'); + var fileName = file.path.split('/').last; + print('fileName $fileName'); - var ext = ''; - var extList = fileName.split('.'); - if (extList.length > 1) { - ext = extList.last; - } - print('ext $ext'); + var ext = ''; + var extList = fileName.split('.'); + if (extList.length > 1) { + ext = extList.last; + } + print('ext $ext'); - var fileMsg = FileChat.create(); - fileMsg.type = ext; - fileMsg.size = fileSize; - fileMsg.name = fileName; + var fileMsg = FileChat.create(); + fileMsg.type = ext; + fileMsg.size = fileSize; + fileMsg.name = fileName; - var msg = MsgHandler.createSendMsg( - ChatType.FileChatType, fileMsg.writeToBuffer(), - friendId: friendId, - localFile: file.path, - channelType: isGroup ? ChatChannelType.Group : ChatChannelType.Session); + var msg = MsgHandler.createSendMsg(ChatType.FileChatType, fileMsg.writeToBuffer(), + friendId: friendId, + localFile: file.path, + channelType: + isGroup ? ChatChannelType.Group : ChatChannelType.Session); + + sendMsg(msg); - sendMsg(msg); } void _sendVideo(BuildContext context) async { diff --git a/lib/data/UserData.dart b/lib/data/UserData.dart index 9980c40..21c800a 100644 --- a/lib/data/UserData.dart +++ b/lib/data/UserData.dart @@ -219,7 +219,6 @@ class UserData { await prefs.setDouble(Constants.Longitude, UserData().longitude); HttpUtil().getAddress(loc.longitude, loc.latitude); //HttpUtil().getAddress(106.600798525456, 10.7517368433358); - //HttpUtil().getAddress(113.8669580078125, 22.568465711805555); if (callback != null) callback(loc); } } diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index 66a89a1..a245bf5 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -2017,8 +2017,8 @@ class I18n implements WidgetsLocalizations { String get emoji => "emoji"; /// "Sign up today to receive /s1 points" String get today_score => "Sign up today to receive /s1 points"; - /// "1. Daily sign-in can receive points. The more accumulated days, the higher the points. \n2. The points can be exchanged for H coins. The exchange will consume the corresponding points. Please redeem carefully. \n3. The sign-in will be reset on the last day of each month. Redeem in time." - String get sign_tips => "1. Daily sign-in can receive points. The more accumulated days, the higher the points. \n2. The points can be exchanged for H coins. The exchange will consume the corresponding points. Please redeem carefully. \n3. The sign-in will be reset on the last day of each month. Redeem in time."; + /// "1. Daily sign-in can receive points. The more accumulated days, the higher the points. \n2. The points can be exchanged for H coins. The exchange will consume the corresponding points. Please redeem carefully. \n3. The sign-in will be reset on the last day of each month. Redeem in time" + String get sign_tips => "1. Daily sign-in can receive points. The more accumulated days, the higher the points. \n2. The points can be exchanged for H coins. The exchange will consume the corresponding points. Please redeem carefully. \n3. The sign-in will be reset on the last day of each month. Redeem in time"; /// "Sign in" String get sign_in => "Sign in"; /// "My scores" @@ -2351,12 +2351,6 @@ class I18n implements WidgetsLocalizations { String get not_have_user => "用户不存在"; /// "你不能添加自己" String get not_add_Myself => "你不能添加自己"; - /// "对方已拉黑了你" - String get you_are_blaklisted => "对方已拉黑了你"; - /// "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)" - String get confrim_recovery => "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)"; - /// "發送到" - String get send_to => "發送到"; } class _I18n_en_US extends I18n { @@ -5345,9 +5339,9 @@ class _I18n_vi_VN extends I18n { /// "Báo danh trong ngày để nhận /s1 điểm tích lũy" @override String get today_score => "Báo danh trong ngày để nhận /s1 điểm tích lũy"; - /// "1. Báo danh hàng ngày để tích lũy điểm, số ngày tích lũy càng nhiều điêm tích lũy càng cao. \n2. Điểm tích lũy có thể đổi thành H coin, khi đổi sẽ tiêu hao điểm tích lũy tương đương, hãy thận trọng khi đổi. \n3.Báo danh sẽ được đặt lại vào ngày cuối cùng của tháng, xóa điểm tích lũy. Hãy kịp thời đổi điểm tích lũy nhé!" + /// "1. Báo danh hàng ngày để tích lũy điểm, số ngày tích lũy càng nhiều điêm tích lũy càng cao \n2. Điểm tích lũy có thể đổi thành H coin, khi đổi sẽ tiêu hao điểm tích lũy tương đương, hãy thận trọng khi đổi. \n3.Báo danh sẽ được đặt lại vào ngày cuối cùng của tháng, xóa điểm tích lũy. Hãy kịp thời đổi điểm tích lũy nhé!" @override - String get sign_tips => "1. Báo danh hàng ngày để tích lũy điểm, số ngày tích lũy càng nhiều điêm tích lũy càng cao. \n2. Điểm tích lũy có thể đổi thành H coin, khi đổi sẽ tiêu hao điểm tích lũy tương đương, hãy thận trọng khi đổi. \n3.Báo danh sẽ được đặt lại vào ngày cuối cùng của tháng, xóa điểm tích lũy. Hãy kịp thời đổi điểm tích lũy nhé!"; + String get sign_tips => "1. Báo danh hàng ngày để tích lũy điểm, số ngày tích lũy càng nhiều điêm tích lũy càng cao \n2. Điểm tích lũy có thể đổi thành H coin, khi đổi sẽ tiêu hao điểm tích lũy tương đương, hãy thận trọng khi đổi. \n3.Báo danh sẽ được đặt lại vào ngày cuối cùng của tháng, xóa điểm tích lũy. Hãy kịp thời đổi điểm tích lũy nhé!"; /// "Báo danh" @override String get sign_in => "Báo danh"; @@ -5846,15 +5840,6 @@ class _I18n_vi_VN extends I18n { /// "你不能添加自己" @override String get not_add_Myself => "你不能添加自己"; - /// "对方已拉黑了你" - @override - String get you_are_blaklisted => "对方已拉黑了你"; - /// "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)" - @override - String get confrim_recovery => "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)"; - /// "發送到" - @override - String get send_to => "發送到"; @override TextDirection get textDirection => TextDirection.ltr; @@ -8839,9 +8824,9 @@ class _I18n_zh_HK extends I18n { /// "今日簽到可領取/s1積分" @override String get today_score => "今日簽到可領取/s1積分"; - /// "1、每日簽到可領取積分,累計天數越多積分越高。\n2、積分可兌換H幣,兌換將消耗對應積分,請慎重兌換。\n3、每月最後一天將重置簽到,清零積分,請記得及時兌換。" + /// "1、每日簽到可領取積分,累計天數越多積分越高\n2、積分可兌換H幣,兌換將消耗對應積分,請慎重兌換\n3、每月最後一天將重置簽到,清零積分,請記得及時兌換" @override - String get sign_tips => "1、每日簽到可領取積分,累計天數越多積分越高。\n2、積分可兌換H幣,兌換將消耗對應積分,請慎重兌換。\n3、每月最後一天將重置簽到,清零積分,請記得及時兌換。"; + String get sign_tips => "1、每日簽到可領取積分,累計天數越多積分越高\n2、積分可兌換H幣,兌換將消耗對應積分,請慎重兌換\n3、每月最後一天將重置簽到,清零積分,請記得及時兌換"; /// "簽到" @override String get sign_in => "簽到"; @@ -9340,15 +9325,6 @@ class _I18n_zh_HK extends I18n { /// "你不能添加自己" @override String get not_add_Myself => "你不能添加自己"; - /// "對方已拉黑了你" - @override - String get you_are_blaklisted => "對方已拉黑了你"; - /// "確定恢復已被焚毀的照片嗎?\n(已經看過的用戶可以再看一次)" - @override - String get confrim_recovery => "確定恢復已被焚毀的照片嗎?\n(已經看過的用戶可以再看一次)"; - /// "發送到" - @override - String get send_to => "發送到"; @override TextDirection get textDirection => TextDirection.ltr; @@ -12333,9 +12309,9 @@ class _I18n_zh_CN extends _I18n_zh_HK { /// "今日签到可领取/s1积分" @override String get today_score => "今日签到可领取/s1积分"; - /// "1、每日签到可领取积分,累计天数越多积分越高。\n2、积分可兑换H币,兑换将消耗对应积分,请慎重兑换。\n3、每月最后一天将重置签到,清零积分,请记得及时兑换。" + /// "1、每日签到可领取积分,累计天数越多积分越高\n2、积分可兑换H币,兑换将消耗对应积分,请慎重兑换\n3、每月最后一天将重置签到,清零积分,请记得及时兑换" @override - String get sign_tips => "1、每日签到可领取积分,累计天数越多积分越高。\n2、积分可兑换H币,兑换将消耗对应积分,请慎重兑换。\n3、每月最后一天将重置签到,清零积分,请记得及时兑换。"; + String get sign_tips => "1、每日签到可领取积分,累计天数越多积分越高\n2、积分可兑换H币,兑换将消耗对应积分,请慎重兑换\n3、每月最后一天将重置签到,清零积分,请记得及时兑换"; /// "签到" @override String get sign_in => "签到"; @@ -12834,15 +12810,6 @@ class _I18n_zh_CN extends _I18n_zh_HK { /// "你不能添加自己" @override String get not_add_Myself => "你不能添加自己"; - /// "对方已拉黑了你" - @override - String get you_are_blaklisted => "对方已拉黑了你"; - /// "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)" - @override - String get confrim_recovery => "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)"; - /// "发送到" - @override - String get send_to => "发送到"; @override TextDirection get textDirection => TextDirection.ltr; @@ -16325,15 +16292,6 @@ class _I18n_ko_KR extends I18n { /// "用户不存在" @override String get not_have_user => "用户不存在"; - /// "对方已拉黑了你" - @override - String get you_are_blaklisted => "对方已拉黑了你"; - /// "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)" - @override - String get confrim_recovery => "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)"; - /// "發送到" - @override - String get send_to => "發送到"; @override TextDirection get textDirection => TextDirection.ltr; @@ -19318,9 +19276,9 @@ class _I18n_ja_JP extends I18n { /// "本日サインして/s1ポイントが受け入れる" @override String get today_score => "本日サインして/s1ポイントが受け入れる"; - /// "1.毎日サインしてポイントが受け入れます、累積日数が多ければ多いほどポイントが高くなります.\n2.ポイントはH幤に交換できます、交換はポイントを消費しますので慎重に交換してください.\n3.サインは毎月の最終日にリセットされ、ポイントもクリアされます。時間内に交換することを忘れないでください." + /// "1.毎日サインしてポイントが受け入れます、累積日数が多ければ多いほどポイントが高くなります\n2.ポイントはH幤に交換できます、交換はポイントを消費しますので慎重に交換してください\n3.サインは毎月の最終日にリセットされ、ポイントもクリアされます。時間内に交換することを忘れないでください " @override - String get sign_tips => "1.毎日サインしてポイントが受け入れます、累積日数が多ければ多いほどポイントが高くなります.\n2.ポイントはH幤に交換できます、交換はポイントを消費しますので慎重に交換してください.\n3.サインは毎月の最終日にリセットされ、ポイントもクリアされます。時間内に交換することを忘れないでください."; + String get sign_tips => "1.毎日サインしてポイントが受け入れます、累積日数が多ければ多いほどポイントが高くなります\n2.ポイントはH幤に交換できます、交換はポイントを消費しますので慎重に交換してください\n3.サインは毎月の最終日にリセットされ、ポイントもクリアされます。時間内に交換することを忘れないでください "; /// "サイン" @override String get sign_in => "サイン"; @@ -19819,15 +19777,6 @@ class _I18n_ja_JP extends I18n { /// "你不能添加自己" @override String get not_add_Myself => "你不能添加自己"; - /// "对方已拉黑了你" - @override - String get you_are_blaklisted => "对方已拉黑了你"; - /// "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)" - @override - String get confrim_recovery => "确定恢复已被焚毁的照片吗?\n(已经看过的用户可以再看一次)"; - /// "發送到" - @override - String get send_to => "發送到"; @override TextDirection get textDirection => TextDirection.ltr; diff --git a/lib/home/AddProgram.dart b/lib/home/AddProgram.dart index 4ca992e..3b0f80b 100644 --- a/lib/home/AddProgram.dart +++ b/lib/home/AddProgram.dart @@ -709,7 +709,6 @@ class _AddProgramState extends State { } void _sendPicture() async { - closeEmojiAction(); var photos = await PhotoPicker.pickAsset( context: context, themeColor: Color(0xFFF0F0F0), @@ -868,7 +867,8 @@ class _AddProgramState extends State { contentPadding: EdgeInsets.only(top: 6, bottom: 10, right: 10), hintText: I18n.of(context).please_civilization, - hintStyle: TextStyle(fontSize: 12, height: 1.15), + hintStyle: + TextStyle(fontSize: 12, height: 1.15), border: InputBorder.none, ), style: TextStyle( @@ -1157,7 +1157,7 @@ class _AddProgramState extends State { .replaceFirst('/s1', UserData().addProgramPrice.toString()); } return Container( - padding: EdgeInsets.only(bottom: 100, left: 20, right: 20), + padding: EdgeInsets.only(bottom: 100), child: Text( str, textScaleFactor: 1.0, @@ -1311,8 +1311,8 @@ class _AddProgramState extends State { var hopeObject = ''; lovePeopleId.forEach((f) => hopeObject += hopeObject == '' ? f : ',$f'); - String temp = ''; - String postTemp = ''; + String temp=''; + String postTemp=''; imgUrlList.forEach((str) { temp += (temp == "" ? str : '|$str'); postTemp += (postTemp == "" diff --git a/lib/home/ConversActionPage.dart b/lib/home/ConversActionPage.dart index 3a35f78..46101bf 100644 --- a/lib/home/ConversActionPage.dart +++ b/lib/home/ConversActionPage.dart @@ -4,7 +4,6 @@ import 'package:chat/data/conversation.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/home/InfoList.dart'; import 'package:chat/home/last_chat_record_widget.dart'; -import 'package:chat/home/rich_title.dart'; import 'package:chat/home/unread_dot_widget.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; diff --git a/lib/home/DiscoverPage.dart b/lib/home/DiscoverPage.dart index 46d6217..2b4a4fc 100644 --- a/lib/home/DiscoverPage.dart +++ b/lib/home/DiscoverPage.dart @@ -691,6 +691,8 @@ class _DisCoverPageState extends State Widget _renderRow(int index, list, page) { if (index < list.length) { var userInfo = list[index]; + print('----------------------------------------------------'); + print(userInfo); return UserCard( key: UniqueKey(), userName: Provider.of(context) diff --git a/lib/home/EditData.dart b/lib/home/EditData.dart index 8984dce..e9a7c80 100644 --- a/lib/home/EditData.dart +++ b/lib/home/EditData.dart @@ -742,8 +742,7 @@ class _EditPageState extends State { widget.isEditPage ? idItem : Container(), _buildDivider(), _bottomBorderBox(I18n.of(context).nickname, I18n.of(context).fill_out, - true, nickNameController, true, (str) => nickname = str, - inputFormatters: [LengthLimitingTextInputFormatter(20)]), + true, nickNameController, true, (str) => nickname = str), _buildDivider(), _bottomBorderBox(I18n.of(context).country, country, false, null, countryId.length != 0, selectCountry), diff --git a/lib/home/InfoList.dart b/lib/home/InfoList.dart index 7bb2823..75e4c70 100644 --- a/lib/home/InfoList.dart +++ b/lib/home/InfoList.dart @@ -2,7 +2,6 @@ import 'package:chat/data/UserData.dart'; import 'package:chat/data/WebData.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/home/ProfilePage.dart'; -import 'package:chat/home/rich_title.dart'; import 'package:chat/models/ref_name_provider.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; @@ -27,6 +26,16 @@ import 'package:cached_network_image/cached_network_image.dart'; import 'ProgramDetail.dart'; +class InfoType { + static const int Apply = 1; + static const int Evaluation = 2; + static const int System = 3; + static const int Radio = 4; + static const int Money = 5; + static const int IncomeMoney = 6; + static const int MyMoney = 7; +} + class _ConversationItem extends StatelessWidget { const _ConversationItem( {Key key, @@ -352,7 +361,429 @@ class _ConversationItem extends StatelessWidget { } } +class TitleItem { + String title = ''; + String name = ''; + String value = ''; + TitleItem({this.title, this.name, this.value}); +} + +class RichTitle { + static List getRichText(TitleItem titleItem, + {titleStyle, nameStyle}) { + if (nameStyle == null) { + nameStyle = TextStyle( + fontWeight: FontWeight.w500, color: Constants.BlackTextColor); + } + if (titleStyle == null) { + titleStyle = TextStyle(color: Constants.GreyTextColor); + } + + titleItem.title = titleItem.title == null ? '' : titleItem.title; + List list = titleItem.title.split('/s1'); + titleItem.name = titleItem.name == null ? '' : (titleItem.name + ' '); + List child; + if (list == null) { + child = [ + TextSpan(text: titleItem.title, style: titleStyle), + ]; + } else { + child = list.length > 1 + ? [ + TextSpan( + text: list[0] == '' ? '' : (list[0] + ' '), + style: titleStyle), + TextSpan(text: titleItem.name, style: nameStyle), + TextSpan(text: list[1], style: titleStyle), + ] + : [ + TextSpan(text: titleItem.name, style: nameStyle), + TextSpan(text: list[0], style: titleStyle), + ]; + } + return child; + } + + static String getNormalText(TitleItem titleItem) { + List list = titleItem.title.split('/s1'); + titleItem.name = titleItem.name == null ? '' : (titleItem.name + ' '); + String res = ''; + if (list == null) { + res = titleItem.title; + } else { + list.length > 1 + ? res = (list[0] == '' ? list[0] : (list[0] + ' ')) + + titleItem.name + + list[1] + : res = titleItem.name + list[0]; + } + return res; + } + + //申请 + static TitleItem _delApplyTitle(userInfo, BuildContext context) { + print(userInfo); + bool isMyself = userInfo['ApplyUserId'] == UserData().basicInfo.userId; + + String name = isMyself + ? Provider.of(context) + .getRefName(userInfo['UserId'], userInfo['UserName']) + : Provider.of(context) + .getRefName(userInfo['ApplyUserId'], userInfo['ApplyName']); + String title = isMyself + ? userInfo['Status'] == 1 + ? I18n.of(context).l15_days + : I18n.of(context).reject_reply + : I18n.of(context).view_application2; + if (userInfo['Type'] == 1) { + title = isMyself + ? I18n.of(context).applyed_friends + : I18n.of(context).apply_friends; + } + + return TitleItem(title: title, name: name); + } + + //评价 + static TitleItem _delEvaluateTitle(userInfo, BuildContext context) { + String name = WebData().getEvaluation(context, userInfo['Value']); + String title = ''; + if (userInfo['Status'] == 2) { + title = I18n.of(context).successful_appeal; + } else if (userInfo['Status'] == 3) { + title = I18n.of(context).successful_appeal1; + } else { + title = UserData().isMan() + ? I18n.of(context).received_evaluation + : I18n.of(context).received_evaluation2; + } + return TitleItem(title: title, name: name); + } + + //电台 + static TitleItem _delRadioTitle(data, BuildContext context) { + bool isProgram = data['ProgramType'] == 0; + String title; + switch (data['Type']) { + case 1: + title = isProgram + ? I18n.of(context).thumbs_up2 + : I18n.of(context).thumbs_up; + break; + case 2: + title = + isProgram ? I18n.of(context).comment2 : I18n.of(context).comment1; + break; + case 3: + title = I18n.of(context).signed_up; + break; + case 4: + title = isProgram + ? I18n.of(context).favorite_user + : I18n.of(context).favorite_user2; + break; + case 5: + title = I18n.of(context).replied_comment; + break; + default: + } + return TitleItem( + title: title, + name: Provider.of(context) + .getRefName(data['UserId'], data['UserName'])); + } + + //系统 + static TitleItem _delSystemTitle(data, BuildContext context) { + bool isMyself = data['UserId'] == UserData().basicInfo.userId; + + bool isPass = data['Status'] == 1; + String title = ''; + String name = Provider.of(context) + .getRefName(data['ReportedUserId'], data['ReportedUserName']); + switch (data['Type']) { + case 1: + title = isPass + ? I18n.of(context).upload_success + : I18n.of(context).re_upload; + break; + case 2: + title = isPass + ? I18n.of(context).successful_authentication + : I18n.of(context).authentication_failed; + break; + case 3: + if (isMyself) { + title = data['Status'] == 1 + ? I18n.of(context).report_success + : I18n.of(context).report_failure; + } else { + title = I18n.of(context).coin_returen; + } + break; + case 4: + title = data['Status'] == 1 + ? I18n.of(context).successful_application + : I18n.of(context).application_failed; + name = data['Status'] == 1 ? data['Content'].toString() : null; + break; + case 5: + title = '代理会员推送相关'; + break; + default: + } + return TitleItem(title: title, name: name); + } + + //钱包 + static TitleItem _delMoneyTitle(data, BuildContext context) { + String title = ''; + bool isMyself = data['UserId'] == UserData().basicInfo.userId; + String name = Provider.of(context) + .getRefName(data['ChangeUserId'], data['UserName']); + switch (data['DetailType'] == 10 ? data['Status'] : data['DetailType']) { + case 1: + title = I18n.of(context).get_coin2; + name = data['Value'].toString(); + break; + case 2: + title = I18n.of(context).buy_vip; + name = data['Value'].toString(); + break; + case 3: + title = isMyself + ? I18n.of(context) + .paid_you4 + .replaceFirst('/s2', data['Value'].toString()) + : I18n.of(context) + .paid_you + .replaceFirst('/s2', data['Value'].toString()); + break; + case 4: + title = isMyself + ? I18n.of(context) + .paid_you5 + .replaceFirst('/s2', data['Value'].toString()) + : I18n.of(context) + .paid_you2 + .replaceFirst('/s2', data['Value'].toString()); + break; + case 5: + title = I18n.of(context).buy_program; + name = data['Value'].toString(); + break; + case 6: + if (data['Status'] == 0) { + title = I18n.of(context).del_add_money; + } else if (data['Status'] == 1) { + title = I18n.of(context).adding_money; + } else { + title = I18n.of(context).withdraw_fail; + } + name = data['Value'].toString(); + break; + case 7: + title = + isMyself ? I18n.of(context).paid_you6 : I18n.of(context).paid_you3; + break; + case 8: + title = isMyself + ? I18n.of(context) + .give_other_money + .replaceFirst('/s2', data['Value'].toString()) + : I18n.of(context) + .get_other_money + .replaceFirst('/s2', data['Value'].toString()); + break; + case 9: + title = isMyself + ? I18n.of(context) + .give_red_money + .replaceFirst('/s2', data['Value'].toString()) + : I18n.of(context) + .get_red_money + .replaceFirst('/s2', data['Value'].toString()); + break; + case 11: + title = I18n.of(context).Redeem; + name = data['Value'].toString(); + break; + } + return TitleItem(title: title, name: name); + } + + //收入金额 + static TitleItem _delInMoneyTitle(data, BuildContext context) { + String title = ''; + String name = Provider.of(context) + .getRefName(data['UserId'], data['UserName']); + switch (data['DetailType']) { + case 1: + if (data['Status'] == 0) { + title = I18n.of(context).del_add_money; + } else if (data['Status'] == 1) { + title = I18n.of(context).withdraw_fail; + } else { + title = I18n.of(context).adding_money; + } + + name = data['Value'].toString(); + break; + case 2: + title = I18n.of(context).change_h_coin; + name = data['Value'].toString(); + break; + case 3: + title = I18n.of(context) + .get_other_money + .replaceFirst('/s2', data['Value'].toString()); + break; + case 4: + title = I18n.of(context) + .get_red_money + .replaceFirst('/s2', data['Value'].toString()); + break; + case 5: + title = I18n.of(context).paid_you3; + break; + case 6: + title = I18n.of(context) + .paid_you + .replaceFirst('/s2', data['Value'].toString()); + break; + case 7: + title = I18n.of(context) + .paid_you2 + .replaceFirst('/s2', data['Value'].toString()); + break; + case 8: + title = I18n.of(context).Representation_succes; + break; + case 9: + title = I18n.of(context).system_give; + break; + case 10: + title = I18n.of(context).exchange_fail; + break; + } + return TitleItem(title: title, name: name); + } + //我的余额 + static TitleItem _delMyMoneyTitle(data, BuildContext context) { + String title = ''; + String name = Provider.of(context) + .getRefName(data['UserId'], data['UserName']); + switch (data['DetailType']) { + case 1: + title = I18n.of(context).get_coin2; + name = data['Value'].toString(); + break; + case 2: + title = I18n.of(context).hibok_exchange; + name = data['Value'].toString(); + break; + case 3: + title = I18n.of(context).bind_code_success; + break; + case 4: + title = I18n.of(context) + .give_other_money + .replaceFirst('/s2', data['Value'].toString()); + break; + case 5: + title = I18n.of(context) + .give_red_money + .replaceFirst('/s2', data['Value'].toString()); + break; + case 6: + title = I18n.of(context) + .paid_you6 + .replaceFirst('/s2', data['Value'].toString()); + break; + case 7: + title = I18n.of(context) + .paid_you4 + .replaceFirst('/s2', data['Value'].toString()); + break; + case 8: + title = I18n.of(context) + .paid_you5 + .replaceFirst('/s2', data['Value'].toString()); + break; + case 9: + title = I18n.of(context).buy_vip; + name = data['Value'].toString(); + break; + case 10: + title = I18n.of(context).translate_money; + name = data['Value'].toString(); + break; + case 11: + title = I18n.of(context).buy_program; + name = data['Value'].toString(); + break; + case 12: + title = I18n.of(context).Representation_succes; + break; + case 13: + title = I18n.of(context).system_back; + break; + case 14: + title = I18n.of(context).system_give; + break; + } + return TitleItem(title: title, name: name); + } + + static TitleItem _getTypeTitleItem(userInfo, BuildContext context, int type) { + var tileItem = TitleItem(); + switch (type) { + case InfoType.Apply: + tileItem = _delApplyTitle(userInfo, context); + break; + case InfoType.Radio: + tileItem = _delRadioTitle(userInfo, context); + break; + case InfoType.System: + tileItem = _delSystemTitle(userInfo, context); + break; + case InfoType.Money: + tileItem = _delMoneyTitle(userInfo, context); + break; + case InfoType.IncomeMoney: + tileItem = _delInMoneyTitle(userInfo, context); + break; + case InfoType.MyMoney: + tileItem = _delMyMoneyTitle(userInfo, context); + break; + case InfoType.Evaluation: + tileItem = _delEvaluateTitle(userInfo, context); + break; + default: + } + return tileItem; + } + + static Widget getRichTitleWidget(userInfo, BuildContext context, int type, + {titleStyle, nameStyle}) { + var tileItem = _getTypeTitleItem(userInfo, context, type); + return RichText( + text: TextSpan( + children: getRichText(tileItem, + titleStyle: titleStyle, nameStyle: nameStyle))); + } + + static String normalTitle(userInfo, BuildContext context, int type) { + if (userInfo == null) { + return ''; + } + var tileItem = _getTypeTitleItem(userInfo, context, type); + var res = getNormalText(tileItem); + int maxlength = 17; + return res.length > maxlength ? res.substring(0, maxlength) + '...' : res; + } +} class InfoListPage extends StatefulWidget { @required diff --git a/lib/home/MoneyPageOld.dart b/lib/home/MoneyPageOld.dart index e42fe91..3f13595 100644 --- a/lib/home/MoneyPageOld.dart +++ b/lib/home/MoneyPageOld.dart @@ -10,7 +10,6 @@ import 'package:chat/generated/i18n.dart'; import 'package:chat/home/BindBank.dart'; import 'package:chat/home/InfoList.dart'; import 'package:chat/home/ProfilePage.dart'; -import 'package:chat/home/rich_title.dart'; import 'package:chat/models/money_change.dart'; import 'package:chat/utils/ChargeMoney.dart'; import 'package:chat/utils/CustomUI.dart'; diff --git a/lib/home/Myprogram.dart b/lib/home/Myprogram.dart index f29f67b..e682c91 100644 --- a/lib/home/Myprogram.dart +++ b/lib/home/Myprogram.dart @@ -171,7 +171,6 @@ class _MyProgramPageState extends State { ), centerTitle: true, leading: CustomUI.buildCustomLeading(context), - elevation: 1, actions: [ isMyself ? myPop.PopupMenuButton( diff --git a/lib/home/ProfilePage.dart b/lib/home/ProfilePage.dart index a4a805e..ea02ec9 100644 --- a/lib/home/ProfilePage.dart +++ b/lib/home/ProfilePage.dart @@ -3,7 +3,6 @@ import 'dart:io'; import 'package:chat/home/InfoList.dart'; import 'package:chat/home/fans_page.dart'; import 'package:chat/home/goddess_hot.dart'; -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'; @@ -11,7 +10,6 @@ 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'; import 'package:chat/utils/conversation_table.dart'; import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/msgHandler.dart'; @@ -449,6 +447,9 @@ class _ProfilePageState extends State data['sign'] = TokenMgr().getSign(data); Response res = await HttpUtil().post('user/personal/album', data: data); + if (res == null) { + return; + } Map resData = res.data; if (resData['code'] == 0) { imgList = resData['data'] == null ? [] : resData['data']; @@ -1147,22 +1148,40 @@ class _ProfilePageState extends State top: 20, child: InkWell( onTap: () async { + Map data = { + "userid": UserData().basicInfo.userId, + "type": 0, + "followUserId": userInfo.userId, + }; + data['sign'] = TokenMgr().getSign(data); if (!userInfo.isLike) { - HttpUtil().setLove(userInfo.userId, () { + Response res = await HttpUtil().post( + 'userfollow/follow/insert', + data: data, + isShowLoading: true); + Map resData = res.data; + if (resData['code'] == 0) { MessageMgr().emit('refresh_love_list', {'UserId': userInfo.userId, 'flag': 0}); setState(() { userInfo.isLike = true; }); - }); + showToast(resData['msg']); + } } else { - HttpUtil().cancleLove(userInfo.userId, () { + Response res = await HttpUtil().post( + 'userfollow/follow/cancel', + data: data, + isShowLoading: true); + Map resData = res.data; + if (resData['code'] == 0) { MessageMgr().emit('refresh_love_list', {'UserId': userInfo.userId, 'flag': 2}); setState(() { userInfo.isLike = false; }); - }); + showToast(resData['msg']); + } } }, child: Container( @@ -1426,10 +1445,20 @@ class _ProfilePageState extends State context, I18n.of(context).blacklist_choose, I18n.of(context).determine, () async { Navigator.pop(context); + Map data = { + "userid": UserData().basicInfo.userId, + "type": 1, + "followUserId": userInfo.userId, + }; + data['sign'] = TokenMgr().getSign(data); - HttpUtil().blackUser(userInfo.userId, () { + Response res = + await HttpUtil().post('userfollow/follow/insert', data: data); + Map resData = res.data; + showToast(resData['msg']); + if (resData['code'] == 0) { isblack = true; - }); + } }); } @@ -2148,25 +2177,19 @@ class _ProfilePageState extends State showDivider: false, showRightIcon: false, onPressed: () async { - CustomUI.buildOneConfirm( - context, - I18n.of(context).confrim_recovery, - I18n.of(context).determine, () async { - Map data = { - "userId": UserData().basicInfo.userId, - }; - data['sign'] = TokenMgr().getSign(data); - - Response res = await HttpUtil().post('user/recover/photos', - data: data, isShowLoading: true); - Map resData = res.data; - if (resData['code'] == 0) { + Map data = { + "userId": UserData().basicInfo.userId, + }; + data['sign'] = TokenMgr().getSign(data); + + Response res = + await HttpUtil().post('user/recover/photos', data: data); + Map resData = res.data; + if (resData['code'] == 0) { showToast(resData['msg']); - Navigator.of(context).pop(); - userInfo.burnNum = 0; - setState(() {}); - } - }); + userInfo.burnNum = 0; + setState(() {}); + } }, ), decoration: BoxDecoration( @@ -2434,11 +2457,24 @@ class _ProfilePageState extends State ), onTap: isblack ? () async { - HttpUtil().cancleBlackUser( - userInfo.userId, () { + Map data = { + "userid": + UserData().basicInfo.userId, + "type": 1, + "followUserId": userInfo.userId, + }; + data['sign'] = + TokenMgr().getSign(data); + + Response res = await HttpUtil().post( + 'userfollow/follow/cancel', + data: data); + Map resData = res.data; + if (resData['code'] == 0) { Navigator.of(context).pop(); isblack = false; - }); + showToast(resData['msg']); + } } : _buildConfirmBlack, ), @@ -2655,16 +2691,6 @@ class _ProfilePageState extends State return; } - if (BlacklistMgr.isBlaklistMe(userInfo.userId)) { - showToast(I18n.of(context).you_are_blaklisted); - return; - } - - if (BlacklistMgr.isInMyblaklist(userInfo.userId)) { - showToast(I18n.of(context).reject_message); - return; - } - //对方关闭陌生人消息,则提示 if (!userInfo.isCanStrangerNews) { showToast(I18n.of(context).stranger_close_tips); diff --git a/lib/home/ProgramDetail.dart b/lib/home/ProgramDetail.dart index 36ffc4e..8402d40 100644 --- a/lib/home/ProgramDetail.dart +++ b/lib/home/ProgramDetail.dart @@ -111,7 +111,7 @@ class _ProgramDetailPageState extends State { @override Widget build(BuildContext context) { Widget appBar = new AppBar( - //backgroundColor: AppColors.NewAppbarBgColor, + backgroundColor: AppColors.NewAppbarBgColor, title: new Text( isProgram ? I18n.of(context).program_details @@ -119,14 +119,13 @@ class _ProgramDetailPageState extends State { textScaleFactor: 1.0, style: TextStyle(color: AppColors.NewAppbarTextColor), ), - elevation: 1, leading: CustomUI.buildCustomLeading(context), centerTitle: true, ); var content = new Scaffold( key: registKey, appBar: appBar, - //backgroundColor: Colors.white, + backgroundColor: Colors.white, body: SafeArea( child: Center( child: Container( @@ -214,7 +213,7 @@ class _ProgramDetailPageState extends State { } } - double fontSize = 14; + double fontSize = 13.5; //1.不是发布者 //1.1是评论者则没有选项 @@ -553,8 +552,7 @@ class _ProgramDetailPageState extends State { list.add(button); } return Container( - padding: EdgeInsets.only(left: 23, top: 10, right: 8, bottom: 10), - color: Colors.white, + margin: EdgeInsets.only(left: 23, top: 10, right: 8, bottom: 10), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: list, diff --git a/lib/home/SearchPage.dart b/lib/home/SearchPage.dart index e110fc1..5272dd2 100644 --- a/lib/home/SearchPage.dart +++ b/lib/home/SearchPage.dart @@ -175,7 +175,7 @@ class _SearchPageState extends State { child: Stack( children: [ SmartRefresher( - enablePullDown: list.length > 0, + enablePullDown: true, enablePullUp: true, header: MaterialClassicHeader(), footer: CustomUI.buildLoadingFooter(), diff --git a/lib/home/WhiteAndBlackList.dart b/lib/home/WhiteAndBlackList.dart index 4a902c2..474f160 100644 --- a/lib/home/WhiteAndBlackList.dart +++ b/lib/home/WhiteAndBlackList.dart @@ -164,7 +164,17 @@ class _WhiteAndBlackPageState extends State { Expanded(child: Container()), InkWell( onTap: () async { - HttpUtil().cancleBlackUser(userInfo.userId, () { + var data = { + "userid": UserData().basicInfo.userId, + "type": 1, + "followUserId": userInfo['FollowUserId'], + }; + data['sign'] = TokenMgr().getSign(data); + + Response res = await HttpUtil().post('userfollow/follow/cancel', + data: data, isShowLoading: true); + Map resData = res.data; + if (resData['code'] == 0) { for (int i = 0; i < list.length; i++) { if (list[i]['FollowUserId'] == userInfo['FollowUserId']) { setState(() { @@ -173,7 +183,8 @@ class _WhiteAndBlackPageState extends State { break; } } - }); + showToast(resData['msg']); + } }, child: Container( padding: EdgeInsets.symmetric(vertical: 5, horizontal: 10.5), diff --git a/lib/home/create_group_view.dart b/lib/home/create_group_view.dart index ea157bf..1ae9c1d 100644 --- a/lib/home/create_group_view.dart +++ b/lib/home/create_group_view.dart @@ -510,7 +510,7 @@ class _CreateGroupPageState extends State { actions: [ InkWell( child: Padding( - padding: EdgeInsets.only(right: 12, top: 14, bottom: 14), + padding: EdgeInsets.only(right: 15, top: 14, bottom: 14), child: Consumer( builder: (context, counter, child) => Container( decoration: BoxDecoration( @@ -525,7 +525,7 @@ class _CreateGroupPageState extends State { ? Colors.red : const Color(0xFF3875E9)), ), - padding: EdgeInsets.symmetric(horizontal: 10), + padding: EdgeInsets.symmetric(horizontal: 18), alignment: Alignment.center, child: fixedText( (widget.pageType == diff --git a/lib/home/daily_bonus_page.dart b/lib/home/daily_bonus_page.dart index 8492317..d9c875d 100644 --- a/lib/home/daily_bonus_page.dart +++ b/lib/home/daily_bonus_page.dart @@ -526,8 +526,8 @@ class DailyBouusState extends State with SingleTickerProviderStateMixin { height: 37, child: Image.asset( R.assetsImagesImgFyj, - width: needAnimate ? animation.value * 17 : 17, - height: needAnimate ? animation.value * 17 : 17, + width: needAnimate ? animation.value * 24 : 24, + height: needAnimate ? animation.value * 24 : 24, ), decoration: BoxDecoration( color: Color(isEnough ? 0xff2D81FF : 0xffCBCBCB), diff --git a/lib/home/forward_view.dart b/lib/home/forward_view.dart new file mode 100644 index 0000000..ff4bf1a --- /dev/null +++ b/lib/home/forward_view.dart @@ -0,0 +1,135 @@ +import 'package:chat/data/chat_data_mgr.dart'; +import 'package:chat/data/constants.dart'; +import 'package:chat/data/group_data_mgr.dart'; +import 'package:chat/generated/i18n.dart'; +import 'package:chat/home/group_item_widget.dart'; +import 'package:chat/home/last_chat_record_widget.dart'; +import 'package:chat/models/ChatMsg.dart'; +import 'package:chat/models/group_info_model.dart'; +import 'package:chat/utils/CustomUI.dart'; +import 'package:chat/utils/receive_share_file.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + + +class ForwardPage extends StatefulWidget { + final MsgModel forwardMsg; + ForwardPage(this.forwardMsg); + + @override + State createState() { + + return ForwardPageState(); + } +} + +class ForwardPageState extends State + with SingleTickerProviderStateMixin { + ScrollController _scrollController = ScrollController(); + + List groupList = []; + var lastMsgList = ChatDataMgr().lastMsgProvider.lastMsgList; + + TabController tabCtrl; + + @override + void initState() { + super.initState(); + + tabCtrl = TabController(length: 2, vsync: this); + groupList = GroupInfoMgr().groupInfoList; + if (groupList.length == 0) { + Future.delayed(Duration(seconds: 3), () { + setState(() { + groupList = GroupInfoMgr().groupInfoList; + }); + }); + } + } + + @override + Widget build(BuildContext context) { + Widget appBar = new AppBar( + backgroundColor: AppColors.NewAppbarBgColor, + title: new Text( + '转发到', + style: TextStyle(color: AppColors.NewAppbarTextColor), + textScaleFactor: 1.0, + ), + leading: CustomUI.buildCustomLeading(context), + centerTitle: true, + bottom: PreferredSize( + preferredSize: Size.fromHeight(28), + child: Container( + padding: EdgeInsets.only(left: 2), + decoration: BoxDecoration( + color: Constants.LightGreyBackgroundColor, + border: Border(bottom: BorderSide(color: Color(0xffeaeaea)))), + alignment: Alignment.centerLeft, + child: TabBar( + isScrollable: true, + indicatorPadding: EdgeInsets.only(left: 9, right: 9), + tabs: [ + Container( + margin: EdgeInsets.only(right: 4), + child: + Text(I18n.of(context).text_chat, textScaleFactor: 1.0), + ), + Container( + margin: EdgeInsets.only(right: 4), + child: Text(I18n.of(context).group_chat, + textScaleFactor: 1.0)), + ], + controller: tabCtrl, + ), + ))); + + return Material( + child: SafeArea( + child: Scaffold( + appBar: appBar, + body: TabBarView( + children: [ + LastChatPage( + needRobot: false, + enterType: 2, + enterContent: widget.forwardMsg, + ), + + ///群聊 + groupList.length == 0 + ? Container() + : Container( + child: ListView.builder( + controller: _scrollController, + itemBuilder: (BuildContext context, int index) { + var info = groupList[index]; + return GroupItem( + ValueKey(info), + groupInfoModel: info, + enterType: 2, + enterContent: widget.forwardMsg, + ); + }, + itemCount: groupList.length, + )) + ], + controller: tabCtrl, + ), + ), + ), + ); + +// return SafeArea(child: Scaffold(body: FileReaderView( +// filePath: widget.filePath, +// ),)); + } + + @override + void dispose() { + + super.dispose(); + ReceiveShareFile.tempFilePath = null; + tabCtrl.dispose(); + } +} diff --git a/lib/home/friend_page.dart b/lib/home/friend_page.dart index 7afc52f..c99ff4e 100644 --- a/lib/home/friend_page.dart +++ b/lib/home/friend_page.dart @@ -215,6 +215,10 @@ class _FriendPageState extends State { Response res = await HttpUtil().post('friendship/newFriends/record', data: data); + + if (res == null) { + return; + } var resData = res.data; if (resData['code'] == 0) { if (resData['data'] != null) { diff --git a/lib/home/homeMain.dart b/lib/home/homeMain.dart index bace6b7..6b32923 100644 --- a/lib/home/homeMain.dart +++ b/lib/home/homeMain.dart @@ -12,7 +12,7 @@ import 'package:chat/utils/LoadingDialog.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/TokenMgr.dart'; import 'package:chat/utils/app_navigator.dart'; -import 'package:chat/utils/file_transfer_page.dart'; +import 'package:chat/utils/file_preview_local.dart'; import 'package:chat/utils/local_notification_util.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/receive_share_file.dart'; @@ -256,7 +256,7 @@ class _HomeMainState extends State { Navigator.of(LoadingManage.context).push( new MaterialPageRoute( builder: (context) { - return FileTransferPage(data); + return FilePreview(data); }, ), ); diff --git a/lib/home/last_chat_item.dart b/lib/home/last_chat_item.dart index 112d3ac..c9a1794 100644 --- a/lib/home/last_chat_item.dart +++ b/lib/home/last_chat_item.dart @@ -41,8 +41,6 @@ class _LastChatItemState extends State { lastMessageModel = widget.lastMessageModel; initUserInfo(); -// initUserInfo(); -// initUserInfo(); MessageMgr().on('UpdateUserInfo', msgUpdateUserInfo); } @@ -162,22 +160,5 @@ class _LastChatItemState extends State { enterType: widget.enterType, enterContent: widget.enterContent); }, ); - - // FutureBuilder( - // future: _friendInfoFuture, - // builder: (BuildContext context, AsyncSnapshot snapshot) { - // if (snapshot.connectionState == ConnectionState.done) { - // if (snapshot.hasError) { - // return Container(); - // } else { - // UserInfo friendInfo = snapshot.data; - // if (friendInfo == null) { - // return Container(); - // } - - // } else { - // return Container(); - // } - // }); } } diff --git a/lib/home/last_chat_record_widget.dart b/lib/home/last_chat_record_widget.dart index 4babc33..a488e66 100644 --- a/lib/home/last_chat_record_widget.dart +++ b/lib/home/last_chat_record_widget.dart @@ -17,7 +17,7 @@ import 'package:permission_handler/permission_handler.dart'; class LastChatPage extends StatefulWidget { final bool needRobot; - final int enterType; // 0默认 1图片 + final int enterType; // 0默认 1图片 2转发消息 final dynamic enterContent; LastChatPage({this.needRobot = true, this.enterType = 0, this.enterContent}); @@ -110,7 +110,7 @@ class _LastChatPageState extends State { : Container(), NetStateWidget(), widget.needRobot ? _translateRobot() : Container(), - //_CompanyServer(), + _CompanyServer(), lastMsgList.length == 0 ? _emptyContent() : _chatRecordsList(lastMsgList) diff --git a/lib/home/money_detail.dart b/lib/home/money_detail.dart index ff9d630..7e006bd 100644 --- a/lib/home/money_detail.dart +++ b/lib/home/money_detail.dart @@ -8,7 +8,6 @@ import 'package:chat/data/conversation.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/home/InfoList.dart'; import 'package:chat/home/ProfilePage.dart'; -import 'package:chat/home/rich_title.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/TokenMgr.dart'; diff --git a/lib/home/my_qr.dart b/lib/home/my_qr.dart index 4e0b7d5..fcf6292 100644 --- a/lib/home/my_qr.dart +++ b/lib/home/my_qr.dart @@ -89,15 +89,12 @@ class MyQr extends StatelessWidget { children: [ Row( children: [ - Container( - constraints: BoxConstraints(maxWidth: 170), - child: Text(name, - textScaleFactor: 1.0, - overflow: TextOverflow.ellipsis, - style: TextStyle( - color: Constants.BlackTextColor, - fontWeight: FontWeight.w500, - fontSize: 16))), + Text(name, + textScaleFactor: 1.0, + style: TextStyle( + color: Constants.BlackTextColor, + fontWeight: FontWeight.w500, + fontSize: 16)), SizedBox(width: 5), Icon( IconData( diff --git a/lib/main.dart b/lib/main.dart index 39da0ac..e051b34 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -22,7 +22,6 @@ import 'package:chat/utils/local_notification_util.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/receive_share_file.dart'; import 'package:chat/utils/screen.dart'; -import 'package:chat/utils/screen_shot.dart'; import 'package:chat/utils/sound_util.dart'; import 'package:chat/utils/sp_utils.dart'; import 'package:chat/utils/sql_util.dart'; @@ -236,11 +235,6 @@ class _MyAppState extends State with WidgetsBindingObserver { I18n.onLocaleChanged = onLocaleChange; WidgetsBinding.instance.addObserver(this); ReceiveShareFile.init(); - - - ScreenShot.getFileStream(); - - } isAvailableAppleSignIn() async { @@ -294,9 +288,6 @@ class _MyAppState extends State with WidgetsBindingObserver { MessageMgr().emit( 'Receive AudioChat Request', MsgHandler.audioChatRequestFriendId); } - - - break; case AppLifecycleState.paused: // 应用程序不可见,后台 print('切换到后台'); diff --git a/lib/utils/ChargeMoney.dart b/lib/utils/ChargeMoney.dart index 9551063..e380833 100644 --- a/lib/utils/ChargeMoney.dart +++ b/lib/utils/ChargeMoney.dart @@ -219,7 +219,7 @@ class PayWayContentState extends State { webPage: url, title: '点我代付[${widget.money}元]', thumbnail: - "http://datasm.chengyouhd.com/Upload/default/icon120.png", + "http://testcyhd.chengyouhd.com/Upload/default/ic_launcher.png", description: '[${UserData().basicInfo.nickName}]正在购买H币,点击帮我支付吧'); fluwx.share(model); } diff --git a/lib/utils/CustomUI.dart b/lib/utils/CustomUI.dart index 08f1919..6de7748 100644 --- a/lib/utils/CustomUI.dart +++ b/lib/utils/CustomUI.dart @@ -1109,27 +1109,23 @@ class CustomUI { if (height == null) { height = MediaQuery.of(context).size.height * 0.8; } - return InkWell( - onTap: null, + return Container( + width: MediaQuery.of(context).size.width, + height: height, + alignment: Alignment.topCenter, child: Container( - width: MediaQuery.of(context).size.width, - height: height, - alignment: Alignment.topCenter, - child: Container( - width: 40, - height: 40, - margin: EdgeInsets.only(top: 20), - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.white, - boxShadow: [ - BoxShadow(blurRadius: 3.0, color: Colors.black26) - ]), - child: new CircularProgressIndicator( - strokeWidth: 2, - ), - ))); + width: 40, + height: 40, + margin: EdgeInsets.only(top: 20), + padding: EdgeInsets.all(10), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.white, + boxShadow: [BoxShadow(blurRadius: 3.0, color: Colors.black26)]), + child: new CircularProgressIndicator( + strokeWidth: 2, + ), + )); } static Widget buildLoadingFooter() { diff --git a/lib/utils/HttpUtil.dart b/lib/utils/HttpUtil.dart index 41070f2..a4636ba 100644 --- a/lib/utils/HttpUtil.dart +++ b/lib/utils/HttpUtil.dart @@ -17,7 +17,6 @@ import 'package:chat/proto/all.pbserver.dart'; import 'package:chat/utils/LoadingDialog.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/NetUtil.dart'; -import 'package:chat/utils/blacklist_mgr.dart'; import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/image_util.dart'; import 'package:chat/utils/local_notification_util.dart'; @@ -282,15 +281,6 @@ class HttpUtil { print('用户信息resData $resData'); if (resData['code'] == 0) { var info = UserInfo.fromJson(resData['data']); - - info.isBlackened - ? BlacklistMgr.addBlackListMe(info.userId) - : BlacklistMgr.removeBalckListMe(info.userId); - - info.isBlackList - ? BlacklistMgr.addMyBlackList(info.userId) - : BlacklistMgr.removeMyBalckList(info.userId); - friendCache[friendId] = info; FriendListMgr().updateFriendInfo(info); UserInfoTable().insertUser(info); @@ -353,15 +343,6 @@ class HttpUtil { if (resData['code'] == 0) { var info = UserInfo.fromJson(resData['data']); - - info.isBlackened - ? BlacklistMgr.addBlackListMe(info.userId) - : BlacklistMgr.removeBalckListMe(info.userId); - - info.isBlackList - ? BlacklistMgr.addMyBlackList(info.userId) - : BlacklistMgr.removeMyBalckList(info.userId); - FriendListMgr().updateFriendInfo(info); friendCache[info.userId] = info; MessageMgr().emit('UpdateUserInfo', info); @@ -1203,8 +1184,8 @@ class HttpUtil { //根据经纬度获取用户国家城市 getAddress(double lon, double lat) async { Map data = { - "lon": lon.toString(), - "lat": lat.toString(), + "lon": lon, + "lat": lat, }; data['sign'] = TokenMgr().getSign(data); data['language'] = UserData().language; @@ -1244,13 +1225,13 @@ class HttpUtil { } } - //根据经纬度更新当前城市 + //根据经纬度获取用户国家城市 changeCurrentCity(double lon, double lat, callback) async { if (UserData().basicInfo.userId == null) return; Map data = { "userId": UserData().basicInfo.userId, - "lon": lon.toString(), - "lat": lat.toString(), + "lon": lon, + "lat": lat, }; data['sign'] = TokenMgr().getSign(data); @@ -1281,80 +1262,6 @@ class HttpUtil { } } - //拉黑用户 - blackUser(int userId, callback) async { - Map data = { - "userid": UserData().basicInfo.userId, - "type": 1, - "followUserId": userId, - }; - data['sign'] = TokenMgr().getSign(data); - - Response res = - await HttpUtil().post('userfollow/follow/insert', data: data); - Map resData = res.data; - showToast(resData['msg']); - if (resData['code'] == 0) { - BlacklistMgr.addMyBlackList(userId); - callback(); - } - } - - //取消拉黑用户 - cancleBlackUser(int userId, callback) async { - Map data = { - "userid": UserData().basicInfo.userId, - "type": 1, - "followUserId": userId, - }; - data['sign'] = TokenMgr().getSign(data); - - Response res = await HttpUtil() - .post('userfollow/follow/cancel', data: data, isShowLoading: true); - Map resData = res.data; - showToast(resData['msg']); - if (resData['code'] == 0) { - BlacklistMgr.removeMyBalckList(userId); - callback(); - } - } - - //收藏用户 - setLove(int userId, callback) async { - Map data = { - "userid": UserData().basicInfo.userId, - "type": 0, - "followUserId": userId, - }; - data['sign'] = TokenMgr().getSign(data); - - Response res = await HttpUtil() - .post('userfollow/follow/insert', data: data, isShowLoading: true); - Map resData = res.data; - if (resData['code'] == 0) { - showToast(resData['msg']); - callback(); - } - } - - //取消收藏用户 - cancleLove(int userId, callback) async { - Map data = { - "userid": UserData().basicInfo.userId, - "type": 0, - "followUserId": userId, - }; - data['sign'] = TokenMgr().getSign(data); - - Response res = await HttpUtil() - .post('userfollow/follow/cancel', data: data, isShowLoading: true); - Map resData = res.data; - if (resData['code'] == 0) { - showToast(resData['msg']); - callback(); - } - } - //向企业服务助手提交信息 Future commitInfoToCompany(MsgModel msgModel) async { Map data = { diff --git a/lib/utils/MessageBox.dart b/lib/utils/MessageBox.dart index 4360524..710ed07 100644 --- a/lib/utils/MessageBox.dart +++ b/lib/utils/MessageBox.dart @@ -85,7 +85,17 @@ class _MessageBoxState extends State { ), ); } else if (str == 'black') { - HttpUtil().blackUser(userId, () {}); + var data = { + "userid": UserData().basicInfo.userId, + "type": 1, + "followUserId": userId, + }; + data['sign'] = TokenMgr().getSign(data); + + Response res = + await HttpUtil().post('userfollow/follow/insert', data: data); + Map resData = res.data; + showToast(resData['msg']); } else if (str == 'noContent') { var data = { "userId": UserData().basicInfo.userId, @@ -481,7 +491,7 @@ class _MessageBoxState extends State { _buildTimebox(data), _buildImgSet(data), _buildImgList(data), - widget.isDetail ? Container() : _buildDivder(), + _buildDivder(), _buildIconButtonList(data), //_buildContent(), ], diff --git a/lib/utils/NetUtil.dart b/lib/utils/NetUtil.dart index 32a8d0e..16c4c62 100644 --- a/lib/utils/NetUtil.dart +++ b/lib/utils/NetUtil.dart @@ -11,7 +11,6 @@ import 'package:chat/generated/i18n.dart'; import 'package:chat/proto/all.pbserver.dart'; import 'package:chat/utils/LoadingDialog.dart'; import 'package:chat/utils/net_state_util.dart'; -import 'package:chat/utils/screen.dart'; import 'package:chat/utils/upload_util.dart'; import 'package:oktoast/oktoast.dart'; import 'package:protobuf/protobuf.dart'; @@ -61,10 +60,7 @@ class NetWork { Timer heartTimer; Timer sendTimer; Timer connectServerTimer; //尝试连接服务器 - Timer loginTimer; //登录 - - // 计时器 - Timer iosBgTimer; //登录计时器 + Timer loginTimer; //登录计时器 bool isInit = false; @@ -82,6 +78,9 @@ class NetWork { HttpUtil().post('/service/config', data: data).then((res) { print('获取聊天服务器地址成功'); res = json.decode(res.toString()); + if (res == null) { + return; + } if (res['code'] == 0) { var config = res['data'][0]; @@ -304,43 +303,37 @@ class NetWork { } + reallySingOut() { + print('用户登出'); + //清缓存 - reallyClose() { + isNormalClose = true; + reallyClose(); + } - if(iosBgTimer==null){ - debugPrint('#### ios bg 没有计时器--计时器你启动'); - iosBgTimer = Timer(Duration(seconds: 20), () async{ - debugPrint('#### ios bg ios后台关闭socket连接'); - isNormalClose=true; - isConnecting = false; - isConnect = false; - isLogin = false; - heartOutCount = 0; - sendTimer?.cancel(); - heartTimer?.cancel(); + reallyClose() async{ + print('清除连接状态'); + isNormalClose=true; + isConnecting = false; + isConnect = false; + isLogin = false; + heartOutCount = 0; + sendTimer?.cancel(); + heartTimer?.cancel(); - loginTimer?.cancel(); - connectServerTimer?.cancel(); + loginTimer?.cancel(); + print('清除计时器'); + connectServerTimer?.cancel(); - if (channel != null) { - await channel.sink.close(); - channel = null; - } - }); - }else{ - debugPrint('#### ios bg 已有计时器'); + if (channel != null) { + var result = await channel.sink.close(); + print('result: $result'); + channel = null; } - - - - } checkConnect() { - debugPrint(' ios bg 取消计时器'); - iosBgTimer?.cancel(); - if (isInit && !isConnect && !isConnecting) { reconnect(); } else { diff --git a/lib/utils/TempUserCard.dart b/lib/utils/TempUserCard.dart index 1e78dd3..c435ae8 100644 --- a/lib/utils/TempUserCard.dart +++ b/lib/utils/TempUserCard.dart @@ -38,29 +38,31 @@ class TempUserCard extends StatelessWidget { TempUserCard( {Key key, - this.userName, - this.isReal: false, - this.city, - this.age, - this.constellation, - this.professional, - this.isOnline, - this.distance, - this.userId, - this.isLove: false, - this.sex, - this.headUrl: '', - this.payImg: false, - this.imgNum: 0, - this.isHidden: false, - this.member: 0, - this.hiddenDistince: false, - this.nameSize = 8, - this.isBalck: false}) + this.userName, + this.isReal: false, + this.city, + this.age, + this.constellation, + this.professional, + this.isOnline, + this.distance, + this.userId, + this.isLove: false, + this.sex, + this.headUrl: '', + this.payImg: false, + this.imgNum: 0, + this.isHidden: false, + this.member: 0, + this.hiddenDistince: false, + this.nameSize = 8, + this.isBalck: false}) : super(key: key); + @override Widget build(BuildContext context) { + bool isVIP = member > 0; bool isSVIP = member == 2; @@ -70,27 +72,27 @@ class TempUserCard extends StatelessWidget { return Stack( children: [ Container( - height: height - 40, - width: height - 40, + height: height-40, + width: height-40, child: ClipRRect( borderRadius: BorderRadius.only( topLeft: Radius.circular(15), topRight: Radius.circular(15)), child: headUrl == '' || headUrl == null ? Image.asset( - Constants.DefaultHeadImgUrl, - width: height - 40, - height: height - 40, - ) + Constants.DefaultHeadImgUrl, + width: height-40, + height: height-40, + ) : CachedNetworkImage( - imageUrl: headUrl, - placeholder: (context, url) => Image.asset( - Constants.DefaultHeadImgUrl, - width: height - 40, - height: height - 40, - ), - fit: BoxFit.cover, - )), + imageUrl: headUrl, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + width: height-40, + height: height-40, + ), + fit: BoxFit.cover, + )), ), Positioned( left: 0, @@ -100,15 +102,16 @@ class TempUserCard extends StatelessWidget { width: 54, decoration: BoxDecoration( color: Colors.black54, - borderRadius: - BorderRadius.only(topRight: Radius.circular(10))), + borderRadius: BorderRadius.only( + + topRight: Radius.circular(10))), child: Row( //mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Padding( padding: EdgeInsets.only(left: 6), child: - Icon(Icons.image, size: 15, color: Colors.white)), + Icon(Icons.image, size: 15, color: Colors.white)), Padding( padding: EdgeInsets.only(left: 5, top: 2), child: fixedText(imgNum.toString(), @@ -129,25 +132,87 @@ class TempUserCard extends StatelessWidget { fontSize: 15), isReal && sex == 2 ? Container( - margin: EdgeInsets.only(left: 5), - padding: - EdgeInsets.only(top: 2, bottom: 2, left: 5, right: 5), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Constants.PurpleBackgroundColor, - ), - child: fixedText('Real', fontSize: 8, color: Colors.white)) + margin: EdgeInsets.only(left: 5), + padding: + EdgeInsets.only(top: 2, bottom: 2, left: 5, right: 5), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Constants.PurpleBackgroundColor, + ), + child: fixedText('Real', fontSize: 8, color: Colors.white)) : Container(), isVIP && sex == 1 ? Container( - margin: EdgeInsets.only(left: 5), - child: isSVIP ? Constants.svipIcon : Constants.vipIcon) + margin: EdgeInsets.only(left: 5), + child: isSVIP ? Constants.svipIcon : Constants.vipIcon) : Container(), ], ); } + // void _selectValue(str) async { + // if (str == 'collection') { + // Map data = { + // "userid": UserData().basicInfo.userId, + // "type": 0, + // "followUserId": this.userId, + // }; + // data['sign'] = TokenMgr().getSign(data); + // Response res = await HttpUtil() + // .post('userfollow/follow/insert', data: data, isShowLoading: true); + // Map resData = res.data; + // if (resData['code'] == 0) { + // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 0}); + // showToast(resData['msg']); + // } + // } else if (str == 'cancleCollection') { + // Map data = { + // "userid": UserData().basicInfo.userId, + // "type": 0, + // "followUserId": this.userId, + // }; + // data['sign'] = TokenMgr().getSign(data); + // Response res = await HttpUtil() + // .post('userfollow/follow/cancel', data: data, isShowLoading: true); + // Map resData = res.data; + // if (resData['code'] == 0) { + // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 2}); + // showToast(resData['msg']); + // } + // } else if (str == 'black') { + // Map data = { + // "userid": UserData().basicInfo.userId, + // "type": 1, + // "followUserId": this.userId, + // }; + // data['sign'] = TokenMgr().getSign(data); + + // Response res = + // await HttpUtil().post('userfollow/follow/insert', data: data); + // Map resData = res.data; + // showToast(resData['msg']); + // if (resData['code'] == 0) { + // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 1}); + // } + // } else if (str == 'cancleBlack') { + // var data = { + // "userid": UserData().basicInfo.userId, + // "type": 1, + // "followUserId": this.userId, + // }; + // data['sign'] = TokenMgr().getSign(data); + + // Response res = + // await HttpUtil().post('userfollow/follow/cancel', data: data); + // Map resData = res.data; + // showToast(resData['msg']); + // if (resData['code'] == 0) { + // MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 2}); + // } + // } + // } + //距离、在线以及相册 Widget otherWidget() { var greyColor = const Color(0xFFB2B2B2); @@ -158,8 +223,8 @@ class TempUserCard extends StatelessWidget { title: hiddenDistince ? I18n.of(context).secrecy : (UserData().hasLocationPermission - ? WebData().getDistanceString(distance) - : I18n.of(context).unknown), + ? WebData().getDistanceString(distance) + : I18n.of(context).unknown), titleColor: greyColor, isDivider: true), InfoTile( @@ -168,24 +233,24 @@ class TempUserCard extends StatelessWidget { isDivider: payImg || isHidden), isHidden ? InfoTile( - icon: IconData(0xe645, fontFamily: 'iconfont'), - iconHeight: 22, - title: I18n.of(context).application_view, - titleColor: greyColor, - isDivider: false, - onTap: () { - print('click'); - }) + icon: IconData(0xe645, fontFamily: 'iconfont'), + iconHeight: 22, + title: I18n.of(context).application_view, + titleColor: greyColor, + isDivider: false, + onTap: () { + print('click'); + }) : Container(), payImg ? InfoTile( - icon: IconData(0xe632, fontFamily: Constants.IconFontFamily), - title: I18n.of(context).paid_photo, - titleColor: greyColor, - isDivider: false, - onTap: () { - print('click'); - }) + icon: IconData(0xe632, fontFamily: Constants.IconFontFamily), + title: I18n.of(context).paid_photo, + titleColor: greyColor, + isDivider: false, + onTap: () { + print('click'); + }) : Container(), ], ); @@ -210,148 +275,125 @@ class TempUserCard extends StatelessWidget { ), ); }, - child: Container( - alignment: Alignment.center, - color: AppColors.NewAppbarBgColor, - width: Screen.width, - child: Container( - width: Screen.width - 40, - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - SizedBox( - height: 23, - ), - headImg(), - Container( - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.only( - bottomLeft: Radius.circular(15), - bottomRight: Radius.circular(15))), - child: Column( - children: [ - Container( - //背景 - padding: EdgeInsets.only( - left: 15, right: 10, bottom: 14.5, top: 5), - child: Column( - children: [ - Stack( - children: [ - Row( - children: [ - //头像图片 - - //信息 - Container( - width: MediaQuery.of(context) - .size - .width - - 104, - child: Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisAlignment: - MainAxisAlignment.end, - children: [ - nameState(), //名字以及状态 - //用户的信息标记 - Padding( - padding: - EdgeInsets.only(top: 9)), - TempUserChips( - city: city, - age: age, - constellation: constellation, - professional: professional), - Padding( - padding: - EdgeInsets.only(top: 4)), - otherWidget(), - ], - )), - ], - ), - ], - ) - ], - )), - SizedBox( - height: 5, - ), - Container( - child: //赞 - sex == UserData().basicInfo.sex - ? InkWell( - onTap: () { - showToast(UserData().isMan() - ? I18n.of(context).not_love - : I18n.of(context).not_love2); - }, - child: Container( - width: 100, - height: 30, - decoration: BoxDecoration( - border: Border.all( - color: Color(0xFF878787), - width: 1), - borderRadius: - BorderRadius.circular(16)), - padding: EdgeInsets.only( - left: 15, - right: 15, - bottom: 5, - top: 5), - child: Row( - mainAxisAlignment: - MainAxisAlignment.center, - children: [ - Icon( - IconData( - 0xe625, - fontFamily: - Constants.IconFontFamily, - ), - size: 15, - color: Color(0xffB2B2B2), - ), - SizedBox( - width: 5, - ), - Text( - 'LOVE', - style: prefix0.TextStyle( - color: Color(0xffB2B2B2)), - ) - ], - ))) - : LoveToggle( - isActive: isLove, - onTap: (bool isActive) async { - if (isActive) { - HttpUtil().setLove(userId, () { - MessageMgr().emit('refresh_love_list', - {'UserId': userId, 'flag': 0}); - }); - } else { - HttpUtil().cancleLove(userId, () { - MessageMgr().emit('refresh_love_list', - {'UserId': userId, 'flag': 2}); - }); - } - }), - ), - SizedBox( - height: 15, - ), - ], - ), - ), - ], - ), - ), - )); + child: Container(alignment: Alignment.center,color: AppColors.NewAppbarBgColor,width: Screen.width,child: Container(width: Screen.width-40,child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + SizedBox(height: 23,), + headImg(), + + + Container(decoration: BoxDecoration(color: Colors.white,borderRadius: BorderRadius.only( + bottomLeft: Radius.circular(15), + bottomRight: Radius.circular(15))) ,child: Column(children: [ + Container( + //背景 + padding: EdgeInsets.only(left: 15,right: 10, bottom: 14.5,top: 5), + child: Column(children: [ + Stack( + children: [ + Row( + children: [ + //头像图片 + + //信息 + Container( + width: MediaQuery.of(context).size.width - 104, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + children: [ + nameState(), //名字以及状态 + //用户的信息标记 + Padding(padding: EdgeInsets.only(top: 9)), + TempUserChips( + city: city, + age: age, + constellation: constellation, + professional: professional), + Padding(padding: EdgeInsets.only(top: 4)), + otherWidget(), + ], + )), + ], + ), + + ], + ) + ],)), + SizedBox(height: 5,), + Container( + + child: //赞 + sex == UserData().basicInfo.sex + ? InkWell( + onTap: () { + showToast(UserData().isMan() + ? I18n.of(context).not_love + : I18n.of(context).not_love2); + }, + child: Container( + width: 100, + height: 30, + decoration: BoxDecoration(border: Border.all(color: Color(0xFF878787), width: 1),borderRadius: BorderRadius.circular(16)) , + padding: EdgeInsets.only( + left: 15, right: 15, bottom: 5,top: 5 ), + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ + Icon( + IconData( + 0xe625, + fontFamily: Constants.IconFontFamily, + ), + size: 15, + color: Color(0xffB2B2B2), + ), + SizedBox(width: 5,), + Text('LOVE',style: prefix0.TextStyle(color: Color(0xffB2B2B2)),) + ],))) + : LoveToggle(isActive: isLove,onTap: (bool isActive) async { + Map data = { + "userid": UserData().basicInfo.userId, + "type": 0, + "followUserId": this.userId, + }; + data['sign'] = TokenMgr().getSign(data); + if (isActive) { + Response res = await HttpUtil().post( + 'userfollow/follow/insert', + data: data, + isShowLoading: true); + Map resData = res.data; + showToast(resData['msg']); + if (resData['code'] == 0) { + MessageMgr().emit('refresh_love_list', + {'UserId': userId, 'flag': 0}); + showToast(resData['msg']); + } + } else { + Response res = await HttpUtil().post( + 'userfollow/follow/cancel', + data: data, + isShowLoading: true); + Map resData = res.data; + if (resData['code'] == 0) { + MessageMgr().emit('refresh_love_list', + {'UserId': userId, 'flag': 2}); + showToast(resData['msg']); + } + } + }), + ), + SizedBox(height: 15,), + + + + ],),), + + + + + + ], + ),),)); } } @@ -368,12 +410,12 @@ class InfoTile extends StatelessWidget { const InfoTile( {Key key, - this.title, - this.titleColor, - this.icon, - this.onTap, - this.iconHeight: TileHeight, - this.isDivider = false}) + this.title, + this.titleColor, + this.icon, + this.onTap, + this.iconHeight: TileHeight, + this.isDivider = false}) : super(key: key); @override diff --git a/lib/utils/UserCard.dart b/lib/utils/UserCard.dart index 90eab15..16d486e 100644 --- a/lib/utils/UserCard.dart +++ b/lib/utils/UserCard.dart @@ -277,16 +277,35 @@ class UserCard extends StatelessWidget { isActive: isLove, size: 16, onTap: (bool isActive) async { + Map data = { + "userid": UserData().basicInfo.userId, + "type": 0, + "followUserId": this.userId, + }; + data['sign'] = TokenMgr().getSign(data); if (isActive) { - HttpUtil().setLove(userId, () { + Response res = await HttpUtil().post( + 'userfollow/follow/insert', + data: data, + isShowLoading: true); + Map resData = res.data; + showToast(resData['msg']); + if (resData['code'] == 0) { MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 0}); - }); + showToast(resData['msg']); + } } else { - HttpUtil().cancleLove(userId, () { + Response res = await HttpUtil().post( + 'userfollow/follow/cancel', + data: data, + isShowLoading: true); + Map resData = res.data; + if (resData['code'] == 0) { MessageMgr().emit('refresh_love_list', {'UserId': userId, 'flag': 2}); - }); + showToast(resData['msg']); + } } }), right: 0, @@ -343,7 +362,7 @@ class InfoTile extends StatelessWidget { Container( alignment: Alignment.bottomCenter, constraints: BoxConstraints(minHeight: 17), - padding: EdgeInsets.only(right: 5, bottom: 1.5), + padding: EdgeInsets.only(right: 5,bottom: 1.5), child: Text(title, textScaleFactor: 1.0, style: TextStyle( diff --git a/lib/utils/app_navigator.dart b/lib/utils/app_navigator.dart index 041a561..7b6dfe1 100644 --- a/lib/utils/app_navigator.dart +++ b/lib/utils/app_navigator.dart @@ -10,6 +10,7 @@ import 'package:chat/home/ProfilePage.dart'; import 'package:chat/home/SearchPage.dart'; import 'package:chat/home/audio_chat_view.dart'; import 'package:chat/home/create_group_view.dart'; +import 'package:chat/home/forward_view.dart'; import 'package:chat/home/group_all_member.dart'; import 'package:chat/home/group_qr_view.dart'; import 'package:chat/home/homeMain.dart'; @@ -99,23 +100,36 @@ class AppNavigator { } //聊天 - static pushChatPage(BuildContext context, int friendId,{enterType=0,enterContent}) async { - if(enterType==1){ + static pushChatPage(BuildContext context, int friendId, + {enterType = 0, enterContent}) async { + if (enterType == 1) { Navigator.of(context).pop(context); } - AppNavigator.push(context, ChatPage(key: Key('Chat'), friendId: friendId,enterType: enterType,enterContent: enterContent,)); + AppNavigator.push( + context, + ChatPage( + key: Key('Chat'), + friendId: friendId, + enterType: enterType, + enterContent: enterContent, + )); } //群聊 - static pushGroupChatPage( - BuildContext context, GroupInfoModel groupInfoModel,{enterType=0,enterContent}) async { - - if(enterType==1){ + static pushGroupChatPage(BuildContext context, GroupInfoModel groupInfoModel, + {enterType = 0, enterContent}) async { + if (enterType == 1) { Navigator.of(context).pop(context); } - AppNavigator.defaultPush(context, - GroupChatPage(key: Key('GroupChat'), groupInfoModel: groupInfoModel,enterType: enterType,enterContent: enterContent,)); + AppNavigator.defaultPush( + context, + GroupChatPage( + key: Key('GroupChat'), + groupInfoModel: groupInfoModel, + enterType: enterType, + enterContent: enterContent, + )); } //客服 @@ -129,7 +143,7 @@ class AppNavigator { } //群聊二维码 - static pushGroupQrPage(BuildContext context,GroupInfoModel model) { + static pushGroupQrPage(BuildContext context, GroupInfoModel model) { AppNavigator.push(context, GroupQrPage(model)); } @@ -205,7 +219,7 @@ class AppNavigator { AppNavigator.push(context, TranslateRobotPage()); } - //进入反馈小助手页面 + //进入反馈小助手页面 static pushCompanyServerPage(BuildContext context) { AppNavigator.push(context, CompanyServerPage()); } @@ -215,5 +229,10 @@ class AppNavigator { BuildContext context, List friendList) { AppNavigator.push( context, CreateGroupPage(GroupOperatingPageType.CreateGroup, [], null)); +} + + //发起群聊界面 + static pushForwardPage(BuildContext context, MsgModel msg) { + AppNavigator.push(context, ForwardPage(msg)); } } diff --git a/lib/utils/file_preview_local.dart b/lib/utils/file_preview_local.dart new file mode 100644 index 0000000..b5b748a --- /dev/null +++ b/lib/utils/file_preview_local.dart @@ -0,0 +1,134 @@ +import 'package:chat/data/chat_data_mgr.dart'; +import 'package:chat/data/constants.dart'; +import 'package:chat/data/group_data_mgr.dart'; +import 'package:chat/generated/i18n.dart'; +import 'package:chat/home/group_item_widget.dart'; +import 'package:chat/home/last_chat_record_widget.dart'; +import 'package:chat/models/group_info_model.dart'; +import 'package:chat/utils/receive_share_file.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import 'CustomUI.dart'; + +class FilePreview extends StatefulWidget { + final String filePath; + FilePreview(this.filePath); + + @override + State createState() { + + return FilePreviewState(); + } +} + +class FilePreviewState extends State + with SingleTickerProviderStateMixin { + ScrollController _scrollController = ScrollController(); + + List groupList = []; + var lastMsgList = ChatDataMgr().lastMsgProvider.lastMsgList; + + TabController tabCtrl; + + @override + void initState() { + super.initState(); + + tabCtrl = TabController(length: 2, vsync: this); + groupList = GroupInfoMgr().groupInfoList; + if (groupList.length == 0) { + Future.delayed(Duration(seconds: 3), () { + setState(() { + groupList = GroupInfoMgr().groupInfoList; + }); + }); + } + } + + @override + Widget build(BuildContext context) { + Widget appBar = new AppBar( + backgroundColor: AppColors.NewAppbarBgColor, + title: new Text( + '发送图片到', + style: TextStyle(color: AppColors.NewAppbarTextColor), + textScaleFactor: 1.0, + ), + leading: CustomUI.buildCustomLeading(context), + centerTitle: true, + bottom: PreferredSize( + preferredSize: Size.fromHeight(28), + child: Container( + padding: EdgeInsets.only(left: 2), + decoration: BoxDecoration( + color: Constants.LightGreyBackgroundColor, + border: Border(bottom: BorderSide(color: Color(0xffeaeaea)))), + alignment: Alignment.centerLeft, + child: TabBar( + isScrollable: true, + indicatorPadding: EdgeInsets.only(left: 9, right: 9), + tabs: [ + Container( + margin: EdgeInsets.only(right: 4), + child: + Text(I18n.of(context).text_chat, textScaleFactor: 1.0), + ), + Container( + margin: EdgeInsets.only(right: 4), + child: Text(I18n.of(context).group_chat, + textScaleFactor: 1.0)), + ], + controller: tabCtrl, + ), + ))); + + return Material( + child: SafeArea( + child: Scaffold( + appBar: appBar, + body: TabBarView( + children: [ + LastChatPage( + needRobot: false, + enterType: 1, + enterContent: widget.filePath, + ), + + ///群聊 + groupList.length == 0 + ? Container() + : Container( + child: ListView.builder( + controller: _scrollController, + itemBuilder: (BuildContext context, int index) { + var info = groupList[index]; + return GroupItem( + ValueKey(info), + groupInfoModel: info, + enterType: 1, + enterContent: widget.filePath, + ); + }, + itemCount: groupList.length, + )) + ], + controller: tabCtrl, + ), + ), + ), + ); + +// return SafeArea(child: Scaffold(body: FileReaderView( +// filePath: widget.filePath, +// ),)); + } + + @override + void dispose() { + + super.dispose(); + ReceiveShareFile.tempFilePath = null; + tabCtrl.dispose(); + } +} diff --git a/lib/utils/local_notification_util.dart b/lib/utils/local_notification_util.dart index 95004a7..bbde75a 100644 --- a/lib/utils/local_notification_util.dart +++ b/lib/utils/local_notification_util.dart @@ -6,7 +6,6 @@ import 'package:chat/data/UserData.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/home/InfoList.dart'; import 'package:chat/home/ProgramDetail.dart'; -import 'package:chat/home/rich_title.dart'; import 'package:chat/models/received_notification.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; diff --git a/lib/utils/msgHandler.dart b/lib/utils/msgHandler.dart index 9358997..c73d791 100644 --- a/lib/utils/msgHandler.dart +++ b/lib/utils/msgHandler.dart @@ -12,7 +12,6 @@ import 'package:chat/models/ChatMsg.dart'; import 'package:chat/models/group_info_model.dart'; import 'package:chat/proto/all.pbserver.dart'; import 'package:chat/utils/NetUtil.dart'; -import 'package:chat/utils/blacklist_mgr.dart'; import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/group_member_model.dart'; import 'package:chat/utils/local_notification_util.dart'; @@ -218,6 +217,7 @@ class MsgHandler { print('消息包大小超过3M'); } + //本地文件为空或者等发送成功之后才可以发送 if (msg.localFile == null || msg.state >= MsgState.Uploaded) { Future.delayed(Duration(seconds: 60), () { if (msg.state != MsgState.SendingSuccess) { @@ -239,6 +239,7 @@ class MsgHandler { seq.targetId = curActiveSession; if (curActiveSession == 10000) { + seq.channelType = ChatChannelType.CSD; } else { seq.channelType = @@ -527,7 +528,12 @@ class MsgHandler { msgModel.state = MsgState.DownloadFailed; } } + + if (msgModel.sessionId == 10000 ) { + print('收到反馈小助手消息'); + } if (msgModel.sessionId == curActiveSession) { + MessageMgr().emit('New Chat Message', msgModel.sessionId); } } @@ -917,16 +923,6 @@ class MsgHandler { ), (route) => route == null); NetWork().singOut(); UserData().reset(); - break; - case 'blacklist': - String messageJson = map['message']; - Map messageMap = json.decode(messageJson); - if (messageMap['Status'] == 0) { - BlacklistMgr.addBlackListMe(messageMap['UserId']); - } else { - BlacklistMgr.removeBalckListMe(messageMap['UserId']); - } - break; } diff --git a/lib/utils/receive_share_file.dart b/lib/utils/receive_share_file.dart index efa46a4..5c304c0 100644 --- a/lib/utils/receive_share_file.dart +++ b/lib/utils/receive_share_file.dart @@ -9,6 +9,8 @@ class ReceiveShareFile { static List _sharedFiles; static String tempFilePath; + static int mLastClickTime = 0; + static final int TIME_INTERVAL = 3000; static void init() { // For sharing images coming from outside the app while the app is in the memory @@ -21,8 +23,12 @@ class ReceiveShareFile { // print('#### getfilePath ${value[0].path}'); if (currentIndex == 1) { - if (value != null && value.length > 0) { - MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, value[0].path); + int nowTime = DateTime.now().millisecondsSinceEpoch; + + if (nowTime - mLastClickTime > TIME_INTERVAL) { + if (value != null && value.length > 0) { + MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, value[0].path); + } } } else { // print("### 记录下来了1"); @@ -44,9 +50,14 @@ class ReceiveShareFile { // print('#### getfilePath ${value[0].path}'); if (currentIndex == 1) { - if (value != null && value.length > 0) { - MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, value[0].path); - } + int nowTime = DateTime.now().millisecondsSinceEpoch; + if (nowTime - mLastClickTime > TIME_INTERVAL) { + // do something + if (value != null && value.length > 0) { + MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, value[0].path); + mLastClickTime = nowTime; + } + } else {} } else { // print("### 记录下来了"); if (value != null && value.length > 0) { @@ -58,9 +69,11 @@ class ReceiveShareFile { // For sharing or opening urls/text coming from outside the app while the app is in the memory _intentDataStreamSubscription = ReceiveSharingIntent.getTextStream().listen((String value) { - print('#### getfilePath dddd $value '); - - MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, value); + print('#### getfilePath $value '); +// setState(() { +// _sharedText = value; +// print("Shared: $_sharedText"); +// }); }, onError: (err) { print("getLinkStream error: $err"); }); diff --git a/lib/utils/screen.dart b/lib/utils/screen.dart index fa12891..5ec556a 100644 --- a/lib/utils/screen.dart +++ b/lib/utils/screen.dart @@ -91,8 +91,3 @@ setStatusBar(){ systemNavigationBarColor: Colors.white, systemNavigationBarIconBrightness: Brightness.dark)); } - - -debugPrint(dynamic msg){ - print('###${DateTime.now()}####### '+msg); -} diff --git a/lib/utils/screen_shot.dart b/lib/utils/screen_shot.dart index 3d4a638..27426c1 100644 --- a/lib/utils/screen_shot.dart +++ b/lib/utils/screen_shot.dart @@ -1,4 +1,3 @@ -import 'dart:io'; import 'dart:typed_data'; import 'package:chat/map/location_result.dart'; @@ -6,14 +5,9 @@ import 'package:chat/utils/screen.dart'; import 'package:flutter/services.dart'; import 'package:flutter_image_compress/flutter_image_compress.dart'; -import 'MessageMgr.dart'; - class ScreenShot { static const MethodChannel _channel = const MethodChannel('make.photo.screen.hibok'); - static const EventChannel eventChannel = - const EventChannel('com.file.hibok'); - static Future> takeScreenshotImage() async { Map args = {}; @@ -44,22 +38,4 @@ class ScreenShot { Map args = {}; return _channel.invokeMethod('isSupportGoogle', args); } - - - static getFileStream() { - eventChannel.receiveBroadcastStream().listen((Object agrs){ - print('######## receiveBroadcastStream $agrs'); - - File file = new File(agrs.toString()); - if(file.existsSync()){ - print('接收到的文件--存在'); - MessageMgr().emit(MessageMgr.RECEIVE_THIRD_SHARE, agrs); - }else{ - print('接收到的文件--不存在'); - } - - }, onError: (Object error){ - print('######## error $error'); - }); - } }