@@ -14,12 +14,14 @@ import '../generated/l10n/zulip_localizations.dart';
14
14
import '../model/avatar_url.dart' ;
15
15
import '../model/binding.dart' ;
16
16
import '../model/content.dart' ;
17
+ import '../model/emoji.dart' ;
17
18
import '../model/internal_link.dart' ;
18
19
import '../model/katex.dart' ;
19
20
import '../model/presence.dart' ;
20
21
import 'actions.dart' ;
21
22
import 'code_block.dart' ;
22
23
import 'dialog.dart' ;
24
+ import 'emoji.dart' ;
23
25
import 'icons.dart' ;
24
26
import 'inset_shadow.dart' ;
25
27
import 'lightbox.dart' ;
@@ -1933,6 +1935,75 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
1933
1935
}
1934
1936
}
1935
1937
1938
+ /// A user status emoji to be displayed in different parts of the app.
1939
+ ///
1940
+ /// Use [neverAnimate] to forcefully disable the animation for animated emojis.
1941
+ class UserStatusEmoji extends StatelessWidget {
1942
+ const UserStatusEmoji ({
1943
+ super .key,
1944
+ required this .userId,
1945
+ required this .size,
1946
+ required this .notoColorEmojiTextSize,
1947
+ this .neverAnimate = true ,
1948
+ });
1949
+
1950
+ final int userId;
1951
+ final double size;
1952
+ final double notoColorEmojiTextSize;
1953
+ final bool neverAnimate;
1954
+
1955
+ /// Creates a [WidgetSpan] with a [UserStatusEmoji] , for use in rich text
1956
+ /// after a user's name.
1957
+ static InlineSpan asWidgetSpan ({
1958
+ required int userId,
1959
+ required double size,
1960
+ required double notoColorEmojiTextSize,
1961
+ bool noAnimation = true ,
1962
+ }) {
1963
+ return WidgetSpan (
1964
+ alignment: PlaceholderAlignment .middle,
1965
+ child: Padding (
1966
+ padding: const EdgeInsetsDirectional .only (start: 4.0 ),
1967
+ child: UserStatusEmoji (userId: userId, size: size,
1968
+ notoColorEmojiTextSize: notoColorEmojiTextSize, neverAnimate: noAnimation)));
1969
+ }
1970
+
1971
+ @override
1972
+ Widget build (BuildContext context) {
1973
+ final store = PerAccountStoreWidget .of (context);
1974
+ final emoji = store.getUserStatus (userId).emoji;
1975
+
1976
+ final placeholder = SizedBox .shrink ();
1977
+ if (emoji == null ) return placeholder;
1978
+
1979
+ final emojiDisplay = store.emojiDisplayFor (
1980
+ emojiType: emoji.reactionType,
1981
+ emojiCode: emoji.emojiCode,
1982
+ emojiName: emoji.emojiName)
1983
+ // Web doesn't seem to respect the emojiset user settings for user status.
1984
+ // .resolve(store.userSettings)
1985
+ ;
1986
+ return switch (emojiDisplay) {
1987
+ UnicodeEmojiDisplay () => UnicodeEmojiWidget (
1988
+ size: size,
1989
+ emojiDisplay: emojiDisplay,
1990
+ notoColorEmojiTextSize: notoColorEmojiTextSize,
1991
+ ),
1992
+ ImageEmojiDisplay () => ImageEmojiWidget (
1993
+ size: size,
1994
+ emojiDisplay: emojiDisplay,
1995
+ neverAnimate: neverAnimate,
1996
+ // If image emoji fails to load, show nothing.
1997
+ errorBuilder: (_, _, _) => placeholder,
1998
+ ),
1999
+ // The user-status feature doesn't support a :text_emoji:-style display.
2000
+ // Also, if an image emoji's URL string doesn't parse, it'll fall back to
2001
+ // a :text_emoji:-style display. We show nothing for this case.
2002
+ TextEmojiDisplay () => placeholder,
2003
+ };
2004
+ }
2005
+ }
2006
+
1936
2007
//
1937
2008
// Small helpers.
1938
2009
//
0 commit comments