Skip to content

Commit 9f4fd69

Browse files
msglist: Use distinct background colors for DM messages.
This commit modifies DmMessage and its DateSeparator to use a different background color from StreamMessage. This matches the web app's behavior where DM messages have a distinct background color. Added new theme colors to MessageListTheme(These colors match the web app version) * Light theme: hsl(45deg 20% 96%) * Dark theme: hsl(46deg 7% 16%) Fixes zulip#681.
1 parent a23309a commit 9f4fd69

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

lib/widgets/message_list.dart

+28-4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
3636
senderBotIcon: const HSLColor.fromAHSL(1, 180, 0.08, 0.65).toColor(),
3737
senderName: const HSLColor.fromAHSL(1, 0, 0, 0.2).toColor(),
3838
streamMessageBgDefault: Colors.white,
39+
// Background color for DM messages in light theme.
40+
// Matches web app's --color-background-private-message-content: hsl(45deg 20% 96%)
41+
dmMessageBgDefault: const HSLColor.fromAHSL(1, 45, 0.20, 0.96).toColor(),
3942
streamRecipientHeaderChevronRight: Colors.black.withValues(alpha: 0.3),
4043

4144
// From the Figma mockup at:
@@ -61,6 +64,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
6164
senderBotIcon: const HSLColor.fromAHSL(1, 180, 0.05, 0.5).toColor(),
6265
senderName: const HSLColor.fromAHSL(0.85, 0, 0, 1).toColor(),
6366
streamMessageBgDefault: const HSLColor.fromAHSL(1, 0, 0, 0.15).toColor(),
67+
// Background color for DM messages in dark theme.
68+
// Matches web app's --color-background-private-message-content: hsl(46deg 7% 16%)
69+
dmMessageBgDefault: const HSLColor.fromAHSL(1, 46, 0.07, 0.16).toColor(),
6470
streamRecipientHeaderChevronRight: Colors.white.withValues(alpha: 0.3),
6571

6672
// 0.75 opacity from here:
@@ -85,6 +91,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
8591
required this.senderBotIcon,
8692
required this.senderName,
8793
required this.streamMessageBgDefault,
94+
required this.dmMessageBgDefault,
8895
required this.streamRecipientHeaderChevronRight,
8996
required this.unreadMarker,
9097
required this.unreadMarkerGap,
@@ -109,6 +116,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
109116
final Color senderBotIcon;
110117
final Color senderName;
111118
final Color streamMessageBgDefault;
119+
final Color dmMessageBgDefault;
112120
final Color streamRecipientHeaderChevronRight;
113121
final Color unreadMarker;
114122
final Color unreadMarkerGap;
@@ -124,6 +132,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
124132
Color? senderBotIcon,
125133
Color? senderName,
126134
Color? streamMessageBgDefault,
135+
Color? dmMessageBgDefault,
127136
Color? streamRecipientHeaderChevronRight,
128137
Color? unreadMarker,
129138
Color? unreadMarkerGap,
@@ -138,6 +147,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
138147
senderBotIcon: senderBotIcon ?? this.senderBotIcon,
139148
senderName: senderName ?? this.senderName,
140149
streamMessageBgDefault: streamMessageBgDefault ?? this.streamMessageBgDefault,
150+
dmMessageBgDefault: dmMessageBgDefault ?? this.dmMessageBgDefault,
141151
streamRecipientHeaderChevronRight: streamRecipientHeaderChevronRight ?? this.streamRecipientHeaderChevronRight,
142152
unreadMarker: unreadMarker ?? this.unreadMarker,
143153
unreadMarkerGap: unreadMarkerGap ?? this.unreadMarkerGap,
@@ -153,12 +163,13 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
153163
return MessageListTheme._(
154164
dateSeparator: Color.lerp(dateSeparator, other.dateSeparator, t)!,
155165
dateSeparatorText: Color.lerp(dateSeparatorText, other.dateSeparatorText, t)!,
156-
dmRecipientHeaderBg: Color.lerp(streamMessageBgDefault, other.dmRecipientHeaderBg, t)!,
166+
dmRecipientHeaderBg: Color.lerp(dmRecipientHeaderBg, other.dmRecipientHeaderBg, t)!,
157167
messageTimestamp: Color.lerp(messageTimestamp, other.messageTimestamp, t)!,
158168
recipientHeaderText: Color.lerp(recipientHeaderText, other.recipientHeaderText, t)!,
159169
senderBotIcon: Color.lerp(senderBotIcon, other.senderBotIcon, t)!,
160170
senderName: Color.lerp(senderName, other.senderName, t)!,
161171
streamMessageBgDefault: Color.lerp(streamMessageBgDefault, other.streamMessageBgDefault, t)!,
172+
dmMessageBgDefault: Color.lerp(dmMessageBgDefault, other.dmMessageBgDefault, t)!,
162173
streamRecipientHeaderChevronRight: Color.lerp(streamRecipientHeaderChevronRight, other.streamRecipientHeaderChevronRight, t)!,
163174
unreadMarker: Color.lerp(unreadMarker, other.unreadMarker, t)!,
164175
unreadMarkerGap: Color.lerp(unreadMarkerGap, other.unreadMarkerGap, t)!,
@@ -931,8 +942,14 @@ class DateSeparator extends StatelessWidget {
931942

932943
final line = BorderSide(width: 0, color: messageListTheme.dateSeparator);
933944

934-
// TODO(#681) use different color for DM messages
935-
return ColoredBox(color: messageListTheme.streamMessageBgDefault,
945+
// Choose background color based on message type to maintain visual consistency
946+
// DM messages and their date separators share the same distinct background
947+
final backgroundColor = switch (message) {
948+
StreamMessage() => messageListTheme.streamMessageBgDefault,
949+
DmMessage() => messageListTheme.dmMessageBgDefault,
950+
};
951+
952+
return ColoredBox(color: backgroundColor,
936953
child: Padding(
937954
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 2),
938955
child: Row(children: [
@@ -973,13 +990,20 @@ class MessageItem extends StatelessWidget {
973990
Widget build(BuildContext context) {
974991
final message = item.message;
975992
final messageListTheme = MessageListTheme.of(context);
993+
994+
// Choose background color based on message type to maintain consistency
995+
final backgroundColor = switch (message) {
996+
StreamMessage() => messageListTheme.streamMessageBgDefault,
997+
DmMessage() => messageListTheme.dmMessageBgDefault,
998+
};
999+
9761000
return StickyHeaderItem(
9771001
allowOverflow: !item.isLastInBlock,
9781002
header: header,
9791003
child: _UnreadMarker(
9801004
isRead: message.flags.contains(MessageFlag.read),
9811005
child: ColoredBox(
982-
color: messageListTheme.streamMessageBgDefault,
1006+
color: backgroundColor,
9831007
child: Column(children: [
9841008
MessageWithPossibleSender(item: item),
9851009
if (trailingWhitespace != null && item.isLastInBlock) SizedBox(height: trailingWhitespace!),

pubspec.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1361,4 +1361,4 @@ packages:
13611361
version: "0.0.1"
13621362
sdks:
13631363
dart: ">=3.7.0-312.0.dev <4.0.0"
1364-
flutter: ">=3.28.0-2.0.pre.38699"
1364+
flutter: ">=3.28.0-2.0.pre.38699"

0 commit comments

Comments
 (0)