diff --git a/android/app/build.gradle b/android/app/build.gradle index b7fee24..2964d4e 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -56,9 +56,9 @@ android { // manifestPlaceholders = [ // AMAP_KEY : "1fd4e93e3b4b13747da41f484c955fe2", /// 高德地图key // ] - ndk { - abiFilters 'armeabi-v7a' - } +// ndk { +// abiFilters 'armeabi-v7a' +// } multiDexEnabled true manifestPlaceholders = [ JPUSH_PKGNAME : 'com.cyhd.henhoandroid', diff --git a/assets/fonts/iconfont.ttf b/assets/fonts/iconfont.ttf index f36674b..76d655a 100644 Binary files a/assets/fonts/iconfont.ttf and b/assets/fonts/iconfont.ttf differ diff --git a/assets/images/lock_photo.png b/assets/images/lock_photo.png new file mode 100644 index 0000000..b0ed4ed Binary files /dev/null and b/assets/images/lock_photo.png differ diff --git a/assets/images/up.png b/assets/images/up.png new file mode 100644 index 0000000..495ef24 Binary files /dev/null and b/assets/images/up.png differ diff --git a/i18n/en-US.json b/i18n/en-US.json index 058b8ba..808fd00 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -1251,5 +1251,10 @@ "shock_notice": "震动通知", "max_upload_size": "最多上传/s1张", "travel_tips2": "您的贴身出行管家,解决语言不通打车走错路的问题", - "new_friends_tips": "现在我们可以开始聊天了。" + "new_friends_tips": "现在我们可以开始聊天了。", + "msg_tips": "填写自我简介获得更多关注,在此处填写", + "new_msg": "/s1条新消息", + "upload1": "上传", + "his_profile": "他的资料", + "her_profile": "她的资料" } \ No newline at end of file diff --git a/i18n/ja-JP.json b/i18n/ja-JP.json index f581102..cd04049 100644 --- a/i18n/ja-JP.json +++ b/i18n/ja-JP.json @@ -1251,5 +1251,10 @@ "shock_notice": "震动通知", "max_upload_size": "最多上传/s1张", "travel_tips2": "您的贴身出行管家,解决语言不通打车走错路的问题", - "new_friends_tips": "现在我们可以开始聊天了。" + "new_friends_tips": "现在我们可以开始聊天了。", + "msg_tips": "填写自我简介获得更多关注,在此处填写", + "new_msg": "/s1条新消息", + "upload1": "上传", + "his_profile": "他的资料", + "her_profile": "她的资料" } \ No newline at end of file diff --git a/i18n/ko-KR.json b/i18n/ko-KR.json index 4627f83..a9951e0 100644 --- a/i18n/ko-KR.json +++ b/i18n/ko-KR.json @@ -1251,5 +1251,10 @@ "shock_notice": "震动通知", "max_upload_size": "最多上传/s1张", "travel_tips2": "您的贴身出行管家,解决语言不通打车走错路的问题", - "new_friends_tips": "现在我们可以开始聊天了。" + "new_friends_tips": "现在我们可以开始聊天了。", + "msg_tips": "填写自我简介获得更多关注,在此处填写", + "new_msg": "/s1条新消息", + "upload1": "上传", + "his_profile": "他的资料", + "her_profile": "她的资料" } \ No newline at end of file diff --git a/i18n/vi-VN.json b/i18n/vi-VN.json index e89affc..cf06889 100644 --- a/i18n/vi-VN.json +++ b/i18n/vi-VN.json @@ -1159,7 +1159,7 @@ "not_have_user": " Người dùng không tồn tại ", "not_add_Myself": "Bạn không thể thêm chính mình", "you_are_blaklisted": " Đối phương đã đưa bạn vào danh sách đen", - "confrim_recovery": " Có chắc là bạn muốn phục hồi ảnh đã tiêu hủy không?\n (người dùng đã xem có thể xem lại lần nữa", + "confrim_recovery": " Có chắc là bạn muốn phục hồi ảnh đã tiêu hủy không?\n (người dùng đã xem có thể xem lại lần nữa)", "send_to": " Gửi tới ", "search_plach": "Rà soát địa điểm", "finding_place": " Tìm địa điểm", @@ -1251,5 +1251,10 @@ "shock_notice": "震动通知", "max_upload_size": "最多上传/s1张", "travel_tips2": "您的贴身出行管家,解决语言不通打车走错路的问题", - "new_friends_tips": "现在我们可以开始聊天了。" + "new_friends_tips": "现在我们可以开始聊天了。", + "msg_tips": "填写自我简介获得更多关注,在此处填写", + "new_msg": "/s1条新消息", + "upload1": "上传", + "his_profile": "他的资料", + "her_profile": "她的资料" } \ No newline at end of file diff --git a/i18n/zh-CN.json b/i18n/zh-CN.json index 9cece82..645ae29 100644 --- a/i18n/zh-CN.json +++ b/i18n/zh-CN.json @@ -1251,5 +1251,10 @@ "shock_notice": "震动通知", "max_upload_size": "最多上传/s1张", "travel_tips2": "您的贴身出行管家,解决语言不通打车走错路的问题", - "new_friends_tips": "现在我们可以开始聊天了。" + "new_friends_tips": "现在我们可以开始聊天了。", + "msg_tips": "填写自我简介获得更多关注,在此处填写", + "new_msg": "/s1条新消息", + "upload1": "上传", + "his_profile": "他的资料", + "her_profile": "她的资料" } \ No newline at end of file diff --git a/i18n/zh-HK.json b/i18n/zh-HK.json index bbaeaa5..dac2d85 100644 --- a/i18n/zh-HK.json +++ b/i18n/zh-HK.json @@ -1251,5 +1251,10 @@ "shock_notice": "震动通知", "max_upload_size": "最多上传/s1张", "travel_tips2": "您的贴身出行管家,解决语言不通打车走错路的问题", - "new_friends_tips": "现在我们可以开始聊天了。" + "new_friends_tips": "现在我们可以开始聊天了。", + "msg_tips": "填寫自我簡介獲得更多關注,在此處填寫", + "new_msg": "/s1條新消息", + "upload1": "上傳", + "his_profile": "他的資料", + "her_profile": "她的資料" } \ No newline at end of file diff --git a/lib/chat/group_chat_view.dart b/lib/chat/group_chat_view.dart index 830f2fa..7e67f11 100644 --- a/lib/chat/group_chat_view.dart +++ b/lib/chat/group_chat_view.dart @@ -18,6 +18,7 @@ import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/analyze_utils.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:chat/utils/net_state_widget.dart'; +import 'package:chat/utils/screen.dart'; import 'package:chat/utils/sound_util.dart'; import 'package:chat/utils/sp_utils.dart'; import 'package:chat/utils/sql_util.dart'; @@ -160,6 +161,17 @@ class _GroupChatPageState extends State { sendMsg(msg); } }); + + controller.addListener(() { + if (alterTime != null || unreadTime != null) { + for (int i = 0; i < msgList.length; i++) { + if ((msgList[i].time == alterTime || msgList[i].time == unreadTime) && + controller.isIndexStateInLayoutRange(i)) { + clearUnreadNews(); + } + } + } + }); } jumpToMsg(time) async { @@ -236,6 +248,11 @@ class _GroupChatPageState extends State { } } + clearUnreadNews() { + unreadTime = null; + setState(() {}); + } + @override Widget build(BuildContext context) { List actions = []; @@ -289,111 +306,126 @@ class _GroupChatPageState extends State { Provider.value(value: true), Provider.value(value: widget.groupInfoModel), ], - child: GestureDetector( - onTapDown: (args){hideKeyBoard();}, - child: ExtendedTextSelectionPointerHandler( - ///选择文字,消除弹窗 - builder: (states) { - return Listener( - child: Scaffold( - resizeToAvoidBottomInset: false, - backgroundColor: const Color(0xFFE2E9F1), - appBar: AppBar( - backgroundColor: AppColors.NewAppbarBgColor, - title: Text( - widget.groupInfoModel.getGroupName(refMap), - textScaleFactor: 1.0, - style: TextStyle( - color: Constants.BlackTextColor, - fontSize: 16.47), - ), - leading: CustomUI.buildCustomLeading(context), - titleSpacing: -10, - elevation: 1, - centerTitle: false, - actions: actions), - body: SafeArea( - child: Stack( + child: GestureDetector(onTapDown: (args) { + hideKeyBoard(); + }, child: ExtendedTextSelectionPointerHandler( + ///选择文字,消除弹窗 + builder: (states) { + return Listener( + child: Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: const Color(0xFFE2E9F1), + appBar: AppBar( + backgroundColor: AppColors.NewAppbarBgColor, + title: Text( + widget.groupInfoModel.getGroupName(refMap), + textScaleFactor: 1.0, + style: TextStyle( + color: Constants.BlackTextColor, fontSize: 16.47), + ), + leading: CustomUI.buildCustomLeading(context), + titleSpacing: -10, + elevation: 1, + centerTitle: false, + actions: actions), + body: SafeArea( + child: Stack( + children: [ + Column( children: [ - Column( - children: [ - NetStateWidget(), - Expanded(child: _buildMessageList()), - InputBar(sendMsg: sendMsg), - ], - ), - isHaveUnreadNews - ? Positioned( - top: 32.5, - right: 0, - child: InkWell( - onTap: () { - jumpToMsg(isAlterYou - ? alterTime - : unreadTime); - unreadTime = null; - setState(() {}); - }, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: Color(0x33000000), //阴影颜色 - blurRadius: 10.0, //阴影大小 - ) - ], - borderRadius: BorderRadius.only( - topLeft: Radius.circular(80), - bottomLeft: Radius.circular(80)), - color: Colors.white, + NetStateWidget(), + Expanded(child: _buildMessageList()), + InputBar(sendMsg: sendMsg), + ], + ), + isHaveUnreadNews + ? Positioned( + top: 32.5, + right: 0, + child: InkWell( + onTap: () { + jumpToMsg( + isAlterYou ? alterTime : unreadTime); + clearUnreadNews(); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: Color(0x33000000), //阴影颜色 + blurRadius: 7, //阴影大小 + ) + ], + borderRadius: BorderRadius.only( + topLeft: Radius.circular(80), + bottomLeft: Radius.circular(80)), + color: Colors.white, + ), + constraints: BoxConstraints(minWidth: 120), + height: 39, + child: Row( + children: [ + SizedBox(width: 16.5), + Image.asset( + 'assets/images/up.png', + width: 12, ), - constraints: - BoxConstraints(minWidth: 120), - height: 39, - child: Row( - children: [ - Icon( - Icons.arrow_upward, - color: Color(0xFF3875E9), - size: 20, - ), - Text( + SizedBox(width: 10), + Container( + child: Text( isAlterYou - ? '$alterUserName @你' - : '$unreadNums条新消息', + ? '$alterUserName' + : I18n.of(context) + .new_msg + .replaceFirst( + '/s1', + unreadNums + .toString()), style: TextStyle( color: Color(0xFF3875E9)), - ) - ], + overflow: TextOverflow.ellipsis, + ), + constraints: BoxConstraints( + maxWidth: isAlterYou + ? 60 + : Screen.width)), + Text( + isAlterYou + ? '@${I18n.of(context).you}' + : '', + style: TextStyle( + color: Color(0xFF3875E9)), ), - ))) - : Container() - ], - ))), - onPointerDown: (value) { - for (var state in states) { - if (!state.containsPosition(value.position)) { - //clear other selection - state.clearSelection(); - } - } - }, - onPointerMove: (value) { + SizedBox(width: 14), + ], + ), + ))) + : Container() + ], + ))), + onPointerDown: (value) { + for (var state in states) { + if (!state.containsPosition(value.position)) { //clear other selection - for (var state in states) { - if (!state.containsPosition(value.position)) { - //clear other selection - state.clearSelection(); - } - } - }, - ); + state.clearSelection(); + } + } + }, + onPointerMove: (value) { + //clear other selection + for (var state in states) { + if (!state.containsPosition(value.position)) { + //clear other selection + state.clearSelection(); + } + } }, - ))); + ); + }, + ))); } - Widget _buildMessageList() { return Container( alignment: Alignment.topCenter, diff --git a/lib/data/chat_data_mgr.dart b/lib/data/chat_data_mgr.dart index 97d9443..956bfdb 100644 --- a/lib/data/chat_data_mgr.dart +++ b/lib/data/chat_data_mgr.dart @@ -59,7 +59,6 @@ class ChatDataMgr { getLastRecord(); } - //初始化私聊未读消息 initUnreadCount() async { @@ -77,6 +76,7 @@ class ChatDataMgr { unreadCountMap.forEach((k, v) { groupUnreadProvider.updateUnreadCount(k, v); }); + groupUnreadProvider.initUnreadAlter(); } logout() { @@ -92,7 +92,8 @@ class ChatDataMgr { //获取私聊记录 List getRecord({int sessionId}) { - var record = msgRecordMap[sessionId==null?MsgHandler.curActiveSession:sessionId]; + var record = msgRecordMap[ + sessionId == null ? MsgHandler.curActiveSession : sessionId]; if (record == null) { record = []; msgRecordMap[MsgHandler.curActiveSession] = record; @@ -102,7 +103,8 @@ class ChatDataMgr { //获取群聊记录 List getGroupRecord({int sessionId}) { - var record = groupRecordMap[sessionId==null?MsgHandler.curActiveSession:sessionId]; + var record = groupRecordMap[ + sessionId == null ? MsgHandler.curActiveSession : sessionId]; if (record == null) { record = []; groupRecordMap[MsgHandler.curActiveSession] = record; @@ -118,7 +120,6 @@ class ChatDataMgr { msgRecordMap[MsgHandler.curActiveSession] = record; } return record; - } updateLastMsgWithTranslateMsg(PushChat chat) async { @@ -281,7 +282,7 @@ class ChatDataMgr { } var result = getMsgBy(msg.sessionId, msg.time, true); if (result != null) { - print('消息存在!!!!'); + print('消息存在!!!!'); } else { print('插入消息!!!!'); insertToDB(msg, record); @@ -315,10 +316,10 @@ class ChatDataMgr { print('数据为空,无法插入'); } else { record.insert(0, msg); - // print(MsgHandler.time); + // print(MsgHandler.time); //int after = DateTime.now().millisecondsSinceEpoch-MsgHandler.time; - // print('******插入数据 use $after'); - // print('******record length ${record.length} ${msg.sessionId}'); + // print('******插入数据 use $after'); + // print('******record length ${record.length} ${msg.sessionId}'); SqlUtil.insert(msg); diff --git a/lib/data/constants.dart b/lib/data/constants.dart index 5adc864..36c981e 100644 --- a/lib/data/constants.dart +++ b/lib/data/constants.dart @@ -92,8 +92,8 @@ class GroupOperatingPageType { //消息发送界面类别 class SendMessagePageType { - static const int AddFriends = 0; //添加朋友 - static const int ChangeGroupName = 1; //修改群名字 + static const int AddFriends = 0; //添加朋友 + static const int ChangeGroupName = 1; //修改群名字 static const int ChangeGroupNickName = 2; //修改群昵称 static const int Remark = 3; //修改备注 } @@ -285,6 +285,8 @@ class Constants { static const Latitude = 'Latitude'; static const Longitude = 'Longitude'; + static const GroupAlterKey = 'GroupAlterKey'; //群@ + /// currentGoodsId+'@'+receipt+'@'+purchaseToken static final vipIcon = Image.asset( diff --git a/lib/generated/i18n.dart b/lib/generated/i18n.dart index ce60261..23c66eb 100644 --- a/lib/generated/i18n.dart +++ b/lib/generated/i18n.dart @@ -2539,6 +2539,16 @@ class I18n implements WidgetsLocalizations { String get travel_tips2 => "您的贴身出行管家,解决语言不通打车走错路的问题"; /// "现在我们可以开始聊天了。" String get new_friends_tips => "现在我们可以开始聊天了。"; + /// "填写自我简介获得更多关注,在此处填写" + String get msg_tips => "填写自我简介获得更多关注,在此处填写"; + /// "/s1条新消息" + String get new_msg => "/s1条新消息"; + /// "上传" + String get upload1 => "上传"; + /// "他的资料" + String get his_profile => "他的资料"; + /// "她的资料" + String get her_profile => "她的资料"; } class _I18n_en_US extends I18n { @@ -5680,9 +5690,9 @@ class _I18n_vi_VN extends I18n { /// "Đơn xin xác thực của bạn đã gửi và chờ đối phương thông qua" @override String get add_friends_tips => "Đơn xin xác thực của bạn đã gửi và chờ đối phương thông qua"; - /// "Tôi là/s1" + /// "Tôi là /s1" @override - String get i_am => "Tôi là/s1"; + String get i_am => "Tôi là /s1"; /// "Cho phép" @override String get agree => "Cho phép"; @@ -6031,9 +6041,9 @@ class _I18n_vi_VN extends I18n { /// " Đối phương đã đưa bạn vào danh sách đen" @override String get you_are_blaklisted => " Đối phương đã đưa bạn vào danh sách đen"; - /// " Có chắc là bạn muốn phục hồi ảnh đã tiêu hủy không?\n (người dùng đã xem có thể xem lại lần nữa" + /// " Có chắc là bạn muốn phục hồi ảnh đã tiêu hủy không?\n (người dùng đã xem có thể xem lại lần nữa)" @override - String get confrim_recovery => " Có chắc là bạn muốn phục hồi ảnh đã tiêu hủy không?\n (người dùng đã xem có thể xem lại lần nữa"; + String get confrim_recovery => " Có chắc là bạn muốn phục hồi ảnh đã tiêu hủy không?\n (người dùng đã xem có thể xem lại lần nữa)"; /// " Gửi tới " @override String get send_to => " Gửi tới "; @@ -6310,6 +6320,21 @@ class _I18n_vi_VN extends I18n { /// "现在我们可以开始聊天了。" @override String get new_friends_tips => "现在我们可以开始聊天了。"; + /// "填写自我简介获得更多关注,在此处填写" + @override + String get msg_tips => "填写自我简介获得更多关注,在此处填写"; + /// "/s1条新消息" + @override + String get new_msg => "/s1条新消息"; + /// "上传" + @override + String get upload1 => "上传"; + /// "他的资料" + @override + String get his_profile => "他的资料"; + /// "她的资料" + @override + String get her_profile => "她的资料"; @override TextDirection get textDirection => TextDirection.ltr; @@ -10077,6 +10102,21 @@ class _I18n_zh_HK extends I18n { /// "现在我们可以开始聊天了。" @override String get new_friends_tips => "现在我们可以开始聊天了。"; + /// "填寫自我簡介獲得更多關注,在此處填寫" + @override + String get msg_tips => "填寫自我簡介獲得更多關注,在此處填寫"; + /// "/s1條新消息" + @override + String get new_msg => "/s1條新消息"; + /// "上傳" + @override + String get upload1 => "上傳"; + /// "他的資料" + @override + String get his_profile => "他的資料"; + /// "她的資料" + @override + String get her_profile => "她的資料"; @override TextDirection get textDirection => TextDirection.ltr; @@ -13844,6 +13884,21 @@ class _I18n_zh_CN extends _I18n_zh_HK { /// "现在我们可以开始聊天了。" @override String get new_friends_tips => "现在我们可以开始聊天了。"; + /// "填写自我简介获得更多关注,在此处填写" + @override + String get msg_tips => "填写自我简介获得更多关注,在此处填写"; + /// "/s1条新消息" + @override + String get new_msg => "/s1条新消息"; + /// "上传" + @override + String get upload1 => "上传"; + /// "他的资料" + @override + String get his_profile => "他的资料"; + /// "她的资料" + @override + String get her_profile => "她的资料"; @override TextDirection get textDirection => TextDirection.ltr; @@ -17611,6 +17666,21 @@ class _I18n_ko_KR extends I18n { /// "现在我们可以开始聊天了。" @override String get new_friends_tips => "现在我们可以开始聊天了。"; + /// "填写自我简介获得更多关注,在此处填写" + @override + String get msg_tips => "填写自我简介获得更多关注,在此处填写"; + /// "/s1条新消息" + @override + String get new_msg => "/s1条新消息"; + /// "上传" + @override + String get upload1 => "上传"; + /// "他的资料" + @override + String get his_profile => "他的资料"; + /// "她的资料" + @override + String get her_profile => "她的资料"; @override TextDirection get textDirection => TextDirection.ltr; @@ -21378,6 +21448,21 @@ class _I18n_ja_JP extends I18n { /// "现在我们可以开始聊天了。" @override String get new_friends_tips => "现在我们可以开始聊天了。"; + /// "填写自我简介获得更多关注,在此处填写" + @override + String get msg_tips => "填写自我简介获得更多关注,在此处填写"; + /// "/s1条新消息" + @override + String get new_msg => "/s1条新消息"; + /// "上传" + @override + String get upload1 => "上传"; + /// "他的资料" + @override + String get his_profile => "他的资料"; + /// "她的资料" + @override + String get her_profile => "她的资料"; @override TextDirection get textDirection => TextDirection.ltr; diff --git a/lib/home/ProfilePage.dart b/lib/home/ProfilePage.dart index 237b372..33ea340 100644 --- a/lib/home/ProfilePage.dart +++ b/lib/home/ProfilePage.dart @@ -2,6 +2,8 @@ import 'dart:convert'; import 'dart:io'; import 'package:chat/home/fans_page.dart'; import 'package:chat/home/goddess_hot.dart'; +import 'package:chat/home/my_headview.dart'; +import 'package:chat/home/photo_page.dart'; import 'package:chat/home/rich_title.dart'; import 'package:chat/models/ChatMsg.dart'; import 'package:chat/models/money_change.dart'; @@ -29,14 +31,10 @@ import 'package:chat/home/VideoPage.dart'; import 'package:chat/home/VipPage.dart'; import 'package:chat/models/UserInfo.dart'; import 'package:chat/utils/CustomUI.dart'; -import 'package:chat/utils/LoadingDialog.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/TutorialOverlay.dart'; -import 'package:chat/utils/UserCard.dart'; -import 'package:chat/utils/UserChips.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/services.dart'; -import 'package:image_cropper/image_cropper.dart'; import 'package:image_picker/image_picker.dart'; import 'package:multi_image_picker/multi_image_picker.dart'; @@ -59,6 +57,7 @@ import 'add_friend.dart'; import 'apply_content_view.dart'; import 'daily_bonus_page.dart'; import 'money_picture_view.dart'; +import 'dart:math' as math; var cardWidth; @@ -91,10 +90,6 @@ class _ProfilePageState extends State UserInfo userInfo = new UserInfo(); TextEditingController nickNameController = new TextEditingController(); - - // AnimationController animationController; - // Animation movement; - bool isMyself = false; List imgList = []; @@ -152,6 +147,8 @@ class _ProfilePageState extends State bool isAuthority = false; //是否有聊天和查看用户资料的权限 + bool isShowAll = false; + getUserInfo({mymsg = ''}) async { if (mymsg != '' && mymsg != null) { UserData().basicInfo.ownMsg = mymsg; @@ -335,6 +332,7 @@ class _ProfilePageState extends State MessageMgr().on('post_add_friend', msgAddFriend); MessageMgr().on('refresh_love_list', msgRefreshLoveList); MessageMgr().on('refresh_fans_num', msgRefreshFansNum); + MessageMgr().on('change_my_headview', msgChangeMyHeadView); } void messageOff() { @@ -346,6 +344,14 @@ class _ProfilePageState extends State MessageMgr().off('post_add_friend', msgAddFriend); MessageMgr().off('refresh_love_list', msgRefreshLoveList); MessageMgr().off('refresh_fans_num', msgRefreshFansNum); + MessageMgr().off('change_my_headview', msgChangeMyHeadView); + } + + msgChangeMyHeadView(data) { + if (isMyself) { + userInfo.headimgurl = UserData().basicInfo.headimgurl; + setState(() {}); + } } msgRefreshFansNum(data) { @@ -376,7 +382,6 @@ class _ProfilePageState extends State void dispose() { messageOff(); registKey = null; - //animationController?.dispose(); nickNameController.dispose(); super.dispose(); } @@ -414,22 +419,6 @@ class _ProfilePageState extends State //上传相册 void _uploadPhoto() async { - // if (await CustomUI.showPhotoPermissionSetting(context)) { - // var tempFile = await ImagePicker.pickImage(source: ImageSource.gallery); - // if (tempFile != null) { - // //选择焚烧 - // Navigator.of(context).push( - // new MaterialPageRoute( - // builder: (context) { - // return UploadPicture( - // img: tempFile, - // ); - // }, - // ), - // ); - // } - // } - int leftLength = MaxImgSize - imgList.length; if (leftLength <= 0) { showToast(I18n.of(context) @@ -486,119 +475,291 @@ class _ProfilePageState extends State showToast(resData['msg']); } } - -// var photos = await PhotoPicker.pickAsset( -// context: context, -// themeColor: Color(0xFFF0F0F0), -// textColor: Color(0xFF3F3F3F), -// pickType: PickType.onlyImage); - -// if (photos != null && photos.length > 0) { -// List fileList = []; -// for (var i = 0; i < photos.length; i++) { -// AssetEntity photoEntity = photos[i]; -// fileList.add(await photoEntity.file); -// } -// Map data = {"type": 2, "userId": UserData().basicInfo.userId}; -// data['sign'] = TokenMgr().getSign(data); -// data['sex'] = UserData().basicInfo.sex; -// data['isBurn'] = 0; -// Response res = await HttpUtil().uploadFiles( -// fileList, data, 'upload/post/postfiles', 'image', -// isShowLoading: true); -// var resData = res.data; -// if (resData['code'] == 0) { -// if (resData['data']['msg'] != '' && resData['data']['msg'] != null) { -// showToast(resData['data']['msg']); -// } -// if(resData['msg'].split('|').length !=photos.length){ -// showToast(I18n.of(context).hava_error_photo); -// } -// MessageMgr().emit('refresh_photo'); -// } -// } } - void _sendPicture() async { - if (await CustomUI.showPhotoPermissionSetting(context)) { - showDialog( - context: context, - barrierDismissible: false, - builder: (BuildContext context) { - return LoadingDialog( - text: "", - ); - }); - var tempFile = await ImagePicker.pickImage(source: ImageSource.gallery); - Navigator.of(context).pop(); - if (tempFile != null) { - _cropPicture(tempFile); - } - } + showHeadView() { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return MyHeadViewPage(); + }, + ), + ); } - void _cropPicture(tempFile) async { - File croppedFile = await ImageCropper.cropImage( - sourcePath: tempFile.path, - aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), + Widget _buildSignIn() { + return Container( + margin: EdgeInsets.only(top: Separate_Size, bottom: Separate_Size), + padding: EdgeInsets.symmetric(horizontal: 10), + child: FullWidthButton( + iconCode: 0xe65c, + iconColor: 0xFFAF60F8, + showRightIcon: true, + title: I18n.of(context).sign_in, + showDivider: false, + onPressed: () { + Navigator.of(context).push(MaterialPageRoute( + builder: (context) { + return DailyBonusPage(); + }, + )); + }, + ), + decoration: BoxDecoration( + color: Colors.white, + border: Border( + top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), ); + } - if (croppedFile != null) { - Map data = {"type": 1, "userId": userInfo.userId}; - data['sign'] = TokenMgr().getSign(data); - Response res = await HttpUtil() - .uploadFile(croppedFile, data, 'upload/file/postflie', 'image'); - var resData = res.data; - if (resData['code'] == 0) { - userInfo.headimgurl = resData['msg']; - - if (mounted) { - setState(() {}); - } - } - } + Widget _buildPicture() { + return FullWidthButton( + iconCode: 0xe689, + iconColor: 0xFFE3AA10, + title: (isMyself + ? I18n.of(context).my_album + : (isMan ? I18n.of(context).his_photo : I18n.of(context).her_photo)), + descriptionColor: Constants.BlueTextColor, + showDivider: false, + showRightIcon: true, + onPressed: () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return PhotoPage( + userInfo: userInfo, + ); + }, + ), + ); + }, + ); } Widget _buildHeadView() { cardWidth = MediaQuery.of(context).size.width; - - Color buttonColor = Colors.grey; return Container( + decoration: BoxDecoration( + color: Colors.white, + border: Border(bottom: Constants.GreyBorderSide)), + child: Container( decoration: BoxDecoration( - color: Colors.white, - border: Border(bottom: Constants.GreyBorderSide)), - child: Stack( + color: Colors.white, + ), + width: MediaQuery.of(context).size.width, + padding: EdgeInsets.only(top: 19), + child: Column( children: [ - Container( - decoration: BoxDecoration( - color: Colors.white, - ), - width: MediaQuery.of(context).size.width, - padding: EdgeInsets.only(top: 20), - child: Column( - children: [ - _buildHeadImg(), - _buildUserName(), - _buildUserChips(), - _buildResientCity(), - //_buildProgram(), - _buildAttestation(), + Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + _buildHeadImg(), + Column(children: [ _buildFans(), - ], - ), + _buildButtonList(), + ]) + ], ), - _buildLoveButton(buttonColor), + _buildUserChips(), + _buildAttestation(), + _buildMyMsg(), ], + ), + ), + ); + } + + Widget _buildMyMsg() { + double width = Screen.width - 80; + var textStyle = TextStyle(fontSize: 12, color: Color(0xFF333333)); + // userInfo.ownMsg = + // '哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈'; + bool showAllContent = isExpansion(userInfo.ownMsg, width); + return Container( + padding: + EdgeInsets.only(left: 25.5, bottom: isMyself ? 20 : 5, right: 10), + child: userInfo.ownMsg == null || userInfo.ownMsg == '' + ? (isMyself + ? InkWell( + onTap: () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return EditPage(isEditPage: true); + }, + ), + ); + }, + child: Row(children: [ + Text(I18n.of(context).msg_tips, style: textStyle), + Transform.rotate( + angle: math.pi * 2, + child: Icon( + IconData(0xe68d, + fontFamily: Constants.IconFontFamily), + color: Color(0xFF717171), + size: 16, + )) + ])) + : Container()) + : Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + width: width, + child: Text( + userInfo.ownMsg, + style: textStyle, + maxLines: isShowAll ? 10 : 1, + overflow: TextOverflow.ellipsis, + )), + SizedBox(width: 4), + showAllContent + ? InkWell( + onTap: () { + setState(() { + isShowAll = !isShowAll; + }); + }, + child: Transform.rotate( + angle: isShowAll ? math.pi : 0, + child: Icon( + IconData(0xe684, + fontFamily: Constants.IconFontFamily), + color: Color(0xFF717171), + size: 13, + ))) + : Container(), + ], + )); + } + + bool isExpansion(String text, double width) { + TextPainter _textPainter = TextPainter( + maxLines: 2, + text: TextSpan( + text: text, style: TextStyle(fontSize: 12.0, color: Colors.black)), + textDirection: TextDirection.ltr) + ..layout(maxWidth: width, minWidth: width); + if (_textPainter.didExceedMaxLines) { + //这里判断 文本是否截断 + return true; + } else { + return false; + } + } + + Widget _buildBorderButton(String str, double width, callback, + {IconData iconCode, int iconColor = 0xFF181818}) { + return InkWell( + onTap: callback, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + border: Border.all(color: Color(0xB5CCCCCC)), + borderRadius: BorderRadius.circular(14)), + height: 28, + width: width, + child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [ + iconCode != null + ? Container( + margin: EdgeInsets.only(right: 2), + child: Icon( + iconCode, + size: 16, + color: Color(iconColor), + )) + : Container(), + Text( + str, + style: TextStyle(fontSize: 14), + ) + ]), + )); + } + + gotoEditPage() { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return EditPage(isEditPage: true); + }, + ), + ); + } + + gotoSystemEditPage() { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return SystemEditPage(); + }, + ), + ); + } + + loveOrCancele() { + if (!userInfo.isLike) { + HttpUtil().setLove(userInfo.userId, () { + MessageMgr() + .emit('refresh_love_list', {'UserId': userInfo.userId, 'flag': 0}); + setState(() { + userInfo.isLike = true; + }); + }); + } else { + HttpUtil().cancleLove(userInfo.userId, () { + MessageMgr() + .emit('refresh_love_list', {'UserId': userInfo.userId, 'flag': 2}); + setState(() { + userInfo.isLike = false; + }); + }); + } + } + + Widget _buildButtonList() { + List list = []; + if (isMyself) { + list = [ + _buildBorderButton( + I18n.of(context).edit_information, 140, gotoEditPage), + SizedBox(width: 12.5), + _buildBorderButton('', 53, gotoSystemEditPage, + iconCode: Icons.settings), + ]; + } else if (userInfo.sex == UserData().basicInfo.sex) { + list = [ + _buildBorderButton(I18n.of(context).private_chat, 140, + isCanWatch ? buyChatAccount : null, + iconCode: IconData(0xe68c, fontFamily: 'iconfont')), + ]; + } else { + list = [ + _buildBorderButton(I18n.of(context).like, 140, loveOrCancele, + iconCode: IconData(userInfo.isLike ? 0xe623 : 0xe625, + fontFamily: Constants.IconFontFamily), + iconColor: userInfo.isLike ? 0xFFFF7777 : 0xFF181818), + SizedBox(width: 12.5), + _buildBorderButton('', 53, isCanWatch ? buyChatAccount : null, + iconCode: IconData(0xe68c, fontFamily: 'iconfont')), + ]; + } + + return Container( + margin: EdgeInsets.only(top: 13, bottom: 10), + child: Row( + children: list, )); } //认证相关 Widget _buildAttestation() { return Container( - margin: EdgeInsets.only(top: 7, bottom: 7), - alignment: Alignment.center, + margin: EdgeInsets.only(top: 7, bottom: 7, left: 25.5), + alignment: Alignment.centerLeft, child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, children: [ isAttestation ? Icon(Icons.check_circle_outline, @@ -628,78 +789,6 @@ class _ProfilePageState extends State style: TextStyle(fontSize: 11, color: Constants.GreyTextColor)) ], )); - // return Stack( - // children: [ - // Container( - // margin: EdgeInsets.only(top: 3), - // alignment: Alignment.center, - // child: Row( - // mainAxisAlignment: MainAxisAlignment.center, - // children: [ - // isAttestation - // ? Icon(Icons.check_circle_outline, - // size: 12, color: Constants.BlueTextColor) - // : Padding( - // padding: EdgeInsets.only(bottom: 0.5), - // child: Icon(IconData(0xe63a, fontFamily: 'iconfont'), - // size: 16, color: const Color(0xFFA9A9A9))), - // SizedBox(width: 3), - // Text( - // isAttestation - // ? isMyself - // ? (isMan - // ? (userInfo.isVipAttestation - // ? I18n.of(context).by_paying - // : I18n.of(context).incode_passed) - // : I18n.of(context).certified) - // : (isMan - // ? (userInfo.isVipAttestation - // ? I18n.of(context).pay_join - // : I18n.of(context).passed_review) - // : I18n.of(context).passed_video) - // : isMyself - // ? I18n.of(context).not_certified - // : (isMan ? '' : I18n.of(context).not_video), - // textScaleFactor: 1.0, - // style: - // TextStyle(fontSize: 11, color: Constants.GreyTextColor)) - // ], - // )), - // !isMan && isAttestation - // ? Container( - // padding: EdgeInsets.only(top: 17), - // alignment: Alignment.centerRight, - // child: InkWell( - // onTap: () { - // Navigator.of(context).push( - // new MaterialPageRoute( - // builder: (context) { - // return VideoPage( - // userId: userInfo.userId, - // ); - // }, - // ), - // ); - // }, - // child: Padding( - // padding: EdgeInsets.only(right: 17), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.end, - // children: [ - // Text('${I18n.of(context).certified_video}', - // textScaleFactor: 1.0, - // style: TextStyle( - // fontSize: 11, color: Colors.grey)), - // Icon( - // IconData(0xe63c, fontFamily: 'iconfont'), - // size: 18.0, - // color: Color(AppColors.TabIconNormal), - // ), - // ], - // )))) - // : Container(), - // ], - // ); } Widget _buildFansButton(int nums, String text, callback, @@ -707,20 +796,17 @@ class _ProfilePageState extends State return InkWell( onTap: callback, child: Container( - width: Screen.width / 3, + width: (Screen.width - 130) / 3, child: Column( children: [ - SizedBox(height: 8), Stack( children: [ Padding( padding: EdgeInsets.only(left: 4, right: 4), child: Text( - nums < 0 ? "0" : nums.toString(), + nums > 99 ? "99+" : nums.toString(), style: TextStyle( - fontSize: 13, - //color: isMyself ? Constants.BlackTextColor : greyColor), - color: Constants.BlackTextColor), + fontSize: 13, color: Constants.BlackTextColor), )), isShowDot ? Positioned( @@ -739,12 +825,8 @@ class _ProfilePageState extends State SizedBox(height: 4), Text( text, - style: TextStyle( - fontSize: 11, - //color: isMyself ? Constants.BlackTextColor : greyColor), - color: greyColor), + style: TextStyle(fontSize: 11, color: greyColor), ), - SizedBox(height: 8), ], )), ); @@ -753,167 +835,60 @@ class _ProfilePageState extends State //关注列表 Widget _buildFans() { return Container( - decoration: - BoxDecoration(border: Border(top: Constants.GreyBorderSide)), child: Row( - //mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - _buildFansButton( - userInfo.fans, - I18n.of(context).fans, - isMyself - ? () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return FansPage(); - }, - ), - ); - } - : null), - _buildFansButton( - userInfo.followNum, - I18n.of(context).attention, - isMyself - ? () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return WhiteAndBlackPage( - isWhite: true, - ); - }, - ), - ); - } - : null), - _buildFansButton(userInfo.dynamicNum, I18n.of(context).dynamics, - () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return MyProgramPage( - userId: userInfo.userId, - isMan: isMan, + children: [ + _buildFansButton( + userInfo.fans, + I18n.of(context).fans, + isMyself + ? () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return FansPage(); + }, + ), ); - }, - ), - ); - }, isShowDot: userInfo.dynamicNum > 0), - ], - )); + } + : null), + _buildFansButton( + userInfo.followNum, + I18n.of(context).attention, + isMyself + ? () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return WhiteAndBlackPage( + isWhite: true, + ); + }, + ), + ); + } + : null), + _buildFansButton(userInfo.dynamicNum, I18n.of(context).dynamics, () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return MyProgramPage( + userId: userInfo.userId, + isMan: isMan, + ); + }, + ), + ); + }, isShowDot: userInfo.dynamicNum > 0), + ], + )); } - // //约会节目按钮 - // Widget _buildProgram() { - // return programId != 0 - // ? InkWell( - // onTap: () { - // Navigator.of(context).push( - // new MaterialPageRoute( - // builder: (context) { - // return ProgramDetailPage( - // programId: programId, - // ); - // }, - // ), - // ); - // }, - // child: Container( - // decoration: BoxDecoration( - // borderRadius: BorderRadius.all( - // Radius.circular(Constants.LittleButtonRadius)), - // gradient: LinearGradient(colors: [ - // const Color(0xFF6D6AEC), - // const Color(0xFF1795FF), - // ])), - // height: 31, - // alignment: Alignment.center, - // width: Screen.width, - // margin: - // EdgeInsets.only(left: 32.5, right: 32.5, top: 5, bottom: 3), - // child: Stack( - // alignment: Alignment.center, - // children: [ - // Container( - // alignment: Alignment.center, - // height: 31, - // child: Text( - // isMan - // ? I18n.of(context).his_appointment - // : I18n.of(context).her_appointment, - // style: TextStyle(color: Colors.white, fontSize: 14), - // )), - // Positioned( - // right: 30, - // child: Container( - // //padding: movement.value, - // child: Image.asset( - // 'assets/images/hand.png', - // width: 20, - // )), - // ) - // ], - // ))) - // : Container(); - // } - - //常驻城市 - Widget _buildResientCity() { - return isMyself - ? Container( - padding: EdgeInsets.only(top: 5), - child: Text( - userInfo.userId == null - ? '' - : '${I18n.of(context).Resident_city}:${UserData().hasLocationPermission ? WebData().getDateRange(userInfo.meetPlace) : I18n.of(context).unknown}', - textScaleFactor: 1.0, - textAlign: TextAlign.center, - style: TextStyle(fontSize: 12), - )) - : userInfo.userId == null - ? Container() - : Padding( - padding: EdgeInsets.only(top: 5), - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - InfoTile( - icon: IconData(0xe630, - fontFamily: Constants.IconFontFamily), - title: WebData() - .getDistanceString(userInfo.distince.toDouble()), - titleColor: greyColor, - isDivider: true), - InfoTile( - title: userInfo.onlineStatus == 1 - ? I18n.of(context).online - : WebData() - .getLoginTime(context, userInfo.loginDate), - titleColor: greyColor, - isDivider: - userInfo.photoAut == 1 || userInfo.infoAut == 1), - userInfo.infoAut == 1 - ? InfoTile( - icon: IconData(0xe645, fontFamily: 'iconfont'), - iconHeight: 22, - title: I18n.of(context).application_view, - titleColor: greyColor, - isDivider: false, - onTap: () {}) - : Container(), - userInfo.photoAut == 1 - ? InfoTile( - icon: IconData(0xe632, - fontFamily: Constants.IconFontFamily), - title: I18n.of(context).paid_photo, - titleColor: greyColor, - isDivider: false, - onTap: () {}) - : Container(), - ], - )); + Widget _buildDivder() { + return Container( + color: Color(0xFFE6E6E6), + width: 1.5, + height: 10, + margin: EdgeInsets.only(left: 7.5, right: 7.5)); } //用户chips @@ -922,275 +897,102 @@ class _ProfilePageState extends State if (userInfo.birthday != null) { age = DateTime.now().year - int.parse(userInfo.birthday.split('-')[0]); } + var textStyle = TextStyle(fontSize: 12); return Container( - margin: EdgeInsets.only(top: 10), - alignment: Alignment.center, - width: cardWidth, - child: userInfo.userId == null - ? Container() - : UserChips( - bgColor: const Color(0xFFF2F2F2), - fontStyle: - TextStyle(fontSize: 12, color: const Color(0xFF807B95)), - isCenter: true, - city: UserData().hasLocationPermission - ? WebData().getCity(userInfo.city) - : I18n.of(context).unknown, - age: age, - constellation: - WebData().getConstellation(context, userInfo.constellation), - professional: userInfo.occupation == null - ? '' - : WebData().getProffesionName(userInfo.occupation))); + width: Screen.width, + padding: EdgeInsets.only(left: 25.5), + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + isAttestation && !isMan + ? Container( + height: 13, + padding: EdgeInsets.only(left: 5, right: 5), + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(10), + color: Constants.PurpleBackgroundColor, + ), + child: Text( + 'Real', + textScaleFactor: 1.0, + style: TextStyle(fontSize: 9, color: Colors.white), + )) + : Text(''), + isVip && isMan + ? Container( + child: isSvip ? Constants.svipIcon : Constants.vipIcon) + : Text(''), + (isAttestation && !isMan) || isVip && isMan + ? _buildDivder() + : Container(), + Text( + '${UserData().hasLocationPermission ? WebData().getDateRange(userInfo.meetPlace) : I18n.of(context).unknown}', + style: textStyle, + ), + _buildDivder(), + Text( + '$age ${I18n.of(context).years_old}-${WebData().getConstellation(context, userInfo.constellation)}', + style: textStyle, + ), + _buildDivder(), + Text( + userInfo.occupation == null + ? '' + : WebData().getProffesionName(userInfo.occupation), + style: textStyle, + ) + ], + )); } - //用户姓名 - Widget _buildUserName() { - return isMyself - ? InkWell( - onTap: () { + //用户头像 + Widget _buildHeadImg() { + double width = 85; + return InkWell( + onTap: isMyself + ? showHeadView + : () { Navigator.of(context).push( new MaterialPageRoute( builder: (context) { - return EditPage(isEditPage: true); + return PicSwiper( + id: 0, + pics: [PicSwiperItem(userInfo.headimgurl, id: 0)], + ); }, ), ); }, - child: Container( - margin: EdgeInsets.only(top: 10), - alignment: Alignment.center, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - Provider.of(context) - .getRefName(userInfo.userId, userInfo.nickName), - textScaleFactor: 1.0, - style: TextStyle( - color: Constants.BlackTextColor, - fontWeight: FontWeight.w500, - fontSize: 16)), - isAttestation && !isMan - ? Container( - height: 13, - margin: EdgeInsets.only(left: 5), - padding: EdgeInsets.only(left: 5, right: 5), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Constants.PurpleBackgroundColor, - ), - child: Text( - 'Real', - textScaleFactor: 1.0, - style: - TextStyle(fontSize: 9, color: Colors.white), - )) - : Text(''), - isVip && isMan - ? Container( - margin: EdgeInsets.only(left: 5), - child: - isSvip ? Constants.svipIcon : Constants.vipIcon) - : Text(''), - Container( - padding: EdgeInsets.only(left: 5), - alignment: Alignment.center, - child: new InkWell( - child: Icon( - IconData(0xe6e5, fontFamily: 'iconfont'), - color: Colors.grey, - size: 16, - ), - onTap: () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return EditPage(isEditPage: true); - }, - ), - ); - }, - ), - ) - ], - ))) - : Container(); - } - - //用户头像 - Widget _buildHeadImg() { - bool needSign = UserData().sign == 1 && isMyself; - - return Container( - width: MediaQuery.of(context).size.width, - child: Stack( - children: [ - Center( - child: InkWell( - onTap: isMyself - ? _sendPicture - : () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return PicSwiper( - id: 0, - pics: [ - PicSwiperItem(userInfo.headimgurl, id: 0) - ], - ); - }, - ), - ); - }, - child: Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2.0), - boxShadow: [ - BoxShadow( - color: Colors.grey[200], - offset: Offset(0, 6), - blurRadius: 5, - ) - ]), - width: 110, - height: 110, - child: ClipRRect( - borderRadius: BorderRadius.circular(10), - child: userInfo.headimgurl == null || - userInfo.headimgurl == '' - ? Image.asset(Constants.DefaultHeadImgUrl, - height: 110, width: 110) - : CachedNetworkImage( - imageUrl: userInfo.headimgurl, - placeholder: (context, url) => Image.asset( - Constants.DefaultHeadImgUrl, - height: 110, - width: 110, - ), - fit: BoxFit.cover, - ), - ))), - ), - - ///签到功能入口 - needSign - ? Positioned.fill( - child: GestureDetector( - onTap: () { - Navigator.of(context).push(MaterialPageRoute( - builder: (context) { - return DailyBonusPage(); - }, - )); - }, - child: Container( - alignment: Alignment.centerRight, - child: Container( - margin: EdgeInsets.only(right: 23), - width: 48, - height: 48, - decoration: BoxDecoration( - borderRadius: BorderRadius.all(Radius.circular(30)), - boxShadow: [ - BoxShadow( - color: Color(0x739f9f9f), - offset: Offset(0.3, 0.5), - blurRadius: 2.0, - spreadRadius: 1.0), -// BoxShadow( -// color: Color(0x9900FF00), offset: Offset(1.0, 1.0)), -// BoxShadow(color: Color(0xFF0000FF)) - ]), - child: ClipOval( - child: Container( - color: Colors.white, - child: Column( - children: [ - SizedBox( - height: 8, - ), - Icon( - IconData(0xe65c, - fontFamily: Constants.IconFontFamily), - size: 20, - color: Color(0xFF0D68FF), - ), - SizedBox( - height: 2, - ), - Text( - I18n.of(context).signin, - style: TextStyle( - color: Color(0xFF0D68FF), fontSize: 10), - ) - ], - ), - ), - ), - ), + child: Container( + margin: EdgeInsets.only(left: 19, right: 19, bottom: 15), + decoration: BoxDecoration(shape: BoxShape.circle, boxShadow: [ + BoxShadow( + color: Color(0xFFD9D9D9), + offset: Offset(0, 0.5), + blurRadius: 5, + ) + ]), + width: width, + height: width, + child: ClipRRect( + borderRadius: BorderRadius.circular(100), + child: userInfo.headimgurl == null || userInfo.headimgurl == '' + ? Image.asset(Constants.DefaultHeadImgUrl, + height: width, width: width) + : CachedNetworkImage( + imageUrl: userInfo.headimgurl, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + height: width, + width: width, ), + fit: BoxFit.cover, ), - ) - : Container() - ], - ), + )), ); } - //收藏按钮 - Widget _buildLoveButton(Color buttonColor) { - return isMyself || userInfo.sex == UserData().basicInfo.sex - ? Container() - : Positioned( - right: 10, - top: 20, - child: InkWell( - onTap: () async { - if (!userInfo.isLike) { - HttpUtil().setLove(userInfo.userId, () { - MessageMgr().emit('refresh_love_list', - {'UserId': userInfo.userId, 'flag': 0}); - setState(() { - userInfo.isLike = true; - }); - }); - } else { - HttpUtil().cancleLove(userInfo.userId, () { - MessageMgr().emit('refresh_love_list', - {'UserId': userInfo.userId, 'flag': 2}); - setState(() { - userInfo.isLike = false; - }); - }); - } - }, - child: Container( - child: Row( - children: [ - Icon( - IconData(userInfo.isLike ? 0xe623 : 0xe625, - fontFamily: Constants.IconFontFamily), - size: 14, - color: userInfo.isLike - ? const Color(0xFFFF7777) - : buttonColor, - ), - SizedBox(width: 2), - Text( - I18n.of(context).like, - style: TextStyle(color: buttonColor, fontSize: 11), - ) - ], - ), - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 5), - decoration: BoxDecoration( - border: Border.all(color: Colors.grey[300]), - borderRadius: BorderRadius.circular(5))))); - } - Widget _buildMyPicture() { var pisc = imgList .map((f) => PicSwiperItem( @@ -1247,7 +1049,6 @@ class _ProfilePageState extends State : (isMan ? I18n.of(context).his_photo : I18n.of(context).her_photo)), - //+'(${I18n.of(context).visit_you.replaceFirst('/s1', userInfo.accessNum.toString())})', description: isMyself ? '${I18n.of(context).upload}(${imgList.length}/$MaxImgSize)' : '', @@ -1395,9 +1196,6 @@ class _ProfilePageState extends State }, child: Container( alignment: Alignment.centerRight, - // decoration: BoxDecoration( - // border: - // Border(top: BorderSide(color: Colors.grey[50]))), margin: EdgeInsets.only(top: 10, right: 10, bottom: 10), padding: EdgeInsets.only(top: 10), child: Text( @@ -1407,7 +1205,6 @@ class _ProfilePageState extends State ), )) : Container(), - _buildRset(), ], ), decoration: BoxDecoration( @@ -1536,18 +1333,22 @@ class _ProfilePageState extends State if (isMyself) { child.addAll([ _buildHeadView(), - _buildGoldnessHot(), + _buildSignIn(), _buildMoneyBox(), - _buildMyPicture(), - _buildTips(), - _buildHistory(), - //_buildApplyCode(), - _buildShare(), ]); } else if (isCanWatch) { child.addAll([ _buildHeadView(), - _buildMyPicture(), + Container( + margin: EdgeInsets.only(top: Separate_Size, bottom: Separate_Size), + padding: EdgeInsets.symmetric(horizontal: 10), + child: _buildPicture(), + decoration: BoxDecoration( + color: Colors.white, + border: Border( + top: Constants.GreyBorderSide, + bottom: Constants.GreyBorderSide)), + ), _buildBasicInfo(), _buildBottomTips(), ]); @@ -1729,7 +1530,7 @@ class _ProfilePageState extends State top: 17, bottom: 17, ), - margin: EdgeInsets.only(left: 20, bottom: 0, right: 10), + margin: EdgeInsets.only(left: 45, bottom: 0, right: 10), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -1792,12 +1593,6 @@ class _ProfilePageState extends State }); } - // //对方是女性用户,且未认证提示未认证 - // if (userInfo.sex == 2 && !userInfo.isAttestation) { - // showToast(I18n.of(context).not_video); - // return; - // } - //自己是女性,且未认证,提示去认证(好友除外) if (!UserData().isMan() && !UserData().basicInfo.isAttestation && @@ -1981,6 +1776,17 @@ class _ProfilePageState extends State : '${userInfo.weight.toInt()}KG'; List basicList = [ + Container( + padding: EdgeInsets.symmetric(horizontal: 10), + child: FullWidthButton( + iconCode: 0xe676, + iconColor: 0xFF57BBFB, + title: isMan + ? I18n.of(context).his_profile + : I18n.of(context).her_profile, + showDivider: true, + showRightIcon: false, + onPressed: () {})), userInfo.height != null && userInfo.height != 0 ? _bottomBorderBox(I18n.of(context).height, heightStr, true, () {}) : Container(), @@ -1988,7 +1794,6 @@ class _ProfilePageState extends State ? _bottomBorderBox(I18n.of(context).weight, weightStr, true, () {}) : Container(), _bottomBorderBox(I18n.of(context).Resident_city, dateRange, true, () {}), - //_bottomBorderBox(I18n.of(context).program, dateItem, true, () {}), _bottomBorderBox(I18n.of(context).expect_lover, lovePeople, true, () {}), (userInfo.wechat != null && userInfo.wechat != '') ? _bottomBorderBox( @@ -2000,10 +1805,6 @@ class _ProfilePageState extends State I18n.of(context).facebook, facebook, true, clickChatAccout, showIcon: !isAuthority) : Container(), - userInfo.ownMsg != null && userInfo.ownMsg != '' - ? _bottomBorderBox( - I18n.of(context).self_introduction, myMsg, false, () {}) - : Container(), ]; return Container( @@ -2019,17 +1820,6 @@ class _ProfilePageState extends State )); } - Widget _buildTips() { - return Container( - margin: EdgeInsets.only(top: 10, bottom: 10, left: 20, right: 20), - child: Text(I18n.of(context).dont, - textScaleFactor: 1.0, - style: TextStyle( - fontSize: 12, - color: Colors.grey, - ))); - } - Widget _buildBottomTips() { return Container( margin: EdgeInsets.only(bottom: 10, left: 10, right: 10, top: 10), @@ -2042,37 +1832,6 @@ class _ProfilePageState extends State ); } - Widget _buildGoldnessHot() { - //女神热度 - return isMan - ? Container() - : Container( - margin: EdgeInsets.only(top: Separate_Size), - padding: EdgeInsets.symmetric(horizontal: 10), - child: FullWidthButton( - title: I18n.of(context).Goddess_heat, - showDivider: false, - showRightIcon: true, - onPressed: () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return GoddessHotPage( - userId: userInfo.userId, - ); - }, - ), - ); - }, - ), - decoration: BoxDecoration( - color: Colors.white, - border: Border( - top: Constants.GreyBorderSide, - bottom: Constants.GreyBorderSide)), - ); - } - Widget _buildMoneyBox() { //认证、钱包、隐私连麦设置 return Container( @@ -2081,11 +1840,33 @@ class _ProfilePageState extends State color: Colors.white, border: Border( top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), - padding: EdgeInsets.all(10), + padding: EdgeInsets.only(top: 4, bottom: 4, left: 10, right: 10), child: Column( children: [ + isMan + ? Container() + : FullWidthButton( + iconCode: 0xe687, + iconColor: 0xFFFF7752, + title: I18n.of(context).Goddess_heat, + showDivider: true, + showRightIcon: true, + onPressed: () { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return GoddessHotPage( + userId: userInfo.userId, + ); + }, + ), + ); + }, + ), isMan ? FullWidthButton( + iconCode: 0xe68e, + iconColor: 0xFF3D83E6, title: I18n.of(context).member, description: UserData().isVip ? I18n.of(context) @@ -2104,6 +1885,8 @@ class _ProfilePageState extends State }, ) : FullWidthButton( + iconCode: 0xe688, + iconColor: 0xFF3D83E6, title: isAttestation ? I18n.of(context).certified_video : I18n.of(context).authenticate, @@ -2123,10 +1906,12 @@ class _ProfilePageState extends State }, ), FullWidthButton( + iconCode: 0xe68a, + iconColor: 0xFF4CB871, title: I18n.of(context).wallet, description: '${Provider.of(context).money}${I18n.of(context).mask_coin}', - showDivider: false, + showDivider: true, onPressed: () { Navigator.of(context).push( new MaterialPageRoute( @@ -2137,86 +1922,12 @@ class _ProfilePageState extends State ); }, ), + _buildPicture(), ], ), ); } - Widget _buildHistory() { - //历史访客 - return Container( - margin: EdgeInsets.only(top: Separate_Size), - padding: EdgeInsets.symmetric(horizontal: 10), - child: FullWidthButton( - title: I18n.of(context).historical_visitor, - description: I18n.of(context) - .visit_you - .replaceFirst('/s1', userInfo.accessNum.toString()), - showDivider: false, - showRightIcon: false, - onPressed: () {}, - ), - decoration: BoxDecoration( - color: Colors.white, - border: Border( - top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), - ); - } - - //恢复焚阅照片 - Widget _buildRset() { - //历史访客 - return isMyself - ? Container( - margin: EdgeInsets.only(top: Separate_Size), - //padding: EdgeInsets.symmetric(horizontal: 10), - child: FullWidthButton( - title: I18n.of(context) - .visit_photo - .replaceFirst('/s1', userInfo.burnNum.toString()), - description: I18n.of(context).recovery_photo, - showDivider: false, - showRightIcon: false, - onPressed: () async { - CustomUI.buildOneConfirm( - context, - I18n.of(context).confrim_recovery, - I18n.of(context).determine, () async { - HttpUtil().resetPhoto(() { - Navigator.of(context).pop(); - userInfo.burnNum = 0; - setState(() {}); - }); - }); - }, - ), - decoration: BoxDecoration( - color: Colors.white, - border: Border(top: Constants.GreyBorderSide)), - ) - : Container(); - } - - Widget _buildShare() { - //分享 - return Container( - margin: EdgeInsets.only(top: Separate_Size, bottom: Separate_Size), - padding: EdgeInsets.symmetric(horizontal: 10), - child: FullWidthButton( - showRightIcon: false, - title: I18n.of(context).share_app, - showDivider: false, - onPressed: () { - Share.share('https://henho.jphgames.com/'); - }, - ), - decoration: BoxDecoration( - color: Colors.white, - border: Border( - top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), - ); - } - Widget _buildIcon(code, str, isCanHit, callback, {iconSize = 28.0}) { var color = isCanHit ? Constants.BlueTextColor : Constants.GreyTextColor; return InkWell( @@ -2257,45 +1968,16 @@ class _ProfilePageState extends State titleSpacing: isMyself ? -40 : NavigationToolbar.kMiddleSpacing, title: isMyself ? Text( - I18n.of(context).me, + userInfo.nickName, + //I18n.of(context).me, textScaleFactor: 1.0, style: Constants.MainTitleStyle, ) - : Container( - alignment: Alignment.center, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - WebData().subUserName( - Provider.of(context) - .getRefName(userInfo.userId, userInfo.nickName)), - textScaleFactor: 1.0, - style: TextStyle(color: Constants.BlackTextColor)), - isAttestation && !isMan - ? Container( - height: 13, - margin: EdgeInsets.only(left: 5), - padding: EdgeInsets.only(left: 5, right: 5), - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(10), - color: Constants.PurpleBackgroundColor, - ), - child: Text( - 'Real', - textScaleFactor: 1.0, - style: TextStyle(fontSize: 10, color: Colors.white), - )) - : Text(''), - isVip && isMan - ? Container( - margin: EdgeInsets.only(left: 5), - child: - isSvip ? Constants.svipIcon : Constants.vipIcon) - : Text(''), - ], - )), + : Text( + WebData().subUserName(Provider.of(context) + .getRefName(userInfo.userId, userInfo.nickName)), + textScaleFactor: 1.0, + style: TextStyle(color: Constants.BlackTextColor)), centerTitle: !isMyself, elevation: 1, actions: [ @@ -2308,66 +1990,18 @@ class _ProfilePageState extends State backgroundColor: Constants.GreyBackgroundColor, radius: 15.75, child: Icon( - IconData(0xe658, fontFamily: 'iconfont'), + IconData(0xe685, fontFamily: 'iconfont'), color: Constants.BlackTextColor, size: 20, )), onTap: () { - AppNavigator.pushQrPage(context); + Share.share('https://henho.jphgames.com/'); }, ), ) : Container(), isMyself - ? Container( - padding: EdgeInsets.only(right: 15), - alignment: Alignment.center, - child: new InkWell( - child: CircleAvatar( - backgroundColor: Constants.GreyBackgroundColor, - radius: 15.75, - child: Icon( - Icons.settings, - //IconData(0xe6e5, fontFamily: 'iconfont'), - color: Constants.BlackTextColor, - size: 22, - )), - onTap: () { - Navigator.of(context).push( - new MaterialPageRoute( - builder: (context) { - return SystemEditPage(); - }, - ), - ); - }, - ), - ) - : Container(), - isMyself - ? Container( - // padding: EdgeInsets.only(right: 10), - // alignment: Alignment.center, - // child: new InkWell( - // child: CircleAvatar( - // backgroundColor: Constants.GreyBackgroundColor, - // radius: 15.75, - // child: Icon( - // IconData(0xe6e5, fontFamily: 'iconfont'), - // color: Constants.BlackTextColor, - // size: 25, - // )), - // onTap: () { - // Navigator.of(context).push( - // new MaterialPageRoute( - // builder: (context) { - // return EditPage(isEditPage: true); - // }, - // ), - // ); - // }, - // ), - ) + ? Container() : Container( alignment: Alignment.center, child: new InkWell( @@ -2494,7 +2128,7 @@ class _ProfilePageState extends State : (widget.addMode == 2 ? [_dealInvite()] : [ - _buildIcon(0xe633, I18n.of(context).evaluate, true, + _buildIcon(0xe68b, I18n.of(context).evaluate, true, () async { Map data = { "userid": userInfo.userId, @@ -2517,9 +2151,6 @@ class _ProfilePageState extends State showToast(resData['msg']); } }), - _buildIcon(0xe637, I18n.of(context).private_chat, - isCanWatch, isCanWatch ? buyChatAccount : null, - iconSize: 24.0), _buildIcon( 0xe62f, I18n.of(context).chat, isCanWatch, onAudio) ]), diff --git a/lib/home/SystemEditPage.dart b/lib/home/SystemEditPage.dart index 8683ec6..09ab485 100644 --- a/lib/home/SystemEditPage.dart +++ b/lib/home/SystemEditPage.dart @@ -78,6 +78,7 @@ class SystemEditPageState extends State { textScaleFactor: 1.0, ), centerTitle: true, + elevation: 1, leading: CustomUI.buildCustomLeading(context), ), body: SafeArea( @@ -107,6 +108,8 @@ class SystemEditPageState extends State { _buildMyEvaluation(), _buildVersion(), _buildHelp(), + _buildHistory(), + _buildRset(), SizedBox(height: Separate_Size), _buildLogout(), SizedBox(height: Separate_Size), @@ -114,6 +117,56 @@ class SystemEditPageState extends State { ); } + //恢复焚阅照片 + Widget _buildRset() { + //历史访客 + return Container( + margin: EdgeInsets.only(top: Separate_Size), + padding: EdgeInsets.symmetric(horizontal: 10), + child: FullWidthButton( + title: I18n.of(context) + .visit_photo + .replaceFirst('/s1', UserData().basicInfo.burnNum.toString()), + description: I18n.of(context).recovery_photo, + showDivider: false, + showRightIcon: false, + onPressed: () async { + CustomUI.buildOneConfirm(context, I18n.of(context).confrim_recovery, + I18n.of(context).determine, () async { + HttpUtil().resetPhoto(() { + Navigator.of(context).pop(); + UserData().basicInfo.burnNum = 0; + setState(() {}); + }); + }); + }, + ), + decoration: BoxDecoration( + color: Colors.white, border: Border(top: Constants.GreyBorderSide)), + ); + } + + Widget _buildHistory() { + //历史访客 + return Container( + margin: EdgeInsets.only(top: Separate_Size), + padding: EdgeInsets.symmetric(horizontal: 10), + child: FullWidthButton( + title: I18n.of(context).historical_visitor, + description: I18n.of(context) + .visit_you + .replaceFirst('/s1', UserData().basicInfo.accessNum.toString()), + showDivider: false, + showRightIcon: false, + onPressed: () {}, + ), + decoration: BoxDecoration( + color: Colors.white, + border: Border( + top: Constants.GreyBorderSide, bottom: Constants.GreyBorderSide)), + ); + } + //有问题需要帮助 Widget _buildHelp() { return Container( @@ -398,7 +451,6 @@ class SystemEditPageState extends State { }, true); setStatusBar(); - } //清楚图片缓存 @@ -512,17 +564,14 @@ class SystemEditPageState extends State { context, I18n.of(context).exit, I18n.of(context).determine, () { userLogout(); HttpUtil().postLoginOut(context); - }); } - - static userLogout(){ + static userLogout() { LocalNotificationUtil().removeAlias(); ReceiveShareFile.dispose(); } - //退出登陆 Widget _buildLogout() { return Container( diff --git a/lib/home/friend_page.dart b/lib/home/friend_page.dart index 1df91ee..6b06981 100644 --- a/lib/home/friend_page.dart +++ b/lib/home/friend_page.dart @@ -17,10 +17,8 @@ import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/screen.dart'; import 'package:dio/dio.dart'; import 'package:oktoast/oktoast.dart'; -import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import 'address_book.dart'; List showUserList = []; diff --git a/lib/home/homeMain.dart b/lib/home/homeMain.dart index c3fad2a..7d8ec1a 100644 --- a/lib/home/homeMain.dart +++ b/lib/home/homeMain.dart @@ -34,7 +34,6 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:chat/utils/my_bottom_navigation_bar.dart' as myBottm; import 'friend_page.dart'; -import 'group_chat_page.dart'; class NavigationIconView { final BottomNavigationBarItem item; diff --git a/lib/home/last_chat_record_widget.dart b/lib/home/last_chat_record_widget.dart index 588003e..ebd9f7b 100644 --- a/lib/home/last_chat_record_widget.dart +++ b/lib/home/last_chat_record_widget.dart @@ -110,7 +110,7 @@ class _LastChatPageState extends State { : Container(), NetStateWidget(), widget.needRobot ? _translateRobot() : Container(), - _CompanyServer(), + _companyServer(), lastMsgList.length == 0 ? _emptyContent() : _chatRecordsList(lastMsgList) @@ -155,7 +155,7 @@ class _LastChatPageState extends State { )); } - Widget _CompanyServer() { + Widget _companyServer() { return InkWell( onTap: () { AppNavigator.pushCompanyServerPage(context); diff --git a/lib/home/my_headview.dart b/lib/home/my_headview.dart new file mode 100644 index 0000000..7b4a5e0 --- /dev/null +++ b/lib/home/my_headview.dart @@ -0,0 +1,179 @@ +import 'dart:io'; + +import 'package:chat/generated/i18n.dart'; +import 'package:chat/utils/CustomUI.dart'; +import 'package:chat/utils/LoadingDialog.dart'; +import 'package:chat/utils/MessageMgr.dart'; +import 'package:chat/utils/screen.dart'; +import 'package:extended_image/extended_image.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:image_cropper/image_cropper.dart'; +import 'package:image_picker/image_picker.dart'; +import '../utils/HttpUtil.dart'; +import 'package:dio/dio.dart'; +import "../data/UserData.dart"; +import '../utils/TokenMgr.dart'; + +class MyHeadViewPage extends StatefulWidget { + MyHeadViewPage({Key key}) : super(key: key); + + @override + _MyHeadViewPageState createState() => new _MyHeadViewPageState(); +} + +class _MyHeadViewPageState extends State + with SingleTickerProviderStateMixin { + AnimationController _animationController; + Animation _animation; + Function animationListener; + List doubleTapScales = [1.0, 2.0]; + + @override + void initState() { + super.initState(); + _animationController = AnimationController( + duration: const Duration(milliseconds: 150), vsync: this); + } + + @override + Widget build(BuildContext context) { + return Scaffold( + body: SafeArea(child: _buildBody()), + backgroundColor: Colors.black, + ); + } + + Widget _buildHeadView() { + return ExtendedImageGesturePageView( + children: [ + InkWell( + onTap: () { + Navigator.pop(context); + }, + child: ExtendedImage.network( + UserData().basicInfo.headimgurl, + fit: BoxFit.contain, + mode: ExtendedImageMode.gesture, + initGestureConfigHandler: (state) { + return GestureConfig( + inPageView: true, + maxScale: 5, + initialAlignment: InitialAlignment.topCenter, + animationMaxScale: 5, + cacheGesture: false); + }, + onDoubleTap: (ExtendedImageGestureState state) { + var pointerDownPosition = state.pointerDownPosition; + double begin = state.gestureDetails.totalScale; + double end; + //remove old + _animation?.removeListener(animationListener); + + //stop pre + _animationController.stop(); + + //reset to use + _animationController.reset(); + + if (begin == doubleTapScales[0]) { + end = doubleTapScales[1]; + } else { + end = doubleTapScales[0]; + } + + animationListener = () { + //print(_animation.value); + state.handleDoubleTap( + scale: _animation.value, + doubleTapPosition: pointerDownPosition); + }; + _animation = _animationController + .drive(Tween(begin: begin, end: end)); + + _animation.addListener(animationListener); + + _animationController.forward(); + }, + )) + ], + ); + } + + Widget _buildBody() { + return Stack( + children: [ + _buildHeadView(), + Positioned( + child: _buildChangeButton(), + bottom: 40, + ) + ], + ); + } + + Widget _buildChangeButton() { + return InkWell( + onTap: _sendPicture, + child: Container( + alignment: Alignment.center, + width: Screen.width, + child: Container( + height: 47.5, + alignment: Alignment.center, + width: 230, + child: Text( + I18n.of(context).upload_avatar, + style: TextStyle(color: Colors.white, fontSize: 17.5), + ), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(24), + color: Color(0xFF181818)), + ))); + } + + void _sendPicture() async { + if (await CustomUI.showPhotoPermissionSetting(context)) { + showDialog( + context: context, + barrierDismissible: false, + builder: (BuildContext context) { + return LoadingDialog( + text: "", + ); + }); + var tempFile = await ImagePicker.pickImage(source: ImageSource.gallery); + Navigator.of(context).pop(); + if (tempFile != null) { + _cropPicture(tempFile); + } + } + } + + void _cropPicture(tempFile) async { + File croppedFile = await ImageCropper.cropImage( + sourcePath: tempFile.path, + aspectRatio: CropAspectRatio(ratioX: 1, ratioY: 1), + ); + + if (croppedFile != null) { + Map data = {"type": 1, "userId": UserData().basicInfo.userId}; + data['sign'] = TokenMgr().getSign(data); + Response res = await HttpUtil() + .uploadFile(croppedFile, data, 'upload/file/postflie', 'image'); + var resData = res.data; + if (resData['code'] == 0) { + UserData().basicInfo.headimgurl = resData['msg']; + MessageMgr().emit('change_my_headview'); + if (mounted) { + setState(() {}); + } + } + } + } + + @override + void dispose() { + super.dispose(); + } +} diff --git a/lib/home/new_addfriends.dart b/lib/home/new_addfriends.dart index 82010a2..4ddb5c8 100644 --- a/lib/home/new_addfriends.dart +++ b/lib/home/new_addfriends.dart @@ -1,8 +1,6 @@ import 'dart:io'; -import 'package:cached_network_image/cached_network_image.dart'; import 'package:chat/home/global_search.dart'; -import 'package:chat/home/new_friends.dart'; import 'package:chat/models/friends_info.dart'; import 'package:chat/utils/TutorialOverlay.dart'; import 'package:flutter/material.dart'; @@ -10,16 +8,9 @@ import 'package:chat/data/UserData.dart'; import 'package:chat/data/constants.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/utils/CustomUI.dart'; -import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/MessageMgr.dart'; -import 'package:chat/utils/TokenMgr.dart'; -import 'package:chat/utils/conversation_table.dart'; -import 'package:chat/utils/friend_list_mgr.dart'; import 'package:chat/utils/screen.dart'; -import 'package:dio/dio.dart'; -import 'package:oktoast/oktoast.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:shared_preferences/shared_preferences.dart'; import 'address_book.dart'; import 'my_qr.dart'; diff --git a/lib/home/new_friends.dart b/lib/home/new_friends.dart index c7e046e..94fbd1f 100644 --- a/lib/home/new_friends.dart +++ b/lib/home/new_friends.dart @@ -8,7 +8,6 @@ import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/TokenMgr.dart'; import 'package:chat/utils/conversation_table.dart'; -import 'package:chat/utils/screen.dart'; import 'package:dio/dio.dart'; import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/material.dart'; diff --git a/lib/home/photo_page.dart b/lib/home/photo_page.dart new file mode 100644 index 0000000..9ea5858 --- /dev/null +++ b/lib/home/photo_page.dart @@ -0,0 +1,516 @@ +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:chat/data/UserData.dart'; +import 'package:chat/data/constants.dart'; +import 'package:chat/generated/i18n.dart'; +import 'package:chat/home/rich_title.dart'; +import 'package:chat/models/UserInfo.dart'; +import 'package:chat/models/money_change.dart'; +import 'package:chat/models/ref_name_provider.dart'; +import 'package:chat/utils/ChargeMoney.dart'; +import 'package:chat/utils/CustomUI.dart'; +import 'package:chat/utils/HttpUtil.dart'; +import 'package:chat/utils/MessageMgr.dart'; +import 'package:chat/utils/PicSwiper.dart'; +import 'package:chat/utils/TokenMgr.dart'; +import 'package:chat/utils/file_cache_mgr.dart'; +import 'package:chat/utils/screen.dart'; +import 'package:dio/dio.dart'; +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:multi_image_picker/multi_image_picker.dart'; +import 'package:oktoast/oktoast.dart'; +import 'package:provider/provider.dart'; + +import 'VipPage.dart'; + +const double LeftSize = 80; +const MaxImgSize = 20; + +class PhotoPage extends StatefulWidget { + @required + final UserInfo userInfo; + PhotoPage({Key key, this.userInfo}) : super(key: key); + + @override + _PhotoPageState createState() => new _PhotoPageState(); +} + +class _PhotoPageState extends State { + bool isMyself = false; + bool isMan = false; + Map imgList = {}; + bool isLoadingFinish = false; + double imgWidth = (Screen.width - LeftSize - 60) / 3; + var resultList = []; + bool isBuyPicture = false; + + @override + void initState() { + super.initState(); + isMyself = widget.userInfo.userId == UserData().basicInfo.userId; + isMan = widget.userInfo.sex == 1; + isBuyPicture = (isMyself || + widget.userInfo.photoAut == 0 || + widget.userInfo.payStatus == 1); + getImg(); + MessageMgr().on('refresh_photo', msgRefreshPhoto); + } + + msgRefreshPhoto(data) { + getImg(); + } + + void getImg() async { + Map data = { + "visitUserId": UserData().basicInfo.userId, + "userId": widget.userInfo.userId, + }; + data['sign'] = TokenMgr().getSign(data); + + Response res = await HttpUtil().post('user/personal/album', data: data); + if (res == null) { + return; + } + isLoadingFinish = true; + Map resData = res.data; + if (resData['code'] == 0) { + imgList = {}; + resultList = resData['data'] ?? []; + for (int i = 0; i < resultList.length; i++) { + var temp = DateTime.parse(resultList[i]['CreatTime']); + if (imgList[temp.year] == null) { + imgList[temp.year] = { + 1: [], + 2: [], + 3: [], + 4: [], + 5: [], + 6: [], + 7: [], + 8: [], + 9: [], + 10: [], + 11: [], + 12: [], + }; + } + imgList[temp.year][temp.month].add(resultList[i]); + } + + if (isMyself) { + UserData().picNum = 0; + for (int i = 0; i < resultList.length; i++) { + if (resultList[i]['Status'] == 1) { + UserData().picNum++; + } + if (resultList[i]['Status'] == 0 || resultList[i]['Status'] == 2) { + UserData().haveReview = true; + } + } + } + + if (mounted) { + setState(() {}); + } + } + } + + @override + Widget build(BuildContext context) { + var content = Scaffold( + appBar: AppBar( + title: !isMyself + ? Text( + (isMyself + ? I18n.of(context).my_album + : (isMan + ? I18n.of(context).his_photo + : I18n.of(context).her_photo)), + textScaleFactor: 1.0, + style: TextStyle( + color: AppColors.NewAppbarTextColor, fontSize: 20), + ) + : Column(children: [ + Text( + (isMyself + ? I18n.of(context).my_album + : (isMan + ? I18n.of(context).his_photo + : I18n.of(context).her_photo)), + textScaleFactor: 1.0, + style: TextStyle( + color: AppColors.NewAppbarTextColor, fontSize: 20), + ), + Text( + '${resultList.length}/$MaxImgSize', + style: TextStyle(fontSize: 11), + ) + ]), + leading: CustomUI.buildCustomLeading(context), + titleSpacing: -10, + centerTitle: true, + elevation: 1), + backgroundColor: Colors.white, + body: SafeArea( + child: SingleChildScrollView( + child: Column(children: _buildBody()), + )), + ); + + return CustomUI.buildPageLoading(context, content, !isLoadingFinish); + } + + buyPhoto() { + //女性用户付费,男性用户会员的话免费解锁,非会员付费解锁 + becomeVip() { + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return VipPage(); + }, + ), + ); + } + + payCallback() { + if (Provider.of(context).money < + widget.userInfo.price) { + Navigator.of(context).pop(); + CustomUI.buildOneConfirm(context, I18n.of(context).balance_insufficien, + I18n.of(context).recharge, () { + Navigator.of(context).pop(); + ChargeMoney.showChargeSheet(context, () { + setState(() {}); + }); + }); + return; + } + Navigator.of(context).pop(); + HttpUtil().buyPictures( + widget.userInfo.price, widget.userInfo.userId, context, () { + setState(() { + isBuyPicture = true; + widget.userInfo.payStatus = 1; + }); + }); + } + + freeTime() { + HttpUtil().userFreeTime(context, widget.userInfo.userId, 1, () { + UserData().basicInfo.usedNum++; + Navigator.of(context).pop(); + setState(() { + isBuyPicture = true; + widget.userInfo.payStatus = 1; + }); + }); + } + + String title = I18n.of(context).unlock_user.replaceFirst( + '/s1', + Provider.of(context) + .getRefName(widget.userInfo.userId, widget.userInfo.nickName), + ); + + if (!UserData().isMan()) { + CustomUI.buildOneConfirm( + context, + title, + I18n.of(context) + .pay_unlock + .replaceFirst('/s1', widget.userInfo.price.toString()), + payCallback); + } else if (UserData().isVip) { + if (UserData().basicInfo.freeNum < UserData().basicInfo.usedNum) { + CustomUI.buildOneConfirm( + context, + title, + I18n.of(context) + .pay_unlock + .replaceFirst('/s1', widget.userInfo.price.toString()), + payCallback); + } else { + CustomUI.buildOneConfirm( + context, title, I18n.of(context).unlock_choose, freeTime); + } + } else { + CustomUI.buildTowConfirm( + context, + title, + I18n.of(context).become_member, + becomeVip, + I18n.of(context) + .pay_unlock + .replaceFirst('/s1', widget.userInfo.price.toString()), + payCallback); + } + } + + Widget _buildLockWidget() { + TitleItem title; + if (!isMan) { + title = UserData().isVip + ? TitleItem( + title: I18n.of(context).unlock_user, + name: Provider.of(context) + .getRefName(widget.userInfo.userId, widget.userInfo.nickName), + ) + : TitleItem( + title: I18n.of(context).free_unlock, + name: widget.userInfo.price.toString() + + I18n.of(context).mask_coin); + } else { + title = TitleItem( + title: I18n.of(context).pay_unlock, + name: widget.userInfo.price.toString()); + } + return Container( + height: Screen.height * 0.7, + alignment: Alignment.center, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset( + 'assets/images/lock_photo.png', + width: 160, + //color: Colors.grey[700], + ), + Container( + margin: EdgeInsets.only(top: 20), + alignment: Alignment.center, + child: Text( + isMan ? I18n.of(context).set_lock : I18n.of(context).set_lock2, + textScaleFactor: 1.0, + style: TextStyle( + color: Colors.grey[700], + fontSize: 15, + fontWeight: FontWeight.bold), + ), + ), + Container( + margin: EdgeInsets.only(top: 8), + alignment: Alignment.center, + child: RichText( + text: TextSpan( + children: RichTitle.getRichText(title, + titleStyle: + TextStyle(color: Colors.grey[700], fontSize: 13), + nameStyle: TextStyle(color: Colors.red, fontSize: 13))), + ), + ), + InkWell( + onTap: buyPhoto, + child: Container( + margin: EdgeInsets.only(top: 30), + padding: EdgeInsets.only(top: 6, bottom: 6), + width: 100, + alignment: Alignment.center, + decoration: Constants.ConfirmBUttonBoxDecoration, + child: Text( + I18n.of(context).unlock, + textScaleFactor: 1.0, + style: TextStyle(color: Colors.white, fontSize: 18), + ), + )), + ], + )); + } + + List _buildBody() { + List list = [_buildUpload()]; + if (imgList.length == 0 && isLoadingFinish && !isMyself) { + list.add(CustomUI.buildNoData(context)); + return list; + } + + if (!isBuyPicture) { + list.add(_buildLockWidget()); + return list; + } + + imgList.keys.forEach((k) { + list.add(_buildYear(k)); + }); + return list; + } + + //上传相册 + void _uploadPhoto() async { + int leftLength = MaxImgSize - imgList.length; + if (leftLength <= 0) { + showToast(I18n.of(context) + .max_upload_size + .replaceFirst('/s1', MaxImgSize.toString())); + return; + } + List resultList = List(); + + resultList = await MultiImagePicker.pickImages( + maxImages: leftLength > 9 ? 9 : leftLength, + enableCamera: false, + selectedAssets: [], + cupertinoOptions: CupertinoOptions(takePhotoIcon: "chat"), + materialOptions: MaterialOptions( + actionBarColor: "#50A7F9", + actionBarTitle: "Hibok", + allViewTitle: "", + useDetailsView: true, + selectCircleStrokeColor: "#000000", + ), + ); + + if (resultList != null && resultList.length > 0) { + List fileList = []; + for (var i = 0; i < resultList.length; i++) { + Asset photoEntity = resultList[i]; + print('名字:${photoEntity.name}'); + ByteData byteData = await photoEntity.getByteData(); + File file = await FileCacheMgr().writeFile( + 'temp-photo-${DateTime.now().millisecondsSinceEpoch}.png', + byteData.buffer.asInt8List(0)); + + fileList.add(file); + } + print('文件列表${fileList.length}'); + Map data = {"type": 2, "userId": UserData().basicInfo.userId}; + data['sign'] = TokenMgr().getSign(data); + data['sex'] = UserData().basicInfo.sex; + data['isBurn'] = 0; + Response res = await HttpUtil().uploadFiles( + fileList, data, 'upload/post/postfiles', 'image', + isShowLoading: true); + var resData = res.data; + if (resData['code'] == 0) { + if (resData['data']['msg'] != '' && resData['data']['msg'] != null) { + showToast(resData['data']['msg']); + } + if (resData['msg'].split('|').length != fileList.length) { + showToast(I18n.of(context).hava_error_photo); + } + //MessageMgr().emit('refresh_photo'); + getImg(); + } else { + showToast(resData['msg']); + } + } + } + + Widget _buildUpload() { + return isMyself + ? Container( + margin: EdgeInsets.only(top: 20), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(right: 15), + width: LeftSize, + child: Text( + I18n.of(context).upload1, + style: + TextStyle(fontSize: 15, fontWeight: FontWeight.w600), + )), + InkWell( + onTap: _uploadPhoto, + child: Container( + width: imgWidth, + height: imgWidth, + margin: EdgeInsets.all(5), + decoration: BoxDecoration( + color: Color(0xFFEDEDED), + borderRadius: BorderRadius.circular(10)), + child: Icon( + IconData(0xe686, fontFamily: Constants.IconFontFamily), + size: 35, + color: Colors.white, + ), + )) + ], + ), + ) + : Container(); + } + + Widget _buildYear(int year) { + var list = [_buildYearTips(year)]; + imgList[year].keys.forEach((k) { + if (imgList[year][k].length > 0) { + list.add(_buildMonth(year, k)); + } + }); + return Container( + width: Screen.width, + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: list, + )); + } + + Widget _buildYearTips(int year) { + return Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(right: 15, top: 20, bottom: 18), + width: LeftSize, + child: Text( + '$year${I18n.of(context).year}', + style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600), + )); + } + + Widget _buildMonth(int year, int month) { + if (imgList[year] == null || imgList[year][month] == null) { + return Container(); + } + List pisc = []; + imgList[year][month].forEach((f) { + pisc.add(PicSwiperItem( + f['ImgUrl'], + id: f['Id'], + type: f['Type'], + isWatch: f['IsCheck'] == 1, + userId: widget.userInfo.userId, + isBuy: f['PayStatus'] == 1, + isCheck: f['Status'] == 0, + )); + }); + + List list = []; + imgList[year][month].forEach((data) { + bool isWatch = data['IsCheck'] == 1; + double raduis = 10; + list.add(CustomUI.buildImgCover(data['Id'], pisc, data['ImgUrl'], + imgWidth, raduis, isWatch, context, data['Type'], + isMyself: isMyself, + payStatus: data['PayStatus'], + state: isMan ? 1 : data['Status'])); + }); + return Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + alignment: Alignment.centerRight, + margin: EdgeInsets.only(right: 15, top: 1), + width: LeftSize, + child: Text( + '$month${I18n.of(context).month}', + style: TextStyle(fontSize: 15, fontWeight: FontWeight.w600), + )), + Container( + width: Screen.width - LeftSize - 15, + child: Wrap( + crossAxisAlignment: WrapCrossAlignment.start, + children: list, + )) + ], + ); + } + + @override + void dispose() { + super.dispose(); + MessageMgr().off('refresh_photo', msgRefreshPhoto); + } +} diff --git a/lib/models/unread_count_provider.dart b/lib/models/unread_count_provider.dart index 74017c8..094bb80 100644 --- a/lib/models/unread_count_provider.dart +++ b/lib/models/unread_count_provider.dart @@ -1,4 +1,6 @@ +import 'package:chat/data/constants.dart'; import 'package:chat/utils/MessageMgr.dart'; +import 'package:chat/utils/sp_utils.dart'; class UnreadCountProvider { //未读消息条数管理 @@ -16,12 +18,41 @@ class UnreadCountProvider { MessageMgr().emit('Update UnreadCount', sessionId); } + initUnreadAlter() async { + //初始化@消息 + List alterList = await SPUtils.getStringList(Constants.GroupAlterKey) ?? []; + for (int i = 0; i < alterList.length; i++) { + var list = alterList[i].split('-'); + if (list.length == 2) { + isHaveAlterme[int.parse(list[0])] = int.parse(list[1]); + } + } + } + getHavaAltertime(int sessionId) { return isHaveAlterme[sessionId] ?? null; } setAlterMe(int sessionId, int time) { - if (isHaveAlterme[sessionId] == null) isHaveAlterme[sessionId] = time; + if (isHaveAlterme[sessionId] == null) { + isHaveAlterme[sessionId] = time; + saveGroupAlterToLocal(); + } + } + + saveGroupAlterToLocal() { + List alterList = []; + isHaveAlterme.forEach((k, v) { + if (v != null) { + alterList.add('$k-$v'); + } + }); + SPUtils.saveList(Constants.GroupAlterKey, alterList); + } + + signUnreadAlter(int sessionId) { + isHaveAlterme[sessionId] = null; + saveGroupAlterToLocal(); } clear() { @@ -45,7 +76,7 @@ class UnreadCountProvider { print('消除未读标记:$sessionId'); int count = getUnreadCount(sessionId); - isHaveAlterme[sessionId] = null; + signUnreadAlter(sessionId); if (count > 0) { unreadCountMap[sessionId] = 0; diff --git a/lib/utils/CustomUI.dart b/lib/utils/CustomUI.dart index a3df280..84dccdb 100644 --- a/lib/utils/CustomUI.dart +++ b/lib/utils/CustomUI.dart @@ -382,7 +382,7 @@ class CustomUI { static Widget buildImgCover( int imgId, - List pics, + List pics, String imgUrl, double width, double raduis, diff --git a/lib/utils/FullWithButton.dart b/lib/utils/FullWithButton.dart index 9c79f01..2dd0390 100644 --- a/lib/utils/FullWithButton.dart +++ b/lib/utils/FullWithButton.dart @@ -11,6 +11,8 @@ class FullWidthButton extends StatelessWidget { final String description; final Color descriptionColor; final bool showRightIcon; + final int iconCode; + final iconColor; final Widget extendWidget; @@ -21,8 +23,9 @@ class FullWidthButton extends StatelessWidget { this.descriptionColor, this.showRightIcon: true, this.showDivider: false, - this.extendWidget - }) + this.iconCode, + this.iconColor, + this.extendWidget}) : assert(title != null), assert(onPressed != null); @@ -32,28 +35,39 @@ class FullWidthButton extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ + iconCode == null + ? Container() + : Container( + margin: EdgeInsets.only(right: 5,bottom: 3), + child: Icon( + IconData( + iconCode, + fontFamily: 'iconfont', + ), + color: Color(iconColor), + size: 20, + )), SizedBox(width: Hor_Padding), Expanded( child: Text( title, textScaleFactor: 1.0, - style: TextStyle( - fontSize: 14, - fontWeight: FontWeight.normal - ), + style: TextStyle(fontSize: 14, fontWeight: FontWeight.normal), ), ), - extendWidget!=null?extendWidget: Text( - description, - textScaleFactor: 1.0, - textAlign: TextAlign.end, - style: TextStyle( - fontSize: 12, - fontWeight: FontWeight.normal, - color: descriptionColor == null - ? const Color(0xFF818181) - : descriptionColor), - ), + extendWidget != null + ? extendWidget + : Text( + description, + textScaleFactor: 1.0, + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 12, + fontWeight: FontWeight.normal, + color: descriptionColor == null + ? const Color(0xFF818181) + : descriptionColor), + ), showRightIcon ? Padding( padding: EdgeInsets.only(bottom: 1.5), diff --git a/lib/utils/HttpUtil.dart b/lib/utils/HttpUtil.dart index a56dd3d..90ec477 100644 --- a/lib/utils/HttpUtil.dart +++ b/lib/utils/HttpUtil.dart @@ -282,7 +282,7 @@ class HttpUtil { } Map resData = res.data; print('用户信息resData $resData'); - if (resData['code'] == 0) { + if (resData['code'] == 0 && resData != null) { var info = UserInfo.fromJson(resData['data']); info.isBlackened ? BlacklistMgr.addBlackListMe(info.userId) diff --git a/lib/utils/sp_utils.dart b/lib/utils/sp_utils.dart index 515d4f8..ba1c5f5 100755 --- a/lib/utils/sp_utils.dart +++ b/lib/utils/sp_utils.dart @@ -1,10 +1,6 @@ - import 'package:shared_preferences/shared_preferences.dart'; class SPUtils { - - - static saveString(String key, value) async { SharedPreferences spf = await SharedPreferences.getInstance(); spf.setString(key, value); @@ -15,7 +11,6 @@ class SPUtils { spf.setStringList(key, value); } - static saveBool(String key, value) async { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.setBool(key, value); @@ -36,6 +31,11 @@ class SPUtils { return prefs.get(key); } + static getStringList(String key) async { + SharedPreferences prefs = await SharedPreferences.getInstance(); + return prefs.getStringList(key); + } + static remove(String key) async { SharedPreferences prefs = await SharedPreferences.getInstance(); prefs.remove(key); diff --git a/pubspec.yaml b/pubspec.yaml index a7df44e..5e04abf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -311,6 +311,8 @@ flutter: - assets/images/gift_2.png - assets/images/ext_txt.png - assets/images/gift_show_2_1.png + - assets/images/up.png + - assets/images/lock_photo.png # assets/images/chat/* - assets/images/chat/emoji.png - assets/images/chat/onion.png