@@ -21,6 +21,7 @@ import 'katex.dart';
2121import 'lightbox.dart' ;
2222import 'message_list.dart' ;
2323import 'poll.dart' ;
24+ import 'profile.dart' ;
2425import 'scrolling.dart' ;
2526import 'store.dart' ;
2627import 'text.dart' ;
@@ -1216,25 +1217,45 @@ class UserMention extends StatelessWidget {
12161217 @override
12171218 Widget build (BuildContext context) {
12181219 final contentTheme = ContentTheme .of (context);
1219- return Container (
1220- decoration: BoxDecoration (
1221- // TODO(#646) different for wildcard mentions
1222- color: contentTheme.colorDirectMentionBackground,
1223- borderRadius: const BorderRadius .all (Radius .circular (3 ))),
1224- padding: const EdgeInsets .symmetric (horizontal: 0.2 * kBaseFontSize),
1225- child: InlineContent (
1226- // If an @-mention is inside a link, let the @-mention override it.
1227- recognizer: null , // TODO(#1867) make @-mentions tappable, for info on user
1228- // One hopes an @-mention can't contain an embedded link.
1229- // (The parser on creating a UserMentionNode has a TODO to check that.)
1230- linkRecognizers: null ,
1231-
1232- // TODO(#647) when self-user is non-silently mentioned, make bold, and:
1233- // TODO(#646) when self-user is non-silently mentioned,
1234- // distinguish font color between direct and wildcard mentions
1235- style: ambientTextStyle,
1236-
1237- nodes: node.nodes));
1220+ final userId = node.userId;
1221+
1222+ final innerContent = InlineContent (
1223+ // If an @-mention is inside a link, let the @-mention override it.
1224+ recognizer: null ,
1225+ // One hopes an @-mention can't contain an embedded link.
1226+ // (The parser on creating a UserMentionNode has a TODO to check that.)
1227+ linkRecognizers: null ,
1228+
1229+ style: ambientTextStyle,
1230+
1231+ nodes: node.nodes);
1232+
1233+ if (userId != null && userId > 0 ) {
1234+ // Wrap with gesture detector if we have a valid user ID
1235+ return GestureDetector (
1236+ onTap: () => Navigator .push (
1237+ context,
1238+ ProfilePage .buildRoute (context: context, userId: userId),
1239+ ),
1240+ child: Container (
1241+ decoration: BoxDecoration (
1242+ // TODO(#646) different for wildcard mentions
1243+ color: contentTheme.colorDirectMentionBackground,
1244+ borderRadius: const BorderRadius .all (Radius .circular (3 ))),
1245+ padding: const EdgeInsets .symmetric (horizontal: 0.2 * kBaseFontSize),
1246+ child: innerContent,
1247+ ),
1248+ );
1249+ } else {
1250+ // Regular container without gesture detector if no valid user ID
1251+ return Container (
1252+ decoration: BoxDecoration (
1253+ // TODO(#646) different for wildcard mentions
1254+ color: contentTheme.colorDirectMentionBackground,
1255+ borderRadius: const BorderRadius .all (Radius .circular (3 ))),
1256+ padding: const EdgeInsets .symmetric (horizontal: 0.2 * kBaseFontSize),
1257+ child: innerContent);
1258+ }
12381259 }
12391260
12401261// This is a more literal translation of Zulip web's CSS.
0 commit comments