Skip to content

Commit 9875a38

Browse files
authored
Merge pull request #69 from 3nln/fix/chat-text-selection
fix: chat message selection fix
2 parents 79d78d7 + 4a61bea commit 9875a38

5 files changed

Lines changed: 101 additions & 51 deletions

File tree

lib/pages/chat/chat_event_list.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ class ChatEventList extends StatelessWidget {
4949
final hasWallpaper =
5050
controller.room.client.applicationAccountConfig.wallpaperUrl != null;
5151

52+
final isDesktopOrWeb = PlatformInfos.isDesktop || PlatformInfos.isWeb;
53+
5254
return SelectionArea(
53-
contextMenuBuilder: (context, selectableRegionState) =>
54-
const SizedBox.shrink(),
55+
contextMenuBuilder: isDesktopOrWeb
56+
? (context, selectableRegionState) =>
57+
AdaptiveTextSelectionToolbar.selectableRegion(
58+
selectableRegionState: selectableRegionState,
59+
)
60+
: (context, selectableRegionState) => const SizedBox.shrink(),
5561
child: ListView.custom(
5662
padding: EdgeInsets.only(
5763
top: 16,

lib/pages/chat/chat_input_row.dart

Lines changed: 70 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ class ChatInputRow extends StatelessWidget {
5757
onSend: controller.onVoiceMessageSend,
5858
);
5959
}
60-
return Row(
60+
return Padding(
61+
padding: controller.selectMode
62+
? const EdgeInsets.symmetric(horizontal: 8)
63+
: EdgeInsets.zero,
64+
child: Row(
6165
crossAxisAlignment: .end,
6266
mainAxisAlignment: .spaceBetween,
6367
children: controller.selectMode
@@ -67,30 +71,43 @@ class ChatInputRow extends StatelessWidget {
6771
))
6872
SizedBox(
6973
height: height,
70-
child: TextButton(
71-
style: TextButton.styleFrom(
72-
foregroundColor: theme.colorScheme.error,
73-
),
74-
onPressed: controller.deleteErrorEventsAction,
75-
child: Row(
76-
children: <Widget>[
77-
const Icon(TablerIcons.trash_filled),
78-
Text(L10n.of(context).delete),
79-
],
74+
child: Center(
75+
child: TextButton(
76+
style: TextButton.styleFrom(
77+
foregroundColor: theme.colorScheme.error,
78+
padding: const EdgeInsets.symmetric(horizontal: 12),
79+
minimumSize: const Size(0, 36),
80+
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
81+
),
82+
onPressed: controller.deleteErrorEventsAction,
83+
child: Row(
84+
children: <Widget>[
85+
const Icon(TablerIcons.trash_filled),
86+
Text(L10n.of(context).delete),
87+
],
88+
),
8089
),
8190
),
8291
)
8392
else
8493
SizedBox(
8594
height: height,
86-
child: TextButton(
87-
style: selectedTextButtonStyle,
88-
onPressed: controller.forwardEventsAction,
89-
child: Row(
90-
children: <Widget>[
91-
const Icon(TablerIcons.chevron_left),
92-
Text(L10n.of(context).forward),
93-
],
95+
child: Center(
96+
child: TextButton(
97+
style: selectedTextButtonStyle.copyWith(
98+
padding: const WidgetStatePropertyAll(
99+
EdgeInsets.symmetric(horizontal: 12),
100+
),
101+
minimumSize: const WidgetStatePropertyAll(Size(0, 36)),
102+
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
103+
),
104+
onPressed: controller.forwardEventsAction,
105+
child: Row(
106+
children: <Widget>[
107+
const Icon(TablerIcons.chevron_left),
108+
Text(L10n.of(context).forward),
109+
],
110+
),
94111
),
95112
),
96113
),
@@ -101,28 +118,44 @@ class ChatInputRow extends StatelessWidget {
101118
.isSent
102119
? SizedBox(
103120
height: height,
104-
child: TextButton(
105-
style: selectedTextButtonStyle,
106-
onPressed: controller.replyAction,
107-
child: Row(
108-
children: <Widget>[
109-
Text(L10n.of(context).reply),
110-
const Icon(TablerIcons.chevron_right),
111-
],
121+
child: Center(
122+
child: TextButton(
123+
style: selectedTextButtonStyle.copyWith(
124+
padding: const WidgetStatePropertyAll(
125+
EdgeInsets.symmetric(horizontal: 12),
126+
),
127+
minimumSize: const WidgetStatePropertyAll(Size(0, 36)),
128+
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
129+
),
130+
onPressed: controller.replyAction,
131+
child: Row(
132+
children: <Widget>[
133+
Text(L10n.of(context).reply),
134+
const Icon(TablerIcons.chevron_right),
135+
],
136+
),
112137
),
113138
),
114139
)
115140
: SizedBox(
116141
height: height,
117-
child: TextButton(
118-
style: selectedTextButtonStyle,
119-
onPressed: controller.sendAgainAction,
120-
child: Row(
121-
children: <Widget>[
122-
Text(L10n.of(context).tryToSendAgain),
123-
const SizedBox(width: 4),
124-
const Icon(TablerIcons.send, size: 16),
125-
],
142+
child: Center(
143+
child: TextButton(
144+
style: selectedTextButtonStyle.copyWith(
145+
padding: const WidgetStatePropertyAll(
146+
EdgeInsets.symmetric(horizontal: 12),
147+
),
148+
minimumSize: const WidgetStatePropertyAll(Size(0, 36)),
149+
tapTargetSize: MaterialTapTargetSize.shrinkWrap,
150+
),
151+
onPressed: controller.sendAgainAction,
152+
child: Row(
153+
children: <Widget>[
154+
Text(L10n.of(context).tryToSendAgain),
155+
const SizedBox(width: 4),
156+
const Icon(TablerIcons.send, size: 14),
157+
],
158+
),
126159
),
127160
),
128161
)
@@ -404,6 +437,7 @@ class ChatInputRow extends StatelessWidget {
404437
),
405438
),
406439
],
440+
),
407441
);
408442
},
409443
);

lib/pages/chat/events/message_context_menu.dart

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:fluffychat/l10n/l10n.dart';
99
import 'package:fluffychat/pages/chat/chat.dart';
1010
import 'package:fluffychat/utils/matrix_sdk_extensions/event_extension.dart';
1111
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
12+
import 'package:fluffychat/utils/platform_infos.dart';
1213
import 'package:fluffychat/widgets/matrix.dart';
1314

1415
enum _ContextAction {
@@ -268,19 +269,23 @@ class MessageContextMenu extends StatelessWidget {
268269

269270
@override
270271
Widget build(BuildContext context) {
272+
final isDesktopOrWeb = PlatformInfos.isDesktop || PlatformInfos.isWeb;
273+
271274
return GestureDetector(
272275
onDoubleTap: event.status.isSent && controller.room.canSendDefaultMessages
273276
? () => controller.replyAction(replyTo: event)
274277
: null,
275278
onSecondaryTapUp: (details) {
276279
_showContextMenu(context, details.globalPosition);
277280
},
278-
onLongPressStart: controller.selectedEvents.isNotEmpty
281+
onLongPressStart: isDesktopOrWeb
279282
? null
280-
: (details) {
281-
HapticFeedback.heavyImpact();
282-
_showContextMenu(context, details.globalPosition);
283-
},
283+
: controller.selectedEvents.isNotEmpty
284+
? null
285+
: (details) {
286+
HapticFeedback.heavyImpact();
287+
_showContextMenu(context, details.globalPosition);
288+
},
284289
child: child,
285290
);
286291
}

lib/widgets/my_swipe_to.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:math' as math;
22

3+
import 'package:fluffychat/utils/platform_infos.dart';
34
import 'package:flutter/material.dart';
45

56
class MySwipeable extends StatefulWidget {
@@ -160,6 +161,10 @@ class _MySwipeableState extends State<MySwipeable> with TickerProviderStateMixin
160161
),
161162
];
162163

164+
if (PlatformInfos.isDesktop || PlatformInfos.isWeb) {
165+
return Stack(children: children);
166+
}
167+
163168
return GestureDetector(
164169
onHorizontalDragStart: _handleDragStart,
165170
onHorizontalDragUpdate: _handleDragUpdate,

pubspec.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,10 +1176,10 @@ packages:
11761176
dependency: transitive
11771177
description:
11781178
name: matcher
1179-
sha256: dc0b7dc7651697ea4ff3e69ef44b0407ea32c487a39fff6a4004fa585e901861
1179+
sha256: "12956d0ad8390bbcc63ca2e1469c0619946ccb52809807067a7020d57e647aa6"
11801180
url: "https://pub.dev"
11811181
source: hosted
1182-
version: "0.12.19"
1182+
version: "0.12.18"
11831183
material_color_utilities:
11841184
dependency: transitive
11851185
description:
@@ -1965,26 +1965,26 @@ packages:
19651965
dependency: transitive
19661966
description:
19671967
name: test
1968-
sha256: "280d6d890011ca966ad08df7e8a4ddfab0fb3aa49f96ed6de56e3521347a9ae7"
1968+
sha256: "54c516bbb7cee2754d327ad4fca637f78abfc3cbcc5ace83b3eda117e42cd71a"
19691969
url: "https://pub.dev"
19701970
source: hosted
1971-
version: "1.30.0"
1971+
version: "1.29.0"
19721972
test_api:
19731973
dependency: transitive
19741974
description:
19751975
name: test_api
1976-
sha256: "8161c84903fd860b26bfdefb7963b3f0b68fee7adea0f59ef805ecca346f0c7a"
1976+
sha256: "93167629bfc610f71560ab9312acdda4959de4df6fac7492c89ff0d3886f6636"
19771977
url: "https://pub.dev"
19781978
source: hosted
1979-
version: "0.7.10"
1979+
version: "0.7.9"
19801980
test_core:
19811981
dependency: transitive
19821982
description:
19831983
name: test_core
1984-
sha256: "0381bd1585d1a924763c308100f2138205252fb90c9d4eeaf28489ee65ccde51"
1984+
sha256: "394f07d21f0f2255ec9e3989f21e54d3c7dc0e6e9dbce160e5a9c1a6be0e2943"
19851985
url: "https://pub.dev"
19861986
source: hosted
1987-
version: "0.6.16"
1987+
version: "0.6.15"
19881988
timezone:
19891989
dependency: transitive
19901990
description:

0 commit comments

Comments
 (0)