diff --git a/lib/chat/ChatPage.dart b/lib/chat/ChatPage.dart index 5972194..a9adece 100644 --- a/lib/chat/ChatPage.dart +++ b/lib/chat/ChatPage.dart @@ -442,78 +442,79 @@ class _ChatPageState extends State { }))); - - return WillPopScope( - child: Stack( - children: [ - MultiProvider( - providers: [ - ChangeNotifierProvider(create: (_) => _keyboardIndexProvider), - Provider.value(value: false), - Provider.value(value: widget.friendId), - ], - child: GestureDetector( - onTapDown: (args){hideKeyBoard();}, - child: ExtendedTextSelectionPointerHandler( - ///选择文字,消除弹窗 - - builder: (states) { - return Listener( - child: Scaffold( - resizeToAvoidBottomInset: false, - backgroundColor: const Color(0xFFE2E9F1), - appBar: AppBar( - title: Text( - '${Provider.of(context).getRefName(friendInfo.userId, friendInfo.nickName)}', - textScaleFactor: 1.0, - style: TextStyle( - color: Constants.BlackTextColor, - fontSize: 16.47), - ), - leading: CustomUI.buildCustomLeading(context,onTap:(){ - goBackCheck(); - - }), - titleSpacing: -10, - centerTitle: false, - elevation: 1, - actions: actions), - body: SafeArea( - child: Column( - children: [ - NetStateWidget(), - (isTranslateButler) - ? _buildTranslationButler() - : Container(), - Expanded(child: _buildMessageList()), - InputBar(sendMsg: sendMsg,isTranslateHK: isTranslateButler,), - ], - ))), - behavior: HitTestBehavior.translucent, - onPointerDown: (value) { - for (var state in states) { - if (!state.containsPosition(value.position)) { - //clear other selection - state.clearSelection(); - } - } - }, - onPointerMove: (value) { + var allItem = Stack( + children: [ + MultiProvider( + providers: [ + ChangeNotifierProvider(create: (_) => _keyboardIndexProvider), + Provider.value(value: false), + Provider.value(value: widget.friendId), + ], + child: GestureDetector( + onTapDown: (args){hideKeyBoard();}, + child: ExtendedTextSelectionPointerHandler( + ///选择文字,消除弹窗 + + builder: (states) { + return Listener( + child: Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: const Color(0xFFE2E9F1), + appBar: AppBar( + title: Text( + '${Provider.of(context).getRefName(friendInfo.userId, friendInfo.nickName)}', + textScaleFactor: 1.0, + style: TextStyle( + color: Constants.BlackTextColor, + fontSize: 16.47), + ), + leading: CustomUI.buildCustomLeading(context,onTap:(){ + goBackCheck(); + + }), + titleSpacing: -10, + centerTitle: false, + elevation: 1, + actions: actions), + body: SafeArea( + child: Column( + children: [ + NetStateWidget(), + (isTranslateButler) + ? _buildTranslationButler() + : Container(), + Expanded(child: _buildMessageList()), + InputBar(sendMsg: sendMsg,isTranslateHK: isTranslateButler,), + ], + ))), + behavior: HitTestBehavior.translucent, + 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(); + } + } }, - ))), - isTranslateButler ? getAudioChatView() : Container(), - isTranslateButler ? zoomAudioButton() : Container() - ], - ), + onPointerMove: (value) { + //clear other selection + for (var state in states) { + if (!state.containsPosition(value.position)) { + //clear other selection + state.clearSelection(); + } + } + }, + ); + }, + ))), + isTranslateButler ? getAudioChatView() : Container(), + isTranslateButler ? zoomAudioButton() : Container() + ], + ); + + return isTranslateButler?WillPopScope( + child: allItem, onWillPop: () { if(isTranslateButler && !isTranslateButlerFinish){ if(UserData().isTranslateUser){ @@ -538,7 +539,7 @@ class _ChatPageState extends State { }else{ Navigator.of(context).pop(); } return Future.value(false); - }); + }):allItem; } diff --git a/lib/chat/group_chat_item.dart b/lib/chat/group_chat_item.dart index 3cbb4e7..9fdc4ec 100644 --- a/lib/chat/group_chat_item.dart +++ b/lib/chat/group_chat_item.dart @@ -829,36 +829,31 @@ class _GroupChatPageItemState extends State selectionEnabled: false, hideKeyboard: widget.hideKeyboard)); } - double _getTextWidth(String text, {double fontSize = FontSize}) { + double _getTextWidth(String text, {double fontSize: FontSize}) { var tp = TextPainter( - text: TextSpan( - style: TextStyle(fontSize: fontSize), text: textList[curTextType]), + text: TextSpan(style: TextStyle(fontSize: fontSize), text: text), textAlign: TextAlign.left, textDirection: TextDirection.ltr, textScaleFactor: 1, ); - tp.layout(maxWidth: maxWidth); - if (text.contains('[')) { - if (text.length < 5 && text.startsWith('[') && text.endsWith(']')) { - ///单表情 - return 25; - } - - int length = text.split('[').length; - if (length > 1) { - ///包含表情 - int scale = 6; + tp.layout(maxWidth: Screen.width - 140); - if (length > 6) scale = 7; + RegExp alterStr = RegExp(r'\[([0-9]+)\]'); + Iterable matches = alterStr.allMatches(text); +// print('~~~~~~~~~~~~~~${matches.length}~~~~~~~~~~~~~~~'); - double width = tp.width + length * scale; - return width > (maxWidth) ? maxWidth : width; + double delta = 0; + for (Match m in matches) { +// print('~~~~~~~~~~~~~~${m.group(1)}~~~~~~~~~~~~~~~'); + if (int.parse(m.group(1)) > 10) { + delta += 20 + 4 - 25; + } else { + delta += 20 + 4 - 16.8; } } - return tp.width; - ///单文字 + return tp.width + delta; } blueDot(bool isShow) { diff --git a/lib/chat/group_chat_view.dart b/lib/chat/group_chat_view.dart index a064d44..830f2fa 100644 --- a/lib/chat/group_chat_view.dart +++ b/lib/chat/group_chat_view.dart @@ -290,7 +290,7 @@ class _GroupChatPageState extends State { Provider.value(value: widget.groupInfoModel), ], child: GestureDetector( - onTap: hideKeyBoard, + onTapDown: (args){hideKeyBoard();}, child: ExtendedTextSelectionPointerHandler( ///选择文字,消除弹窗 builder: (states) { diff --git a/lib/home/homeMain.dart b/lib/home/homeMain.dart index 37f8d48..c3fad2a 100644 --- a/lib/home/homeMain.dart +++ b/lib/home/homeMain.dart @@ -6,6 +6,7 @@ import 'package:chat/data/translate_hk_data_mgr.dart'; import 'package:chat/generated/i18n.dart'; import 'package:chat/home/SystemEditPage.dart'; import 'package:chat/home/find_page.dart'; +import 'package:chat/home/realtimehelper/real_time_helper_page.dart'; import 'package:chat/home/unread_dot_widget.dart'; import 'package:chat/models/UserInfo.dart'; import 'package:chat/models/ref_name_provider.dart'; diff --git a/lib/utils/app_navigator.dart b/lib/utils/app_navigator.dart index 03ccc53..f054e92 100644 --- a/lib/utils/app_navigator.dart +++ b/lib/utils/app_navigator.dart @@ -105,7 +105,7 @@ class AppNavigator { if (enterType == 1 ||enterType == 2) { Navigator.of(context).pop(context); } - AppNavigator.push( + AppNavigator.defaultPush( context, ChatPage( key: Key('Chat'),