Kaynağa Gözat

修复 聊天界面ios侧滑失效

master
jiahao 5 yıl önce
ebeveyn
işleme
a6bdd047ac
5 değiştirilmiş dosya ile 89 ekleme ve 92 silme
  1. +72
    -71
      lib/chat/ChatPage.dart
  2. +14
    -19
      lib/chat/group_chat_item.dart
  3. +1
    -1
      lib/chat/group_chat_view.dart
  4. +1
    -0
      lib/home/homeMain.dart
  5. +1
    -1
      lib/utils/app_navigator.dart

+ 72
- 71
lib/chat/ChatPage.dart Dosyayı Görüntüle

@@ -442,78 +442,79 @@ class _ChatPageState extends State<ChatPage> {
})));
return WillPopScope(
child: Stack(
children: <Widget>[
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => _keyboardIndexProvider),
Provider<bool>.value(value: false),
Provider<int>.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<RefNameProvider>(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: <Widget>[
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: <Widget>[
MultiProvider(
providers: [
ChangeNotifierProvider(create: (_) => _keyboardIndexProvider),
Provider<bool>.value(value: false),
Provider<int>.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<RefNameProvider>(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: <Widget>[
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<ChatPage> {
}else{
Navigator.of(context).pop(); }
return Future.value(false);
});
}):allItem;
}


+ 14
- 19
lib/chat/group_chat_item.dart Dosyayı Görüntüle

@@ -829,36 +829,31 @@ class _GroupChatPageItemState extends State<GroupChatPageItem>
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<Match> 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) {


+ 1
- 1
lib/chat/group_chat_view.dart Dosyayı Görüntüle

@@ -290,7 +290,7 @@ class _GroupChatPageState extends State<GroupChatPage> {
Provider<GroupInfoModel>.value(value: widget.groupInfoModel),
],
child: GestureDetector(
onTap: hideKeyBoard,
onTapDown: (args){hideKeyBoard();},
child: ExtendedTextSelectionPointerHandler(
///选择文字,消除弹窗
builder: (states) {


+ 1
- 0
lib/home/homeMain.dart Dosyayı Görüntüle

@@ -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';


+ 1
- 1
lib/utils/app_navigator.dart Dosyayı Görüntüle

@@ -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'),


Yükleniyor…
İptal
Kaydet