Skip to content

Commit beee77e

Browse files
chrisbobbegnprice
authored andcommitted
msglist: Add MessageListTheme.messageTimestamp
Web expresses this as separate `color` and `opacity` attributes. We combine those attributes into a single Color, where the alpha is the alpha from `color` multiplied by the `opacity`. So, for light theme: 1 * 0.8 = 0.8 And for dark theme: 0.75 * 0.8 = 0.6
1 parent 5fe9361 commit beee77e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/widgets/message_list.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
3131
dateSeparator: Colors.black,
3232
dateSeparatorText: const HSLColor.fromAHSL(0.75, 0, 0, 0.15).toColor(),
3333
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
34+
messageTimestamp: const HSLColor.fromAHSL(0.8, 0, 0, 0.2).toColor(),
3435
recipientHeaderText: const HSLColor.fromAHSL(1, 0, 0, 0.15).toColor(),
3536
senderBotIcon: const HSLColor.fromAHSL(1, 180, 0.08, 0.65).toColor(),
3637
senderName: const HSLColor.fromAHSL(1, 0, 0, 0.2).toColor(),
@@ -56,6 +57,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
5657
dateSeparator: Colors.white,
5758
dateSeparatorText: const HSLColor.fromAHSL(0.75, 0, 0, 1).toColor(),
5859
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
60+
messageTimestamp: const HSLColor.fromAHSL(0.6, 0, 0, 1).toColor(),
5961
recipientHeaderText: const HSLColor.fromAHSL(0.8, 0, 0, 1).toColor(),
6062
senderBotIcon: const HSLColor.fromAHSL(1, 180, 0.05, 0.5).toColor(),
6163
senderName: const HSLColor.fromAHSL(0.85, 0, 0, 1).toColor(),
@@ -79,6 +81,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
7981
required this.dateSeparator,
8082
required this.dateSeparatorText,
8183
required this.dmRecipientHeaderBg,
84+
required this.messageTimestamp,
8285
required this.recipientHeaderText,
8386
required this.senderBotIcon,
8487
required this.senderName,
@@ -102,6 +105,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
102105
final Color dateSeparator;
103106
final Color dateSeparatorText;
104107
final Color dmRecipientHeaderBg;
108+
final Color messageTimestamp;
105109
final Color recipientHeaderText;
106110
final Color senderBotIcon;
107111
final Color senderName;
@@ -116,6 +120,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
116120
Color? dateSeparator,
117121
Color? dateSeparatorText,
118122
Color? dmRecipientHeaderBg,
123+
Color? messageTimestamp,
119124
Color? recipientHeaderText,
120125
Color? senderBotIcon,
121126
Color? senderName,
@@ -129,6 +134,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
129134
dateSeparator: dateSeparator ?? this.dateSeparator,
130135
dateSeparatorText: dateSeparatorText ?? this.dateSeparatorText,
131136
dmRecipientHeaderBg: dmRecipientHeaderBg ?? this.dmRecipientHeaderBg,
137+
messageTimestamp: messageTimestamp ?? this.messageTimestamp,
132138
recipientHeaderText: recipientHeaderText ?? this.recipientHeaderText,
133139
senderBotIcon: senderBotIcon ?? this.senderBotIcon,
134140
senderName: senderName ?? this.senderName,
@@ -149,6 +155,7 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
149155
dateSeparator: Color.lerp(dateSeparator, other.dateSeparator, t)!,
150156
dateSeparatorText: Color.lerp(dateSeparatorText, other.dateSeparatorText, t)!,
151157
dmRecipientHeaderBg: Color.lerp(streamMessageBgDefault, other.dmRecipientHeaderBg, t)!,
158+
messageTimestamp: Color.lerp(messageTimestamp, other.messageTimestamp, t)!,
152159
recipientHeaderText: Color.lerp(recipientHeaderText, other.recipientHeaderText, t)!,
153160
senderBotIcon: Color.lerp(senderBotIcon, other.senderBotIcon, t)!,
154161
senderName: Color.lerp(senderName, other.senderName, t)!,
@@ -1148,7 +1155,7 @@ class MessageWithPossibleSender extends StatelessWidget {
11481155
const SizedBox(width: 4),
11491156
Text(time,
11501157
style: TextStyle(
1151-
color: _kMessageTimestampColor,
1158+
color: messageListTheme.messageTimestamp,
11521159
fontFamily: 'Source Sans 3',
11531160
fontSize: 16,
11541161
height: (18 / 16),
@@ -1187,5 +1194,3 @@ class MessageWithPossibleSender extends StatelessWidget {
11871194

11881195
// TODO web seems to ignore locale in formatting time, but we could do better
11891196
final _kMessageTimestampFormat = DateFormat('h:mm aa', 'en_US');
1190-
1191-
final _kMessageTimestampColor = const HSLColor.fromAHSL(0.8, 0, 0, 0.2).toColor();

0 commit comments

Comments
 (0)