@@ -289,6 +289,11 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
289
289
290
290
/// A user status emoji to be displayed in different parts of the app.
291
291
///
292
+ /// Use [userId] to show status emoji for that user.
293
+ /// Use [emoji] to show the specific emoji passed.
294
+ ///
295
+ /// Only one of [userId] or [emoji] should be passed.
296
+ ///
292
297
/// Use [padding] to control the padding of status emoji from neighboring
293
298
/// widgets.
294
299
/// When there is no status emoji to be shown, the padding will be omitted too.
@@ -298,13 +303,16 @@ class _PresenceCircleState extends State<PresenceCircle> with PerAccountStoreAwa
298
303
class UserStatusEmoji extends StatelessWidget {
299
304
const UserStatusEmoji ({
300
305
super .key,
301
- required this .userId,
306
+ this .userId,
307
+ this .emoji,
302
308
required this .size,
303
309
this .padding = EdgeInsets .zero,
304
310
this .neverAnimate = true ,
305
- });
311
+ }) : assert ((userId == null ) != (emoji == null ),
312
+ 'Only one of the userId or emoji should be provided.' );
306
313
307
- final int userId;
314
+ final int ? userId;
315
+ final StatusEmoji ? emoji;
308
316
final double size;
309
317
final EdgeInsetsGeometry padding;
310
318
final bool neverAnimate;
@@ -317,7 +325,8 @@ class UserStatusEmoji extends StatelessWidget {
317
325
/// Use [position] to tell the emoji span where it is located relative to
318
326
/// another span, so that it can adjust the necessary padding from it.
319
327
static InlineSpan asWidgetSpan ({
320
- required int userId,
328
+ int ? userId,
329
+ StatusEmoji ? emoji,
321
330
required double fontSize,
322
331
required TextScaler textScaler,
323
332
StatusEmojiPosition position = StatusEmojiPosition .after,
@@ -330,23 +339,23 @@ class UserStatusEmoji extends StatelessWidget {
330
339
final size = textScaler.scale (fontSize);
331
340
return WidgetSpan (
332
341
alignment: PlaceholderAlignment .middle,
333
- child: UserStatusEmoji (userId: userId, size: size,
342
+ child: UserStatusEmoji (userId: userId, emoji : emoji, size: size,
334
343
padding: EdgeInsetsDirectional .only (start: paddingStart, end: paddingEnd),
335
344
neverAnimate: neverAnimate));
336
345
}
337
346
338
347
@override
339
348
Widget build (BuildContext context) {
340
349
final store = PerAccountStoreWidget .of (context);
341
- final emoji = store.getUserStatus (userId).emoji;
350
+ final effectiveEmoji = emoji ?? store.getUserStatus (userId! ).emoji;
342
351
343
352
final placeholder = SizedBox .shrink ();
344
- if (emoji == null ) return placeholder;
353
+ if (effectiveEmoji == null ) return placeholder;
345
354
346
355
final emojiDisplay = store.emojiDisplayFor (
347
- emojiType: emoji .reactionType,
348
- emojiCode: emoji .emojiCode,
349
- emojiName: emoji .emojiName)
356
+ emojiType: effectiveEmoji .reactionType,
357
+ emojiCode: effectiveEmoji .emojiCode,
358
+ emojiName: effectiveEmoji .emojiName)
350
359
// Web doesn't seem to respect the emojiset user settings for user status.
351
360
// .resolve(store.userSettings)
352
361
;
0 commit comments