@@ -1820,6 +1820,11 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
1820
1820
1821
1821
/// A user status emoji to be displayed in different parts of the app.
1822
1822
///
1823
+ /// Use [userId] to show status emoji for that user.
1824
+ /// Use [emoji] to show the specific emoji passed.
1825
+ ///
1826
+ /// Only one of [userId] or [emoji] should be passed.
1827
+ ///
1823
1828
/// Use [padding] to control the padding of status emoji from neighboring
1824
1829
/// widgets.
1825
1830
/// When there is no status emoji to be shown, the padding will be omitted too.
@@ -1829,13 +1834,16 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
1829
1834
class UserStatusEmoji extends StatelessWidget {
1830
1835
const UserStatusEmoji ({
1831
1836
super .key,
1832
- required this .userId,
1837
+ this .userId,
1838
+ this .emoji,
1833
1839
required this .size,
1834
1840
this .padding = EdgeInsets .zero,
1835
1841
this .neverAnimate = true ,
1836
- });
1842
+ }) : assert ((userId == null ) != (emoji == null ),
1843
+ 'Only one of the userId or emoji should be provided.' );
1837
1844
1838
- final int userId;
1845
+ final int ? userId;
1846
+ final StatusEmoji ? emoji;
1839
1847
final double size;
1840
1848
final EdgeInsetsGeometry padding;
1841
1849
final bool neverAnimate;
@@ -1848,7 +1856,8 @@ class UserStatusEmoji extends StatelessWidget {
1848
1856
/// Use [position] to tell the emoji span where it is located relative to
1849
1857
/// another span, so that it can adjust the necessary padding from it.
1850
1858
static InlineSpan asWidgetSpan ({
1851
- required int userId,
1859
+ int ? userId,
1860
+ StatusEmoji ? emoji,
1852
1861
required double fontSize,
1853
1862
required TextScaler textScaler,
1854
1863
StatusEmojiPosition position = StatusEmojiPosition .after,
@@ -1861,23 +1870,23 @@ class UserStatusEmoji extends StatelessWidget {
1861
1870
final size = textScaler.scale (fontSize);
1862
1871
return WidgetSpan (
1863
1872
alignment: PlaceholderAlignment .middle,
1864
- child: UserStatusEmoji (userId: userId, size: size,
1873
+ child: UserStatusEmoji (userId: userId, emoji : emoji, size: size,
1865
1874
padding: EdgeInsetsDirectional .only (start: paddingStart, end: paddingEnd),
1866
1875
neverAnimate: neverAnimate));
1867
1876
}
1868
1877
1869
1878
@override
1870
1879
Widget build (BuildContext context) {
1871
1880
final store = PerAccountStoreWidget .of (context);
1872
- final emoji = store.getUserStatus (userId).emoji;
1881
+ final effectiveEmoji = emoji ?? store.getUserStatus (userId! ).emoji;
1873
1882
1874
1883
final placeholder = SizedBox .shrink ();
1875
- if (emoji == null ) return placeholder;
1884
+ if (effectiveEmoji == null ) return placeholder;
1876
1885
1877
1886
final emojiDisplay = store.emojiDisplayFor (
1878
- emojiType: emoji .reactionType,
1879
- emojiCode: emoji .emojiCode,
1880
- emojiName: emoji .emojiName)
1887
+ emojiType: effectiveEmoji .reactionType,
1888
+ emojiCode: effectiveEmoji .emojiCode,
1889
+ emojiName: effectiveEmoji .emojiName)
1881
1890
// Web doesn't seem to respect the emojiset user settings for user status.
1882
1891
// .resolve(store.userSettings)
1883
1892
;
0 commit comments