Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak dark theme #1213

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 19 additions & 39 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
MessageListTheme.light() :
Gaurav-Kushwaha-1225 marked this conversation as resolved.
Show resolved Hide resolved
this._(
dateSeparator: Colors.black,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme[nfc]: Remove senderName & recipientHeaderText 

commit message nit: similarly, mentioning title in the commit summary is helpful

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get why you are saying to add title in this commit message.

theme: Replace `dateSeparatorText` and `messageTimestamp` with `labelTime`

This commit message as you have mentioned above is fine for this commit.
Please correct me if I didn't understand properly at any place.

dateSeparatorText: const HSLColor.fromAHSL(0.75, 0, 0, 0.15).toColor(),
labelTime: const HSLColor.fromAHSL(0.49, 0, 0, 0).toColor(),
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
messageTimestamp: const HSLColor.fromAHSL(0.8, 0, 0, 0.2).toColor(),
recipientHeaderText: const HSLColor.fromAHSL(1, 0, 0, 0.15).toColor(),
senderBotIcon: const HSLColor.fromAHSL(1, 180, 0.08, 0.65).toColor(),
senderName: const HSLColor.fromAHSL(1, 0, 0, 0.2).toColor(),
streamMessageBgDefault: Colors.white,
streamRecipientHeaderChevronRight: Colors.black.withValues(alpha: 0.3),

Expand All @@ -55,14 +52,11 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

theme: Adjust foreground & dateSeparator colors

Adjusted the colors for `foreground` in
`DesignVariables` and `dateSeparator` in `MessageListTheme`
as asked.

This commit is adjusting more colors than the commit message is suggesting. Some of them is probably irrelevant because we refactored them away later, right? It will be cleaner to make this the final commit in the sequence.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I edit the commit message too after reordering the commits, like the below one;

theme: Adjust foreground & dateSeparator colors

Adjusted the colors for `foreground` in
`DesignVariables` and `dateSeparator` in `MessageListTheme`
as asked. 
Updated `dateSeparator` and `dmRecipientHeaderBg` values acc. to   
their values in figma file.
`foreground`: https://github.com/zulip/zulip-flutter/pull/1213#discussion_r1908368175
`dateSeparator`: https://github.com/zulip/zulip-flutter/pull/1213#discussion_r1908328416

MessageListTheme.dark() :
this._(
dateSeparator: Colors.white,
dateSeparatorText: const HSLColor.fromAHSL(0.75, 0, 0, 1).toColor(),
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
messageTimestamp: const HSLColor.fromAHSL(0.8, 0, 0, 0.85).toColor(),
recipientHeaderText: const HSLColor.fromAHSL(0.8, 0, 0, 1).toColor(),
dateSeparator: Colors.white.withValues(alpha: 51),
labelTime: const HSLColor.fromAHSL(0.5, 0, 0, 1).toColor(),
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 0, 0, 0.14).toColor(),
Copy link
Member

@PIG208 PIG208 Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you identify where this color (dmRecipientHeaderBg) comes from? I looked at https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3702-28206&p=f&t=dBCq6jmgNML8Joly-0 but couldn't find it.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This dmRecipientHeaderBg is the light-colored top bar in below screen.
  • Though, it is represented using bg-top-bar in the figma design file with value HSLColor.fromAHSL(1, 0, 0, 0.14).toColor().

senderBotIcon: const HSLColor.fromAHSL(1, 180, 0.05, 0.5).toColor(),
senderName: const HSLColor.fromAHSL(0.85, 0, 0, 1).toColor(),
streamMessageBgDefault: const HSLColor.fromAHSL(1, 0, 0, 0.15).toColor(),
streamMessageBgDefault: const HSLColor.fromAHSL(1, 0, 0, 0.11).toColor(),
streamRecipientHeaderChevronRight: Colors.white.withValues(alpha: 0.3),

// 0.75 opacity from here:
Expand All @@ -80,12 +74,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {

MessageListTheme._({
required this.dateSeparator,
required this.dateSeparatorText,
required this.labelTime,
required this.dmRecipientHeaderBg,
required this.messageTimestamp,
required this.recipientHeaderText,
required this.senderBotIcon,
required this.senderName,
required this.streamMessageBgDefault,
required this.streamRecipientHeaderChevronRight,
required this.unreadMarker,
Expand All @@ -104,12 +95,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
}

final Color dateSeparator;
final Color dateSeparatorText;
final Color labelTime;
final Color dmRecipientHeaderBg;
final Color messageTimestamp;
final Color recipientHeaderText;
final Color senderBotIcon;
final Color senderName;
final Color streamMessageBgDefault;
final Color streamRecipientHeaderChevronRight;
final Color unreadMarker;
Expand All @@ -119,12 +107,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
@override
MessageListTheme copyWith({
Color? dateSeparator,
Color? dateSeparatorText,
Color? labelTime,
Color? dmRecipientHeaderBg,
Color? messageTimestamp,
Color? recipientHeaderText,
Color? senderBotIcon,
Color? senderName,
Color? streamMessageBgDefault,
Color? streamRecipientHeaderChevronRight,
Color? unreadMarker,
Expand All @@ -133,12 +118,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
}) {
return MessageListTheme._(
dateSeparator: dateSeparator ?? this.dateSeparator,
dateSeparatorText: dateSeparatorText ?? this.dateSeparatorText,
labelTime: labelTime ?? this.labelTime,
dmRecipientHeaderBg: dmRecipientHeaderBg ?? this.dmRecipientHeaderBg,
messageTimestamp: messageTimestamp ?? this.messageTimestamp,
recipientHeaderText: recipientHeaderText ?? this.recipientHeaderText,
senderBotIcon: senderBotIcon ?? this.senderBotIcon,
senderName: senderName ?? this.senderName,
streamMessageBgDefault: streamMessageBgDefault ?? this.streamMessageBgDefault,
streamRecipientHeaderChevronRight: streamRecipientHeaderChevronRight ?? this.streamRecipientHeaderChevronRight,
unreadMarker: unreadMarker ?? this.unreadMarker,
Expand All @@ -154,12 +136,9 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
}
return MessageListTheme._(
dateSeparator: Color.lerp(dateSeparator, other.dateSeparator, t)!,
dateSeparatorText: Color.lerp(dateSeparatorText, other.dateSeparatorText, t)!,
labelTime: Color.lerp(labelTime, other.labelTime, t)!,
dmRecipientHeaderBg: Color.lerp(streamMessageBgDefault, other.dmRecipientHeaderBg, t)!,
messageTimestamp: Color.lerp(messageTimestamp, other.messageTimestamp, t)!,
recipientHeaderText: Color.lerp(recipientHeaderText, other.recipientHeaderText, t)!,
senderBotIcon: Color.lerp(senderBotIcon, other.senderBotIcon, t)!,
senderName: Color.lerp(senderName, other.senderName, t)!,
streamMessageBgDefault: Color.lerp(streamMessageBgDefault, other.streamMessageBgDefault, t)!,
streamRecipientHeaderChevronRight: Color.lerp(streamRecipientHeaderChevronRight, other.streamRecipientHeaderChevronRight, t)!,
unreadMarker: Color.lerp(unreadMarker, other.unreadMarker, t)!,
Expand Down Expand Up @@ -352,7 +331,7 @@ class MessageListAppBarTitle extends StatelessWidget {
padding: const EdgeInsetsDirectional.only(start: 4),
Gaurav-Kushwaha-1225 marked this conversation as resolved.
Show resolved Hide resolved
child: Icon(icon,
// TODO(design) copies the recipient header in web; is there a better color?
Gaurav-Kushwaha-1225 marked this conversation as resolved.
Show resolved Hide resolved
color: designVariables.colorMessageHeaderIconInteractive, size: 14)),
color: designVariables.title, size: 14)),
]);
}

