@@ -2012,6 +2012,11 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
2012
2012
2013
2013
/// A user status emoji to be displayed in different parts of the app.
2014
2014
///
2015
+ /// Use [userId] to show status emoji for that user.
2016
+ /// Use [emoji] to show the specific emoji passed.
2017
+ ///
2018
+ /// Only one of [userId] or [emoji] should be passed.
2019
+ ///
2015
2020
/// Use [padding] to control the padding of status emoji from neighboring
2016
2021
/// widgets.
2017
2022
/// When there is no status emoji to be shown, the padding will be omitted too.
@@ -2021,13 +2026,16 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
2021
2026
class UserStatusEmoji extends StatelessWidget {
2022
2027
const UserStatusEmoji ({
2023
2028
super .key,
2024
- required this .userId,
2029
+ this .userId,
2030
+ this .emoji,
2025
2031
required this .size,
2026
2032
this .padding = EdgeInsets .zero,
2027
2033
this .neverAnimate = true ,
2028
- });
2034
+ }) : assert ((userId == null ) != (emoji == null ),
2035
+ 'Only one of the userId or emoji should be provided.' );
2029
2036
2030
- final int userId;
2037
+ final int ? userId;
2038
+ final StatusEmoji ? emoji;
2031
2039
final double size;
2032
2040
final EdgeInsetsGeometry padding;
2033
2041
final bool neverAnimate;
@@ -2040,7 +2048,8 @@ class UserStatusEmoji extends StatelessWidget {
2040
2048
/// Use [position] to tell the emoji span where it is located relative to
2041
2049
/// another span, so that it can adjust the necessary padding from it.
2042
2050
static InlineSpan asWidgetSpan ({
2043
- required int userId,
2051
+ int ? userId,
2052
+ StatusEmoji ? emoji,
2044
2053
required double fontSize,
2045
2054
required TextScaler textScaler,
2046
2055
StatusEmojiPosition position = StatusEmojiPosition .after,
@@ -2053,23 +2062,25 @@ class UserStatusEmoji extends StatelessWidget {
2053
2062
final size = textScaler.scale (fontSize);
2054
2063
return WidgetSpan (
2055
2064
alignment: PlaceholderAlignment .middle,
2056
- child: UserStatusEmoji (userId: userId, size: size,
2065
+ child: UserStatusEmoji (userId: userId, emoji : emoji, size: size,
2057
2066
padding: EdgeInsetsDirectional .only (start: paddingStart, end: paddingEnd),
2058
2067
neverAnimate: neverAnimate));
2059
2068
}
2060
2069
2061
2070
@override
2062
2071
Widget build (BuildContext context) {
2063
2072
final store = PerAccountStoreWidget .of (context);
2064
- final emoji = store.getUserStatus (userId).emoji;
2073
+ final effectiveEmoji = userId != null
2074
+ ? store.getUserStatus (userId! ).emoji
2075
+ : emoji;
2065
2076
2066
2077
final placeholder = SizedBox .shrink ();
2067
- if (emoji == null ) return placeholder;
2078
+ if (effectiveEmoji == null ) return placeholder;
2068
2079
2069
2080
final emojiDisplay = store.emojiDisplayFor (
2070
- emojiType: emoji .reactionType,
2071
- emojiCode: emoji .emojiCode,
2072
- emojiName: emoji .emojiName)
2081
+ emojiType: effectiveEmoji .reactionType,
2082
+ emojiCode: effectiveEmoji .emojiCode,
2083
+ emojiName: effectiveEmoji .emojiName)
2073
2084
// Web doesn't seem to respect the emojiset user settings for user status.
2074
2085
// .resolve(store.userSettings)
2075
2086
;
0 commit comments