@@ -19,6 +19,7 @@ import '../../shared/custom_emoji/custom_emoji.dart';
1919import '../../shared/custom_emoji/custom_emoji_provider.dart' ;
2020import '../../shared/custom_emoji/custom_emoji_render.dart' ;
2121import '../../shared/emoji/native_emoji_glyph.dart' ;
22+ import '../../shared/emoji/emoji_data_provider.dart' ;
2223import '../../shared/widgets/sheet_action_section.dart' ;
2324import '../../shared/widgets/modal_presentation.dart' ;
2425import '../../shared/reminders/remind_me_later_sheet.dart' ;
@@ -42,6 +43,22 @@ part 'message_actions/quick_reaction_row.dart';
4243/// `msg.body.slice(0, 100)` .
4344const _reminderPreviewLength = 100 ;
4445
46+ // A weak, route-owned latch shared by every action, including pointers that
47+ // were already down when another selection started dismissing the sheet.
48+ final _selectedMessageActionRoutes = Expando <bool >();
49+
50+ bool _selectMessageAction (BuildContext context) {
51+ final route = ModalRoute .of (context);
52+ if (route == null ||
53+ ! route.isCurrent ||
54+ _selectedMessageActionRoutes[route] == true ) {
55+ return false ;
56+ }
57+ _selectedMessageActionRoutes[route] = true ;
58+ Navigator .of (context).pop (true );
59+ return true ;
60+ }
61+
4562/// Presents message reactions and grouped actions in the shared bottom sheet.
4663/// Snapshot and preview callbacks are not used by the sheet presentation.
4764Future <void > showMessageActions ({
@@ -133,7 +150,7 @@ Future<void> showMessageActions({
133150 leading: const Icon (BuzzIcons .copy),
134151 title: const Text ('Copy text' ),
135152 onTap: () {
136- Navigator . of ( sheetContext). pop ( true ) ;
153+ if ( ! _selectMessageAction ( sheetContext)) return ;
137154 // Copy to clipboard
138155 final data = ClipboardData (text: message.content);
139156 Clipboard .setData (data);
@@ -149,7 +166,7 @@ Future<void> showMessageActions({
149166 leading: const Icon (BuzzIcons .pencil),
150167 title: const Text ('Edit message' ),
151168 onTap: () {
152- Navigator . of ( sheetContext). pop ( true ) ;
169+ if ( ! _selectMessageAction ( sheetContext)) return ;
153170 _showEditSheet (
154171 context: context,
155172 ref: ref,
@@ -168,7 +185,7 @@ Future<void> showMessageActions({
168185 style: TextStyle (color: sheetContext.colors.error),
169186 ),
170187 onTap: () {
171- Navigator . of ( sheetContext). pop ( true ) ;
188+ if ( ! _selectMessageAction ( sheetContext)) return ;
172189 _confirmDelete (
173190 context: context,
174191 ref: ref,
@@ -495,7 +512,7 @@ class _MarkReadUnreadTile extends ConsumerWidget {
495512 leading: Icon (unread ? BuzzIcons .mailCheck : BuzzIcons .mailOpen),
496513 title: Text (unread ? 'Mark read' : 'Mark unread' ),
497514 onTap: () {
498- Navigator . of ( context). pop ( true ) ;
515+ if ( ! _selectMessageAction ( context)) return ;
499516 final notifier = ref.read (readStateProvider.notifier);
500517 if (unread) {
501518 // Advances the `msg:` marker and clears this message's own forced
@@ -536,7 +553,7 @@ class _FollowThreadTile extends ConsumerWidget {
536553 leading: Icon (following ? BuzzIcons .bellOff : BuzzIcons .bellRing),
537554 title: Text (following ? 'Unfollow thread' : 'Follow thread' ),
538555 onTap: () {
539- Navigator . of ( context). pop ( true ) ;
556+ if ( ! _selectMessageAction ( context)) return ;
540557 final notifier = ref.read (threadFollowsProvider.notifier);
541558 if (following) {
542559 notifier.unfollowThread (rootId);
@@ -581,7 +598,7 @@ class _MessageQuickActionsRow extends ConsumerWidget {
581598 icon: BuzzIcons .messageSquareReply,
582599 label: 'Reply' ,
583600 onTap: () {
584- Navigator . of ( context). pop ( true ) ;
601+ if ( ! _selectMessageAction ( context)) return ;
585602 Navigator .of (pageContext).push (
586603 MaterialPageRoute <void >(
587604 builder: (_) => ThreadDetailPage (
@@ -600,7 +617,7 @@ class _MessageQuickActionsRow extends ConsumerWidget {
600617 icon: BuzzIcons .link2,
601618 label: 'Copy link' ,
602619 onTap: () {
603- Navigator . of ( context). pop ( true ) ;
620+ if ( ! _selectMessageAction ( context)) return ;
604621 copyToClipboard (
605622 pageContext,
606623 messageLinkFor (message: message, channelId: channelId),
@@ -617,7 +634,7 @@ class _MessageQuickActionsRow extends ConsumerWidget {
617634 context,
618635 rootNavigator: true ,
619636 ).context;
620- Navigator . of ( context). pop ( true ) ;
637+ if ( ! _selectMessageAction ( context)) return ;
621638 showRemindMeLaterSheet (
622639 context: rootContext,
623640 ref: ref,
@@ -731,29 +748,48 @@ class _QuickReactionCircle extends StatelessWidget {
731748 final VoidCallback onTap;
732749 final Widget child;
733750 final double size;
751+ final String label;
752+ final bool ? selected;
734753
735754 const _QuickReactionCircle ({
736755 required this .onTap,
737756 required this .child,
738757 required this .size,
758+ required this .label,
759+ this .selected,
739760 });
740761
741762 @override
742763 Widget build (BuildContext context) {
743- return GestureDetector (
744- onTap: () {
745- unawaited (HapticFeedback .lightImpact ());
746- onTap ();
747- },
748- child: Container (
749- width: size,
750- height: size,
751- alignment: Alignment .center,
752- decoration: BoxDecoration (
753- color: context.colors.surfaceContainerHighest,
754- shape: BoxShape .circle,
764+ return Semantics (
765+ button: true ,
766+ label: label,
767+ selected: selected,
768+ excludeSemantics: true ,
769+ onTap: onTap,
770+ child: GestureDetector (
771+ excludeFromSemantics: true ,
772+ onTap: () {
773+ unawaited (HapticFeedback .lightImpact ());
774+ onTap ();
775+ },
776+ child: Container (
777+ width: size,
778+ height: size,
779+ alignment: Alignment .center,
780+ decoration: BoxDecoration (
781+ color: selected == true
782+ ? context.colors.primary.withValues (alpha: 0.10 )
783+ : context.colors.surfaceContainerHighest,
784+ border: selected == true
785+ ? Border .all (
786+ color: context.colors.primary.withValues (alpha: 0.40 ),
787+ )
788+ : null ,
789+ shape: BoxShape .circle,
790+ ),
791+ child: child,
755792 ),
756- child: child,
757793 ),
758794 );
759795 }
0 commit comments