@@ -1944,6 +1944,11 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
1944
1944
1945
1945
/// A user status emoji to be displayed in different parts of the app.
1946
1946
///
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
+ ///
1947
1952
/// Use [padding] to control the padding of status emoji from neighboring
1948
1953
/// widgets.
1949
1954
/// 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
1953
1958
class UserStatusEmoji extends StatelessWidget {
1954
1959
const UserStatusEmoji ({
1955
1960
super .key,
1956
- required this .userId,
1961
+ this .userId,
1962
+ this .emoji,
1957
1963
required this .size,
1958
1964
this .padding = EdgeInsets .zero,
1959
1965
this .neverAnimate = true ,
1960
- });
1966
+ }) : assert ((userId == null ) != (emoji == null ),
1967
+ 'Only one of the userId or emoji should be provided.' );
1961
1968
1962
- final int userId;
1969
+ final int ? userId;
1970
+ final StatusEmoji ? emoji;
1963
1971
final double size;
1964
1972
final EdgeInsetsGeometry padding;
1965
1973
final bool neverAnimate;
@@ -1972,7 +1980,8 @@ class UserStatusEmoji extends StatelessWidget {
1972
1980
/// Use [position] to tell the emoji span where it is located relative to
1973
1981
/// another span, so that it can adjust the necessary padding from it.
1974
1982
static InlineSpan asWidgetSpan ({
1975
- required int userId,
1983
+ int ? userId,
1984
+ StatusEmoji ? emoji,
1976
1985
required double fontSize,
1977
1986
required TextScaler textScaler,
1978
1987
StatusEmojiPosition position = StatusEmojiPosition .after,
@@ -1985,23 +1994,25 @@ class UserStatusEmoji extends StatelessWidget {
1985
1994
final size = textScaler.scale (fontSize);
1986
1995
return WidgetSpan (
1987
1996
alignment: PlaceholderAlignment .middle,
1988
- child: UserStatusEmoji (userId: userId, size: size,
1997
+ child: UserStatusEmoji (userId: userId, emoji : emoji, size: size,
1989
1998
padding: EdgeInsetsDirectional .only (start: paddingStart, end: paddingEnd),
1990
1999
neverAnimate: neverAnimate));
1991
2000
}
1992
2001
1993
2002
@override
1994
2003
Widget build (BuildContext context) {
1995
2004
final store = PerAccountStoreWidget .of (context);
1996
- final emoji = store.getUserStatus (userId).emoji;
2005
+ final effectiveEmoji = userId != null
2006
+ ? store.getUserStatus (userId! ).emoji
2007
+ : emoji;
1997
2008
1998
2009
final placeholder = SizedBox .shrink ();
1999
- if (emoji == null ) return placeholder;
2010
+ if (effectiveEmoji == null ) return placeholder;
2000
2011
2001
2012
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)
2005
2016
// Web doesn't seem to respect the emojiset user settings for user status.
2006
2017
// .resolve(store.userSettings)
2007
2018
;
0 commit comments