diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..bbfd110 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + // 使用 IntelliSense 了解相关属性。 + // 悬停以查看现有属性的描述。 + // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Flutter", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 5240342..ba24ceb 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -638,6 +638,11 @@ class _GroupChatPageItemState extends State child: hasHeadImg ? CachedNetworkImage( imageUrl: UserData().basicInfo.headimgurl, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + width: 40, + height: 40, + ), width: 40, height: 40, ) @@ -1279,6 +1284,11 @@ class _GroupChatPageItemState extends State child: hasHeadImg ? CachedNetworkImage( imageUrl: memberModel.avtar, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + width: 40, + height: 40, + ), width: 40, height: 40, ) @@ -1288,7 +1298,7 @@ class _GroupChatPageItemState extends State child: Image.asset(R.assetsImagesDefaultNorAvatar))), onTap: () { AppNavigator.pushProfileInfoPage(context, memberModel.memberId, - fromWhere: 2,addMode: 1); + fromWhere: 2, addMode: 1); }, onLongPress: () { print('long press user'); diff --git a/lib/data/constants.dart b/lib/data/constants.dart index c8d6515..d3d075c 100644 --- a/lib/data/constants.dart +++ b/lib/data/constants.dart @@ -91,9 +91,10 @@ 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; //修改备注 } //全局搜索类别 @@ -112,12 +113,12 @@ class Constants { //app全局key,处理content static final GlobalKey navigatorKey = GlobalKey(); - /// 获取当前的state static NavigatorState getCurrentState() => navigatorKey.currentState; /// 获取当前的context - static BuildContext getCurrentContext() => navigatorKey.currentState.overlay.context;//navigatorKey.currentContext; + static BuildContext getCurrentContext() => + navigatorKey.currentState.overlay.context; //navigatorKey.currentContext; ///在pubspec.yaml中修改版本号 static String versionName = '1.0.0'; @@ -138,6 +139,8 @@ class Constants { static const FullWidthIconButtonIconSize = 24.0; static const ProfileHeaderIconSize = 60.0; + static const int NameLength = 14; + static const AppId = 'wx02328a8853f058ad'; static const Secret = '9d401b6a8bfe7b2fe63b3bf5c040b2f2'; diff --git a/lib/home/ConversActionPage.dart b/lib/home/ConversActionPage.dart index eeeeb93..9c4104e 100644 --- a/lib/home/ConversActionPage.dart +++ b/lib/home/ConversActionPage.dart @@ -17,7 +17,13 @@ import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; -import '../data/constants.dart' show AppColors, AppStyles, Constants, GlobalSearchPageType, GroupOperatingPageType; +import '../data/constants.dart' + show + AppColors, + AppStyles, + Constants, + GlobalSearchPageType, + GroupOperatingPageType; import 'package:cached_network_image/cached_network_image.dart'; import 'create_group_view.dart'; @@ -253,7 +259,6 @@ class _ConversActionPageState extends State @override Widget build(BuildContext context) { - List groupList = GroupInfoMgr().groupInfoList; return Scaffold( @@ -350,9 +355,6 @@ class _ConversActionPageState extends State child: TabBarView( children: [ LastChatPage(), - - - ListView.builder( // controller: _scrollController, itemBuilder: (BuildContext context, int index) { @@ -365,7 +367,6 @@ class _ConversActionPageState extends State }, itemCount: groupList.length + 1, ), - ListView( children: [ SizedBox(height: 8.5), @@ -544,21 +545,23 @@ class _ConversActionPageState extends State ); }, child: Container( - height: ItemHeight-20, -// margin: EdgeInsets.only(top: 1.5, bottom:1), - decoration: BoxDecoration(color: Colors.white), - child: Row( - children: [ - SizedBox(width: LeftPadding), - _avatarIcon, - SizedBox(width: 14.0), - Text( - I18n.of(context).create_group_chat, - style: TextStyle(fontSize: 15.5), + padding: EdgeInsets.only(top: 14, bottom: 14), + color: Constants.GreyBackgroundColor, + child: Container( + height: ItemHeight, + decoration: BoxDecoration(color: Colors.white), + child: Row( + children: [ + SizedBox(width: LeftPadding), + _avatarIcon, + SizedBox(width: 14.0), + Text( + I18n.of(context).create_group_chat, + style: TextStyle(fontSize: 15.5), + ), + ], ), - ], - ), - )); + ))); Widget tips = Container( alignment: Alignment.centerLeft, @@ -573,7 +576,9 @@ class _ConversActionPageState extends State return Column( children: [ - SizedBox(height: 10,), + SizedBox( + height: 10, + ), CustomUI.buildSearchButton(context, () { Navigator.of(context).push( new MaterialPageRoute( @@ -584,10 +589,9 @@ class _ConversActionPageState extends State }, ), ); - },bottom: 10 ), + }, bottom: 10), _button, tips, - ], ); } @@ -599,6 +603,7 @@ class _ConversActionPageState extends State }); } } + updateGroupLastMsg(args) async { await GroupInfoMgr().sortGroupList(); if (mounted) { diff --git a/lib/home/EditData.dart b/lib/home/EditData.dart index e9a7c80..1f3a2af 100644 --- a/lib/home/EditData.dart +++ b/lib/home/EditData.dart @@ -334,7 +334,7 @@ class _EditPageState extends State { showToast(I18n.of(context).only1_8); return; } - if (dateRangeId.length == 0) { + if (dateRangeId.length == 0 && UserData().hasLocationPermission) { showToast(I18n.of(context).Please_select_a_resident_city); return; } @@ -742,7 +742,10 @@ 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), + true, nickNameController, true, (str) => nickname = str, + inputFormatters: [ + LengthLimitingTextInputFormatter(Constants.NameLength) + ]), _buildDivider(), _bottomBorderBox(I18n.of(context).country, country, false, null, countryId.length != 0, selectCountry), diff --git a/lib/home/ProfilePage.dart b/lib/home/ProfilePage.dart index 3329a89..f54a34c 100644 --- a/lib/home/ProfilePage.dart +++ b/lib/home/ProfilePage.dart @@ -2359,86 +2359,21 @@ class _ProfilePageState extends State InkWell( onTap: () async { Navigator.of(context).pop(); - - nickNameController.text = - Provider.of(context) - .getRefName(userInfo.userId, - userInfo.nickName); - - var confirm = CustomUI.buildConfirmBotton( - I18n.of(context).determine, () async { - nickNameController.text = - nickNameController.text.trim(); - if (nickNameController.text == null || - nickNameController.text.length > - 25) { - showToast(I18n.of(context).only1_8); - return; - } - Provider.of( - registKey.currentContext) - .changeRefName(userInfo.userId, - nickNameController.text, () { - Navigator.of(registKey.currentContext) - .pop(); - }); - }); - var tip = Column( - children: [ - Container( - margin: EdgeInsets.only(top: 20), - child: Text( - I18n.of(context).setRemark, - style: TextStyle( - color: - Constants.BlackTextColor, - fontSize: 16), - ), - ), - Container( - margin: EdgeInsets.only( - top: 23, bottom: 25), - decoration: BoxDecoration( - color: Colors.grey[200], - borderRadius: BorderRadius.all( - Radius.circular(8))), - child: TextField( - keyboardAppearance: - Brightness.light, - controller: nickNameController, - textAlign: TextAlign.center, - textInputAction: - TextInputAction.search, - style: TextStyle( - textBaseline: - TextBaseline.alphabetic, - fontSize: 14), - decoration: InputDecoration( - hintText: userInfo.nickName, - hintStyle: - TextStyle(fontSize: 12), - filled: true, - contentPadding: EdgeInsets.only( - top: 10, bottom: 10), - fillColor: Colors.transparent, - border: InputBorder.none, - ), - maxLines: 1, - inputFormatters: [ - LengthLimitingTextInputFormatter( - 15) - ], - ), - ) - ], + Navigator.of(context).push( + new MaterialPageRoute( + builder: (context) { + return AddFriendPage( + userId: userInfo.userId, + pageType: + SendMessagePageType.Remark, + originalName: Provider.of< + RefNameProvider>( + context) + .getRefName(userInfo.userId, + userInfo.nickName)); + }, + ), ); - var content = - CustomUI.buildConfirmContent( - tip, confirm); - CustomUI.buildTip( - registKey.currentContext, - '', - content); }, child: Container( alignment: Alignment.center, diff --git a/lib/home/add_friend.dart b/lib/home/add_friend.dart index e9b7845..536d296 100644 --- a/lib/home/add_friend.dart +++ b/lib/home/add_friend.dart @@ -1,11 +1,13 @@ import 'package:chat/data/constants.dart'; import 'package:chat/generated/i18n.dart'; +import 'package:chat/models/ref_name_provider.dart'; import 'package:chat/utils/CustomUI.dart'; import 'package:chat/utils/HttpUtil.dart'; import 'package:chat/utils/MessageMgr.dart'; import 'package:chat/utils/msgHandler.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; class AddFriendPage extends StatefulWidget { final int userId; @@ -32,6 +34,8 @@ class _AddFriendPageState extends State { print('AddFriendPage init111'); _txtCtrl.text = widget.originalName; + _hasdeleteIcon = + !(widget.originalName == null || widget.originalName == ""); } @override @@ -47,6 +51,9 @@ class _AddFriendPageState extends State { case SendMessagePageType.ChangeGroupNickName: title = I18n.of(context).my_group_nickname; break; + case SendMessagePageType.Remark: + title = I18n.of(context).setRemark; + break; default: } Widget appBar = new AppBar( @@ -73,7 +80,6 @@ class _AddFriendPageState extends State { }); break; case SendMessagePageType.ChangeGroupName: - Navigator.of(context).pop(); MsgHandler.updateGroupName(widget.userId, content); break; @@ -81,6 +87,12 @@ class _AddFriendPageState extends State { Navigator.of(context).pop(); MsgHandler.updateMemberRefName(widget.userId, content); break; + case SendMessagePageType.Remark: + Provider.of(context) + .changeRefName(widget.userId, content, () { + Navigator.of(context).pop(); + }); + break; default: } }, @@ -88,16 +100,16 @@ class _AddFriendPageState extends State { alignment: Alignment.center, margin: EdgeInsets.only(top: 15, bottom: 15, right: 20), height: 20, - padding: EdgeInsets.only(left: 18,right: 18,bottom: 1), + padding: EdgeInsets.only(left: 18, right: 18, bottom: 1), decoration: BoxDecoration( - color: Constants.ConfrimButtonColor, borderRadius: BorderRadius.circular(4.5)), + color: Constants.ConfrimButtonColor, + borderRadius: BorderRadius.circular(4.5)), child: Text( widget.pageType == SendMessagePageType.AddFriends ? I18n.of(context).send : I18n.of(context).determine, - style: TextStyle( - color: Colors.white , fontSize: 14), - textScaleFactor: 1.0, + style: TextStyle(color: Colors.white, fontSize: 14), + textScaleFactor: 1.0, ), ), ) @@ -124,8 +136,9 @@ class _AddFriendPageState extends State { height: 36.5, color: Colors.white, child: TextField( - keyboardAppearance: Brightness.light, + keyboardAppearance: Brightness.light, controller: _txtCtrl, + //autofocus: true, style: TextStyle( fontSize: 16, color: Constants.BlackTextColor, @@ -188,7 +201,7 @@ class _AddFriendPageState extends State { margin: EdgeInsets.only(top: 20.5, left: 15, bottom: 6), child: Text( title, - textScaleFactor: 1.0, + textScaleFactor: 1.0, style: TextStyle(fontSize: 11), ), ); diff --git a/lib/home/create_group_view.dart b/lib/home/create_group_view.dart index 1ae9c1d..799569b 100644 --- a/lib/home/create_group_view.dart +++ b/lib/home/create_group_view.dart @@ -95,7 +95,13 @@ class _FriendSelectItemState extends State { SizedBox(width: 10), _avatarIcon, SizedBox(width: 10.0), - Text(widget.friendModel.getTitle()), + Expanded( + child: Container( + child: Text( + widget.friendModel.getTitle(), + overflow: TextOverflow.ellipsis, + )), + ) ], ), ); diff --git a/lib/home/friend_page.dart b/lib/home/friend_page.dart index 9c08049..082c3fc 100644 --- a/lib/home/friend_page.dart +++ b/lib/home/friend_page.dart @@ -111,6 +111,11 @@ class _FriendPageState extends State { borderRadius: BorderRadius.circular(6), child: CachedNetworkImage( imageUrl: url, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + width: Constants.ContactAvatarSize, + height: Constants.ContactAvatarSize, + ), width: Constants.ContactAvatarSize, height: Constants.ContactAvatarSize, )); diff --git a/lib/home/global_search.dart b/lib/home/global_search.dart index 69ca75e..6ce6226 100644 --- a/lib/home/global_search.dart +++ b/lib/home/global_search.dart @@ -113,9 +113,10 @@ class _GlobalSearchPageState extends State { width: Screen.width, child: Row( mainAxisAlignment: MainAxisAlignment.start, + textBaseline: TextBaseline.ideographic, children: [ Container( - margin: EdgeInsets.only(left: 20,right: 13), + margin: EdgeInsets.only(left: 20, right: 13), width: Constants.ContactAvatarSize, height: Constants.ContactAvatarSize, decoration: BoxDecoration( @@ -132,15 +133,18 @@ class _GlobalSearchPageState extends State { color: Colors.white, ), ), - Container( - child: Text('${I18n.of(context).search_phone}: ', - style: TextStyle(fontSize: 16.23)), - ), - Container( - margin: EdgeInsets.only(top: 5), - child: Text(searchStr, + RichText( + text: TextSpan(children: [ + TextSpan( + text: '${I18n.of(context).search_phone}: ', style: TextStyle( - fontSize: 16.23, color: Color(0xFF008AFF)))) + color: Constants.BlackTextColor, fontSize: 16.23)), + TextSpan( + text: searchStr, + style: TextStyle( + color: Color(0xFF008AFF), fontSize: 16.23)), + ]), + ), ], ), color: Colors.white)); diff --git a/lib/home/group_all_member.dart b/lib/home/group_all_member.dart index 18836a3..c698c83 100644 --- a/lib/home/group_all_member.dart +++ b/lib/home/group_all_member.dart @@ -30,16 +30,12 @@ class GroupAllMemberState extends State { static const Separate_Size = 15.0; bool isHost; - ///是否是群主 @override void initState() { super.initState(); MessageMgr().on('Update Group Info', updateGroupInfo); isHost = widget.groupInfoModel.hosterId == UserData().basicInfo.userId; - - - } updateGroupInfo(args) async { @@ -51,18 +47,12 @@ class GroupAllMemberState extends State { @override void dispose() { - super.dispose(); MessageMgr().off('Update Group Info', updateGroupInfo); } @override Widget build(BuildContext context) { - - - - - Widget appBar = new AppBar( backgroundColor: AppColors.NewAppbarBgColor, title: new Text( @@ -150,14 +140,17 @@ class GroupAllMemberState extends State { borderRadius: BorderRadius.all(Radius.circular(8.0)), child: CachedNetworkImage( imageUrl: member.avtar, - placeholder: CustomUI.buildImgLoding, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + width: size - 30, + height: size - 30, + ), width: size - 30, height: size - 30, )), SizedBox( height: 5, ), - SizedBox( width: size - 30, child: Text( @@ -176,7 +169,7 @@ class GroupAllMemberState extends State { onTap: () { if (member.memberId != UserData().basicInfo.userId) { AppNavigator.pushProfileInfoPage(context, member.memberId, - fromWhere: 2,addMode: 1); + fromWhere: 2, addMode: 1); } }, )); diff --git a/lib/home/homeMain.dart b/lib/home/homeMain.dart index 2219c7c..a2c8b7d 100644 --- a/lib/home/homeMain.dart +++ b/lib/home/homeMain.dart @@ -39,6 +39,7 @@ class NavigationIconView { String title, IconData icon, int type, + EdgeInsets iconMargin, double iconSize = 24, bool isCenter = false, bool isShowdot = false, @@ -72,7 +73,7 @@ class NavigationIconView { Container( margin: isCenter ? EdgeInsets.only(bottom: 8, right: 6) - : EdgeInsets.zero, + : iconMargin ?? EdgeInsets.zero, child: Icon(icon, size: iconSize, color: @@ -110,7 +111,7 @@ class NavigationIconView { Container( margin: isCenter ? EdgeInsets.only(bottom: 8, right: 6) - : EdgeInsets.zero, + : iconMargin ?? EdgeInsets.zero, child: isShowdot ? UnreadDot( child: Icon(icon, @@ -122,6 +123,11 @@ class NavigationIconView { color: isCenter ? Colors.white : Constants.BottomIconGreyColor)) + // child: Icon(icon, + // size: iconSize, + // color: isCenter + // ? Colors.white + // : Constants.BottomIconGreyColor)) ], )); } @@ -141,7 +147,6 @@ class _HomeMainState extends State { @override void initState() { - SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light); super.initState(); LocalNotificationUtil.instance.initState(context); @@ -312,11 +317,11 @@ class _HomeMainState extends State { fontFamily: 'iconfont', ), isShowdot: true, - type: 3, - iconSize: 25), + iconSize: 29), NavigationIconView( title: _titles[0], isShowdot: true, + iconMargin: EdgeInsets.only(top: 2), type: 5, icon: IconData( 0xe66e, @@ -338,7 +343,7 @@ class _HomeMainState extends State { 0xe60b, fontFamily: 'iconfont', ), - type: 4, + type: 6, iconSize: 26.5), NavigationIconView( title: _titles[3], diff --git a/lib/home/last_chat_item.dart b/lib/home/last_chat_item.dart index c9a1794..7da529d 100644 --- a/lib/home/last_chat_item.dart +++ b/lib/home/last_chat_item.dart @@ -121,6 +121,7 @@ class _LastChatItemState extends State { Provider.of(context) .getRefName(userInfo.userId, userInfo.nickName), textScaleFactor: 1.0, + overflow: TextOverflow.ellipsis, style: TextStyle( fontSize: 15, color: Colors.black, diff --git a/lib/home/new_friends.dart b/lib/home/new_friends.dart index f8a5021..9cb3f31 100644 --- a/lib/home/new_friends.dart +++ b/lib/home/new_friends.dart @@ -48,6 +48,11 @@ class _ContactItem extends StatelessWidget { borderRadius: BorderRadius.circular(6), child: CachedNetworkImage( imageUrl: this.avatar, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + width: Constants.ContactAvatarSize, + height: Constants.ContactAvatarSize, + ), width: Constants.ContactAvatarSize, height: Constants.ContactAvatarSize, )); diff --git a/lib/home/unread_dot_widget.dart b/lib/home/unread_dot_widget.dart index ab210b6..58eec2a 100644 --- a/lib/home/unread_dot_widget.dart +++ b/lib/home/unread_dot_widget.dart @@ -56,14 +56,16 @@ class _UnreadDotState extends State { case 5: isHasUnread = isHaveNewFriends(); break; + case 6: + isHasUnread = ChatDataMgr().unreadCountProvider.checkUnreadMsg() || + isShowMsg() || + ChatDataMgr().groupUnreadProvider.checkUnreadMsg(); + break; } return Stack( children: [ - Padding( - padding: EdgeInsets.only(right: 2), - child: widget.child, - ), + widget.child, Positioned( right: 0, top: 0, diff --git a/lib/main.dart b/lib/main.dart index 637c116..5733e1a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -376,6 +376,7 @@ class _MyAppState extends State with WidgetsBindingObserver { GlobalCupertinoLocalizations.delegate, // <-- needed for iOS const FallbackCupertinoLocalisationsDelegate() ], + //locale: const Locale('en'), supportedLocales: i18n.supportedLocales, title: 'Chat', onGenerateTitle: (context) { diff --git a/lib/models/friends_info.dart b/lib/models/friends_info.dart index bc4941b..2a4d0be 100644 --- a/lib/models/friends_info.dart +++ b/lib/models/friends_info.dart @@ -52,6 +52,11 @@ class FriendsInfo extends StatelessWidget { borderRadius: BorderRadius.circular(6), child: CachedNetworkImage( imageUrl: this.avatar, + placeholder: (context, url) => Image.asset( + Constants.DefaultHeadImgUrl, + width: Constants.ContactAvatarSize, + height: Constants.ContactAvatarSize, + ), width: Constants.ContactAvatarSize, height: Constants.ContactAvatarSize, )); @@ -76,7 +81,12 @@ class FriendsInfo extends StatelessWidget { children: [ _avatarIcon, SizedBox(width: 10.0), - Text(title), + Expanded( + child: Container( + child: Text( + title, + overflow: TextOverflow.ellipsis, + ))) ], ), );