Skip to content

Commit

Permalink
action_sheet test [nfc]: Have showFromAppBar take messages, not `me…
Browse files Browse the repository at this point in the history
…ssage`

When we add the resolve/unresolve button, coming up, we'll use this
to test the edge case where the button isn't shown in the
message-list app bar if the message list is empty. (For that case
we'll just pass an empty Iterable for this.)
  • Loading branch information
chrisbobbe authored and Gaurav-Kushwaha-1225 committed Jan 28, 2025
1 parent faed229 commit ab883d1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
53 changes: 23 additions & 30 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ import 'theme.dart';
/// Message-list styles that differ between light and dark themes.
class MessageListTheme extends ThemeExtension<MessageListTheme> {
static final light = MessageListTheme._(
dateSeparator: Colors.black,
dateSeparatorText: const HSLColor.fromAHSL(0.75, 0, 0, 0.15).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),
dateSeparator: Colors.black,
labelTime: const HSLColor.fromAHSL(0.49, 0, 0, 0).toColor(),
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.35, 0.93).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),

// From the Figma mockup at:
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=132-9684
Expand All @@ -53,15 +52,14 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
);

static final dark = MessageListTheme._(
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(),
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(),
streamRecipientHeaderChevronRight: Colors.white.withValues(alpha: 0.3),
dateSeparator: Colors.white,
labelTime: const HSLColor.fromAHSL(0.5, 0, 0, 1).toColor(),
dmRecipientHeaderBg: const HSLColor.fromAHSL(1, 46, 0.15, 0.2).toColor(),
recipientHeaderText: const HSLColor.fromAHSL(0.9, 0, 0, 1).toColor(),
senderBotIcon: const HSLColor.fromAHSL(1, 180, 0.05, 0.5).toColor(),
senderName: const HSLColor.fromAHSL(0.9, 0, 0, 1).toColor(),
streamMessageBgDefault: const HSLColor.fromAHSL(1, 0, 0, 0.15).toColor(),
streamRecipientHeaderChevronRight: Colors.white.withValues(alpha: 0.3),

// 0.75 opacity from here:
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=807-33998&m=dev
Expand All @@ -78,9 +76,8 @@ 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,
Expand All @@ -102,9 +99,8 @@ 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;
Expand All @@ -117,9 +113,8 @@ class MessageListTheme extends ThemeExtension<MessageListTheme> {
@override
MessageListTheme copyWith({
Color? dateSeparator,
Color? dateSeparatorText,
Color? labelTime,
Color? dmRecipientHeaderBg,
Color? messageTimestamp,
Color? recipientHeaderText,
Color? senderBotIcon,
Color? senderName,
Expand All @@ -131,9 +126,8 @@ 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,
Expand All @@ -152,9 +146,8 @@ 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)!,
Expand Down Expand Up @@ -1224,7 +1217,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 @@ -1331,7 +1324,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: 6 additions & 5 deletions test/widgets/action_sheet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,14 @@ void main() {
Future<void> showFromAppBar(WidgetTester tester, {
ZulipStream? channel,
String topic = someTopic,
StreamMessage? message,
List<StreamMessage>? messages,
}) async {
final effectiveChannel = channel ?? someChannel;
final effectiveMessage = message ?? someMessage;
assert(effectiveMessage.topic.apiName == topic);
final effectiveMessages = messages ?? [someMessage];
assert(effectiveMessages.every((m) => m.topic.apiName == topic));

connection.prepare(json: eg.newestGetMessagesResult(
foundOldest: true, messages: [effectiveMessage]).toJson());
foundOldest: true, messages: effectiveMessages).toJson());
await tester.pumpWidget(TestZulipApp(accountId: eg.selfAccount.id,
child: MessageListPage(
initNarrow: eg.topicNarrow(effectiveChannel.streamId, topic))));
Expand Down Expand Up @@ -284,7 +284,8 @@ void main() {

final message = eg.streamMessage(
stream: someChannel, topic: topic, sender: eg.otherUser);
await showFromAppBar(tester, channel: someChannel, topic: topic, message: message);
await showFromAppBar(tester,
channel: someChannel, topic: topic, messages: [message]);
}

void checkButtons(List<Finder> expectedButtonFinders) {
Expand Down

0 comments on commit ab883d1

Please sign in to comment.