Expand Down Expand Up @@ -1041,7 +1020,7 @@ class StreamMessageRecipientHeader extends StatelessWidget {
iconColor = swatch.iconOnBarBackground;
} else {
backgroundColor = messageListTheme.unsubscribedStreamRecipientHeaderBg;
iconColor = messageListTheme.recipientHeaderText;
iconColor = designVariables.title;
}

final Widget streamWidget;
Expand Down Expand Up @@ -1098,7 +1077,7 @@ class StreamMessageRecipientHeader extends StatelessWidget {
style: recipientHeaderTextStyle(context))),
const SizedBox(width: 4),
// TODO(design) copies the recipient header in web; is there a better color?
Gaurav-Kushwaha-1225 marked this conversation as resolved.
Show resolved Hide resolved
Icon(size: 14, color: designVariables.colorMessageHeaderIconInteractive,
Icon(size: 14, color: designVariables.title,
// A null [Icon.icon] makes a blank space.
iconDataForTopicVisibilityPolicy(
store.topicVisibilityPolicy(message.streamId, topic))),
Expand Down Expand Up @@ -1147,6 +1126,7 @@ class DmRecipientHeader extends StatelessWidget {
}

final messageListTheme = MessageListTheme.of(context);
final designVariables = DesignVariables.of(context);

return GestureDetector(
onTap: () => Navigator.push(context,
Expand All @@ -1162,7 +1142,7 @@ class DmRecipientHeader extends StatelessWidget {
Padding(
padding: const EdgeInsets.symmetric(horizontal: 6),
child: Icon(
color: messageListTheme.recipientHeaderText,
color: designVariables.title,
size: 16,
ZulipIcons.user)),
Expanded(
Expand All @@ -1176,7 +1156,7 @@ class DmRecipientHeader extends StatelessWidget {

TextStyle recipientHeaderTextStyle(BuildContext context) {
return TextStyle(
color: MessageListTheme.of(context).recipientHeaderText,
color: DesignVariables.of(context).title,
fontSize: 16,
letterSpacing: proportionalLetterSpacing(context, 0.02, baseFontSize: 16),
height: (18 / 16),
Expand Down Expand Up @@ -1220,7 +1200,7 @@ class DateText extends StatelessWidget {
final zulipLocalizations = ZulipLocalizations.of(context);
return Text(
style: TextStyle(
color: messageListTheme.dateSeparatorText,
color: messageListTheme.labelTime,
fontSize: fontSize,
height: height,
// This is equivalent to css `all-small-caps`, see:
Expand Down Expand Up @@ -1312,7 +1292,7 @@ class MessageWithPossibleSender extends StatelessWidget {
style: TextStyle(
fontSize: 18,
height: (22 / 18),
color: messageListTheme.senderName,
color: designVariables.title,
).merge(weightVariableTextStyle(context, wght: 600)),
overflow: TextOverflow.ellipsis)),
if (sender?.isBot ?? false) ...[
Expand All @@ -1327,7 +1307,7 @@ class MessageWithPossibleSender extends StatelessWidget {
const SizedBox(width: 4),
Text(time,
style: TextStyle(
color: messageListTheme.messageTimestamp,
color: messageListTheme.labelTime,
fontSize: 16,
height: (18 / 16),
fontFeatures: const [FontFeature.enable('c2sc'), FontFeature.enable('smcp')],
Expand Down
11 changes: 2 additions & 9 deletions lib/widgets/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
bgSearchInput: const Color(0xffe3e3e3),
textMessage: const Color(0xff262626),
channelColorSwatches: ChannelColorSwatches.light,
colorMessageHeaderIconInteractive: Colors.black.withValues(alpha: 0.2),
Gaurav-Kushwaha-1225 marked this conversation as resolved.
Show resolved Hide resolved
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15),
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20),
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).toColor(),
Expand Down Expand Up @@ -192,14 +191,13 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
labelMenuButton: const Color(0xffffffff).withValues(alpha: 0.85),
mainBackground: const Color(0xff1d1d1d),
textInput: const Color(0xffffffff).withValues(alpha: 0.9),
title: const Color(0xffffffff),
Gaurav-Kushwaha-1225 marked this conversation as resolved.
Show resolved Hide resolved
title: const Color(0xffffffff).withValues(alpha: 0.9),
bgSearchInput: const Color(0xff313131),
textMessage: const Color(0xffffffff).withValues(alpha: 0.8),
channelColorSwatches: ChannelColorSwatches.dark,
contextMenuCancelBg: const Color(0xff797986).withValues(alpha: 0.15), // the same as the light mode in Figma
contextMenuCancelPressedBg: const Color(0xff797986).withValues(alpha: 0.20), // the same as the light mode in Figma
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
colorMessageHeaderIconInteractive: Colors.white.withValues(alpha: 0.2),
dmHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
groupDmConversationIcon: Colors.white.withValues(alpha: 0.5),
Expand Down Expand Up @@ -253,7 +251,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
required this.bgSearchInput,
required this.textMessage,
required this.channelColorSwatches,
required this.colorMessageHeaderIconInteractive,
required this.contextMenuCancelBg,
required this.contextMenuCancelPressedBg,
required this.dmHeaderBg,
Expand Down Expand Up @@ -315,7 +312,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
final ChannelColorSwatches channelColorSwatches;

// Not named variables in Figma; taken from older Figma drafts, or elsewhere.
final Color colorMessageHeaderIconInteractive;
final Color contextMenuCancelBg; // In Figma, but unnamed.
final Color contextMenuCancelPressedBg; // In Figma, but unnamed.
final Color dmHeaderBg;
Expand Down Expand Up @@ -364,7 +360,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
Color? bgSearchInput,
Color? textMessage,
ChannelColorSwatches? channelColorSwatches,
Color? colorMessageHeaderIconInteractive,
Color? contextMenuCancelBg,
Color? contextMenuCancelPressedBg,
Color? dmHeaderBg,
Expand Down Expand Up @@ -412,7 +407,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
bgSearchInput: bgSearchInput ?? this.bgSearchInput,
textMessage: textMessage ?? this.textMessage,
channelColorSwatches: channelColorSwatches ?? this.channelColorSwatches,
colorMessageHeaderIconInteractive: colorMessageHeaderIconInteractive ?? this.colorMessageHeaderIconInteractive,
contextMenuCancelBg: contextMenuCancelBg ?? this.contextMenuCancelBg,
contextMenuCancelPressedBg: contextMenuCancelPressedBg ?? this.contextMenuCancelPressedBg,
dmHeaderBg: dmHeaderBg ?? this.dmHeaderBg,
Expand Down Expand Up @@ -467,7 +461,6 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
bgSearchInput: Color.lerp(bgSearchInput, other.bgSearchInput, t)!,
textMessage: Color.lerp(textMessage, other.textMessage, t)!,
channelColorSwatches: ChannelColorSwatches.lerp(channelColorSwatches, other.channelColorSwatches, t),
colorMessageHeaderIconInteractive: Color.lerp(colorMessageHeaderIconInteractive, other.colorMessageHeaderIconInteractive, t)!,
contextMenuCancelBg: Color.lerp(contextMenuCancelBg, other.contextMenuCancelBg, t)!,
contextMenuCancelPressedBg: Color.lerp(contextMenuCancelPressedBg, other.contextMenuCancelPressedBg, t)!,
dmHeaderBg: Color.lerp(dmHeaderBg, other.dmHeaderBg, t)!,
Expand All @@ -493,5 +486,5 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
/// For how this value is cached, see [ChannelColorSwatches.forBaseColor].
ChannelColorSwatch colorSwatchFor(BuildContext context, Subscription subscription) {
return DesignVariables.of(context)
.channelColorSwatches.forBaseColor(subscription.color);
.channelColorSwatches.forBaseColor(subscription.color);
Gaurav-Kushwaha-1225 marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions test/widgets/autocomplete_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ void main() {
text: 'some',
selection: TextSelection(baseOffset: 1, extentOffset: 3)));
await tester.pump();
// Add an extra pump to account for any potential frame delays introduced
// by the post frame callback in RawAutocomplete's implementation.
await tester.pump();

check(controller.value)
..text.equals('some')
..selection.equals(
Expand Down