Skip to content

Commit ae0b51f

Browse files
committed
user-status: Show user status with user display names throughout the app
In the following places, user status is added with display names: - message feed - recent DMs list page - new DM sheet - user autocomplete - profile page Fixes: #197
1 parent 114c432 commit ae0b51f

File tree

6 files changed

+64
-5
lines changed

6 files changed

+64
-5
lines changed

lib/widgets/autocomplete.dart

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,19 @@ class _MentionAutocompleteItem extends StatelessWidget {
315315
mainAxisSize: MainAxisSize.min,
316316
crossAxisAlignment: CrossAxisAlignment.start,
317317
children: [
318-
labelWidget,
318+
Row(
319+
children: [
320+
Flexible(child: labelWidget),
321+
if (option case UserMentionAutocompleteResult(:var userId))
322+
Padding(
323+
padding: const EdgeInsetsDirectional.only(start: 5.0),
324+
child: UserStatusEmoji(
325+
userId: userId,
326+
size: 18,
327+
notoColorEmojiTextSize: 15),
328+
)
329+
],
330+
),
319331
if (sublabelWidget != null) sublabelWidget,
320332
])),
321333
]));

lib/widgets/message_list.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,12 @@ class _SenderRow extends StatelessWidget {
17201720
color: designVariables.title,
17211721
).merge(weightVariableTextStyle(context, wght: 600)),
17221722
overflow: TextOverflow.ellipsis)),
1723+
if (sender != null)
1724+
Padding(
1725+
padding: const EdgeInsetsDirectional.only(start: 5.0),
1726+
child: UserStatusEmoji(userId: sender.userId,
1727+
size: 18, notoColorEmojiTextSize: 15),
1728+
),
17231729
if (sender?.isBot ?? false) ...[
17241730
const SizedBox(width: 5),
17251731
Icon(

lib/widgets/new_dm_sheet.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ class _SelectedUserChip extends StatelessWidget {
314314
fontSize: 16,
315315
height: 16 / 16,
316316
color: designVariables.labelMenuButton)))),
317+
UserStatusEmoji(userId: userId, size: 16, notoColorEmojiTextSize: 13.3),
318+
SizedBox(width: 4),
317319
])));
318320
}
319321
}
@@ -412,7 +414,14 @@ class _NewDmUserListItem extends StatelessWidget {
412414
Avatar(userId: userId, size: 32, borderRadius: 3),
413415
SizedBox(width: 8),
414416
Expanded(
415-
child: Text(store.userDisplayName(userId),
417+
child: Text.rich(
418+
TextSpan(
419+
children: [
420+
TextSpan(text: store.userDisplayName(userId)),
421+
UserStatusEmoji.asWidgetSpan(userId: userId, size: 17,
422+
notoColorEmojiTextSize: 14),
423+
]
424+
),
416425
style: TextStyle(
417426
fontSize: 17,
418427
height: 19 / 17,

lib/widgets/profile.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import 'message_list.dart';
1212
import 'page.dart';
1313
import 'store.dart';
1414
import 'text.dart';
15+
import 'theme.dart';
1516

1617
class _TextStyles {
1718
static const primaryFieldText = TextStyle(fontSize: 20);
@@ -43,6 +44,7 @@ class ProfilePage extends StatelessWidget {
4344
if (user == null) {
4445
return const _ProfileErrorPage();
4546
}
47+
final userStatus = store.getUserStatus(userId);
4648

4749
final nameStyle = _TextStyles.primaryFieldText
4850
.merge(weightVariableTextStyle(context, wght: 700));
@@ -66,9 +68,20 @@ class ProfilePage extends StatelessWidget {
6668
textScaler: MediaQuery.textScalerOf(context),
6769
),
6870
TextSpan(text: user.fullName),
71+
UserStatusEmoji.asWidgetSpan(
72+
userId: userId,
73+
size: 20,
74+
notoColorEmojiTextSize: 16.6,
75+
noAnimation: false,
76+
),
6977
]),
7078
textAlign: TextAlign.center,
7179
style: nameStyle),
80+
if (userStatus != null && userStatus.statusText != null)
81+
Text(userStatus.statusText!,
82+
textAlign: TextAlign.center,
83+
style: TextStyle(fontSize: 16, color: DesignVariables.of(context).statusText)),
84+
7285
if (displayEmail != null)
7386
Text(displayEmail,
7487
textAlign: TextAlign.center,

lib/widgets/recent_dm_conversations.dart

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,27 @@ class RecentDmConversationsItem extends StatelessWidget {
146146
const SizedBox(width: 8),
147147
Expanded(child: Padding(
148148
padding: const EdgeInsets.symmetric(vertical: 4),
149-
child: Text(
149+
child: Text.rich(
150+
TextSpan(
151+
children: [
152+
TextSpan(text: title),
153+
if (narrow.otherRecipientIds.length <= 1)
154+
if (narrow.otherRecipientIds case [var otherUserId])
155+
UserStatusEmoji.asWidgetSpan(userId: otherUserId,
156+
size: 17, notoColorEmojiTextSize: 14.1)
157+
else
158+
UserStatusEmoji.asWidgetSpan(userId: store.selfUserId,
159+
size: 17, notoColorEmojiTextSize: 14.1),
160+
]
161+
),
150162
style: TextStyle(
151163
fontSize: 17,
152164
height: (20 / 17),
153165
// TODO(design) check if this is the right variable
154166
color: designVariables.labelMenuButton,
155167
),
156168
maxLines: 2,
157-
overflow: TextOverflow.ellipsis,
158-
title))),
169+
overflow: TextOverflow.ellipsis))),
159170
const SizedBox(width: 12),
160171
unreadCount > 0
161172
? Padding(padding: const EdgeInsetsDirectional.only(end: 16),

lib/widgets/theme.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
198198
navigationButtonBg: Colors.black.withValues(alpha: 0.05),
199199
sectionCollapseIcon: const Color(0x7f1e2e48),
200200
star: const HSLColor.fromAHSL(0.5, 47, 1, 0.41).toColor(),
201+
statusText: const Color(0xff808080),
201202
subscriptionListHeaderLine: const HSLColor.fromAHSL(0.2, 240, 0.1, 0.5).toColor(),
202203
subscriptionListHeaderText: const HSLColor.fromAHSL(1.0, 240, 0.1, 0.5).toColor(),
203204
unreadCountBadgeTextForChannel: Colors.black.withValues(alpha: 0.9),
@@ -280,6 +281,8 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
280281
sectionCollapseIcon: const Color(0x7fb6c8e2),
281282
// TODO(design-dark) unchanged in dark theme?
282283
star: const HSLColor.fromAHSL(0.5, 47, 1, 0.41).toColor(),
284+
// TODO(design-dark) unchanged in dark theme?
285+
statusText: const Color(0xff808080),
283286
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
284287
subscriptionListHeaderLine: const HSLColor.fromAHSL(0.4, 240, 0.1, 0.75).toColor(),
285288
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
@@ -354,6 +357,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
354357
required this.navigationButtonBg,
355358
required this.sectionCollapseIcon,
356359
required this.star,
360+
required this.statusText,
357361
required this.subscriptionListHeaderLine,
358362
required this.subscriptionListHeaderText,
359363
required this.unreadCountBadgeTextForChannel,
@@ -439,6 +443,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
439443
final Color navigationButtonBg;
440444
final Color sectionCollapseIcon;
441445
final Color star;
446+
final Color statusText; // In Figma, but unnamed.
442447
final Color subscriptionListHeaderLine;
443448
final Color subscriptionListHeaderText;
444449
final Color unreadCountBadgeTextForChannel;
@@ -511,6 +516,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
511516
Color? navigationButtonBg,
512517
Color? sectionCollapseIcon,
513518
Color? star,
519+
Color? statusText,
514520
Color? subscriptionListHeaderLine,
515521
Color? subscriptionListHeaderText,
516522
Color? unreadCountBadgeTextForChannel,
@@ -582,6 +588,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
582588
navigationButtonBg: navigationButtonBg ?? this.navigationButtonBg,
583589
sectionCollapseIcon: sectionCollapseIcon ?? this.sectionCollapseIcon,
584590
star: star ?? this.star,
591+
statusText: statusText ?? this.statusText,
585592
subscriptionListHeaderLine: subscriptionListHeaderLine ?? this.subscriptionListHeaderLine,
586593
subscriptionListHeaderText: subscriptionListHeaderText ?? this.subscriptionListHeaderText,
587594
unreadCountBadgeTextForChannel: unreadCountBadgeTextForChannel ?? this.unreadCountBadgeTextForChannel,
@@ -660,6 +667,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
660667
navigationButtonBg: Color.lerp(navigationButtonBg, other.navigationButtonBg, t)!,
661668
sectionCollapseIcon: Color.lerp(sectionCollapseIcon, other.sectionCollapseIcon, t)!,
662669
star: Color.lerp(star, other.star, t)!,
670+
statusText: Color.lerp(statusText, other.statusText, t)!,
663671
subscriptionListHeaderLine: Color.lerp(subscriptionListHeaderLine, other.subscriptionListHeaderLine, t)!,
664672
subscriptionListHeaderText: Color.lerp(subscriptionListHeaderText, other.subscriptionListHeaderText, t)!,
665673
unreadCountBadgeTextForChannel: Color.lerp(unreadCountBadgeTextForChannel, other.unreadCountBadgeTextForChannel, t)!,

0 commit comments

Comments
 (0)