Skip to content

Commit 4b17b0c

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. Fixes zulip#681.
1 parent 4c04d07 commit 4b17b0c

File tree

3 files changed

+57
-5
lines changed

3 files changed

+57
-5
lines changed

lib/widgets/message_list.dart

+20-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
3030
static final light = MessageListTheme._(
3131
dateSeparator: Colors.black,
3232
dateSeparatorText: const HSLColor.fromAHSL(0.75, 0, 0, 0.15).toColor(),
33+
dmMessageBgDefault: const HSLColor.fromAHSL(1, 45, 0.20, 0.96).toColor(),
3334
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
3435
messageTimestamp: const HSLColor.fromAHSL(0.8, 0, 0, 0.2).toColor(),
3536
recipientHeaderText: const HSLColor.fromAHSL(1, 0, 0, 0.15).toColor(),
@@ -55,6 +56,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
5556
static final dark = MessageListTheme._(
5657
dateSeparator: Colors.white,
5758
dateSeparatorText: const HSLColor.fromAHSL(0.75, 0, 0, 1).toColor(),
59+
dmMessageBgDefault: const HSLColor.fromAHSL(1, 46, 0.07, 0.16).toColor(),
5860
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
5961
messageTimestamp: const HSLColor.fromAHSL(0.8, 0, 0, 0.85).toColor(),
6062
recipientHeaderText: const HSLColor.fromAHSL(0.8, 0, 0, 1).toColor(),
@@ -79,6 +81,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
7981
MessageListTheme._({
8082
required this.dateSeparator,
8183
required this.dateSeparatorText,
84+
required this.dmMessageBgDefault,
8285
required this.dmRecipientHeaderBg,
8386
required this.messageTimestamp,
8487
required this.recipientHeaderText,
@@ -103,6 +106,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
103106

104107
final Color dateSeparator;
105108
final Color dateSeparatorText;
109+
final Color dmMessageBgDefault;
106110
final Color dmRecipientHeaderBg;
107111
final Color messageTimestamp;
108112
final Color recipientHeaderText;
@@ -118,6 +122,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
118122
MessageListTheme copyWith({
119123
Color? dateSeparator,
120124
Color? dateSeparatorText,
125+
Color? dmMessageBgDefault,
121126
Color? dmRecipientHeaderBg,
122127
Color? messageTimestamp,
123128
Color? recipientHeaderText,
@@ -132,6 +137,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
132137
return MessageListTheme._(
133138
dateSeparator: dateSeparator ?? this.dateSeparator,
134139
dateSeparatorText: dateSeparatorText ?? this.dateSeparatorText,
140+
dmMessageBgDefault: dmMessageBgDefault ?? this.dmMessageBgDefault,
135141
dmRecipientHeaderBg: dmRecipientHeaderBg ?? this.dmRecipientHeaderBg,
136142
messageTimestamp: messageTimestamp ?? this.messageTimestamp,
137143
recipientHeaderText: recipientHeaderText ?? this.recipientHeaderText,
@@ -153,6 +159,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
153159
return MessageListTheme._(
154160
dateSeparator: Color.lerp(dateSeparator, other.dateSeparator, t)!,
155161
dateSeparatorText: Color.lerp(dateSeparatorText, other.dateSeparatorText, t)!,
162+
dmMessageBgDefault: Color.lerp(dmMessageBgDefault, other.dmMessageBgDefault, t)!,
156163
dmRecipientHeaderBg: Color.lerp(streamMessageBgDefault, other.dmRecipientHeaderBg, t)!,
157164
messageTimestamp: Color.lerp(messageTimestamp, other.messageTimestamp, t)!,
158165
recipientHeaderText: Color.lerp(recipientHeaderText, other.recipientHeaderText, t)!,
@@ -924,8 +931,12 @@ class DateSeparator extends StatelessWidget {
924931

925932
final line = BorderSide(width: 0, color: messageListTheme.dateSeparator);
926933

927-
// TODO(#681) use different color for DM messages
928-
return ColoredBox(color: messageListTheme.streamMessageBgDefault,
934+
final backgroundColor = switch (message) {
935+
StreamMessage() => messageListTheme.streamMessageBgDefault,
936+
DmMessage() => messageListTheme.dmMessageBgDefault,
937+
};
938+
939+
return ColoredBox(color: backgroundColor,
929940
child: Padding(
930941
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 2),
931942
child: Row(children: [
@@ -966,13 +977,19 @@ class MessageItem extends StatelessWidget {
966977
Widget build(BuildContext context) {
967978
final message = item.message;
968979
final messageListTheme = MessageListTheme.of(context);
980+
981+
final backgroundColor = switch (message) {
982+
StreamMessage() => messageListTheme.streamMessageBgDefault,
983+
DmMessage() => messageListTheme.dmMessageBgDefault,
984+
};
985+
969986
return StickyHeaderItem(
970987
allowOverflow: !item.isLastInBlock,
971988
header: header,
972989
child: _UnreadMarker(
973990
isRead: message.flags.contains(MessageFlag.read),
974991
child: ColoredBox(
975-
color: messageListTheme.streamMessageBgDefault,
992+
color: backgroundColor,
976993
child: Column(children: [
977994
MessageWithPossibleSender(item: item),
978995
if (trailingWhitespace != null && item.isLastInBlock) SizedBox(height: trailingWhitespace!),

pubspec.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1044,10 +1044,10 @@ packages:
10441044
dependency: transitive
10451045
description:
10461046
name: stream_channel
1047-
sha256: "4ac0537115a24d772c408a2520ecd0abb99bca2ea9c4e634ccbdbfae64fe17ec"
1047+
sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d"
10481048
url: "https://pub.dev"
10491049
source: hosted
1050-
version: "2.1.3"
1050+
version: "2.1.4"
10511051
stream_transform:
10521052
dependency: transitive
10531053
description:

tools/customer-testing/setup.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
# Setup script for running Zulip's tests as part of the Flutter
3+
# "customer testing" suite:
4+
# https://github.com/flutter/tests
5+
6+
set -euo pipefail
7+
8+
# Flutter's "customer testing" suite runs in two environments:
9+
# * GitHub Actions for changes to the flutter/tests tree itself
10+
# (which is just a registry of downstream test suites to run);
11+
# * LUCI, at ci.chromium.org, for changes in Flutter.
12+
#
13+
# For background, see:
14+
# https://github.com/flutter/flutter/issues/162041#issuecomment-2611129958
15+
16+
if ! sudo -v; then
17+
# In the LUCI environment sudo isn't available,
18+
# but also the setup below isn't needed. Skip it.
19+
exit 0
20+
fi
21+
22+
# Otherwise, assume we're in the GitHub Actions environment.
23+
24+
25+
# Install libsqlite3-dev.
26+
#
27+
# A few Zulip tests use SQLite, and so need libsqlite3.so.
28+
# (The actual databases involved are tiny and in-memory.)
29+
#
30+
# Both older and newer GitHub Actions images have the SQLite shared
31+
# library, from the libsqlite3-0 package. But newer images
32+
# (ubuntu-24.04, which the ubuntu-latest alias switched to around
33+
# 2025-01) no longer have a symlink "libsqlite3.so" pointing to it,
34+
# which is part of the libsqlite3-dev package. Install that.
35+
sudo apt install -y libsqlite3-dev

0 commit comments

Comments
 (0)