@@ -1944,6 +1944,11 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
19441944
19451945/// A user status emoji to be displayed in different parts of the app.
19461946///
1947+ /// Pass [userId] to show status emoji for that user, if one is set.
1948+ /// Pass [emoji] to show that specific emoji.
1949+ ///
1950+ /// Only one of [userId] or [emoji] should be passed.
1951+ ///
19471952/// Use [padding] to control the padding of status emoji from neighboring
19481953/// widgets.
19491954/// When there is no status emoji to be shown, the padding will be omitted too.
@@ -1953,13 +1958,16 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
19531958class UserStatusEmoji extends StatelessWidget {
19541959 const UserStatusEmoji ({
19551960 super .key,
1956- required this .userId,
1961+ this .userId,
1962+ this .emoji,
19571963 required this .size,
19581964 this .padding = EdgeInsets .zero,
19591965 this .neverAnimate = true ,
1960- });
1966+ }) : assert ((userId == null ) != (emoji == null ),
1967+ 'Only one of the userId or emoji should be provided.' );
19611968
1962- final int userId;
1969+ final int ? userId;
1970+ final StatusEmoji ? emoji;
19631971 final double size;
19641972 final EdgeInsetsGeometry padding;
19651973 final bool neverAnimate;
@@ -1972,7 +1980,8 @@ class UserStatusEmoji extends StatelessWidget {
19721980 /// Use [position] to tell the emoji span where it is located relative to
19731981 /// another span, so that it can adjust the necessary padding from it.
19741982 static InlineSpan asWidgetSpan ({
1975- required int userId,
1983+ int ? userId,
1984+ StatusEmoji ? emoji,
19761985 required double fontSize,
19771986 required TextScaler textScaler,
19781987 StatusEmojiPosition position = StatusEmojiPosition .after,
@@ -1985,23 +1994,25 @@ class UserStatusEmoji extends StatelessWidget {
19851994 final size = textScaler.scale (fontSize);
19861995 return WidgetSpan (
19871996 alignment: PlaceholderAlignment .middle,
1988- child: UserStatusEmoji (userId: userId, size: size,
1997+ child: UserStatusEmoji (userId: userId, emoji : emoji, size: size,
19891998 padding: EdgeInsetsDirectional .only (start: paddingStart, end: paddingEnd),
19901999 neverAnimate: neverAnimate));
19912000 }
19922001
19932002 @override
19942003 Widget build (BuildContext context) {
19952004 final store = PerAccountStoreWidget .of (context);
1996- final emoji = store.getUserStatus (userId).emoji;
2005+ final effectiveEmoji = userId != null
2006+ ? store.getUserStatus (userId! ).emoji
2007+ : emoji;
19972008
19982009 final placeholder = SizedBox .shrink ();
1999- if (emoji == null ) return placeholder;
2010+ if (effectiveEmoji == null ) return placeholder;
20002011
20012012 final emojiDisplay = store.emojiDisplayFor (
2002- emojiType: emoji .reactionType,
2003- emojiCode: emoji .emojiCode,
2004- emojiName: emoji .emojiName)
2013+ emojiType: effectiveEmoji .reactionType,
2014+ emojiCode: effectiveEmoji .emojiCode,
2015+ emojiName: effectiveEmoji .emojiName)
20052016 // Web doesn't seem to respect the emojiset user settings for user status.
20062017 // .resolve(store.userSettings)
20072018 ;
0 commit comments