Skip to content

ui: Stop using deprecated ColorScheme.background and ColorScheme.surfaceVariant #527

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

Merged
merged 7 commits into from
Feb 21, 2024
16 changes: 9 additions & 7 deletions lib/widgets/app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,15 @@ class ZulipApp extends StatelessWidget {
final theme = ThemeData(
typography: zulipTypography(context),
appBarTheme: const AppBarTheme(
// This prevents an elevation change in [AppBar]s so they stop turning
// darker if there is something scrolled underneath it. See docs:
// https://api.flutter.dev/flutter/material/AppBar/elevation.html
// Set these two fields to prevent a color change in [AppBar]s when
// there is something scrolled under it. If an app bar hasn't been
// given a backgroundColor directly or by theme, it uses
// ColorScheme.surfaceContainer for the scrolled-under state and
// ColorScheme.surface otherwise, and those are different colors.
scrolledUnderElevation: 0,
backgroundColor: Color(0xfff5f5f5),

shape: Border(bottom: BorderSide(color: Color(0xffcccccc))),
),
// This applies Material 3's color system to produce a palette of
// appropriately matching and contrasting colors for use in a UI.
Expand All @@ -99,11 +104,8 @@ class ZulipApp extends StatelessWidget {
// https://m3.material.io/theme-builder#/custom
colorScheme: ColorScheme.fromSeed(
seedColor: kZulipBrandColor,

// Used in the Figma for surfaces underneath scrollable content, e.g.:
// <https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=341%3A12362&mode=dev>
background: const Color(0xfff6f6f6),
),
scaffoldBackgroundColor: const Color(0xfff6f6f6),
// `preferBelow: false` seems like a better default for mobile;
// the area below a long-press target seems more likely to be hidden by
// a finger or thumb than the area above.
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/compose_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ class _ComposeBoxLayout extends StatelessWidget {
);

return Material(
color: colorScheme.surfaceVariant,
color: colorScheme.surfaceContainerHighest,
child: SafeArea(
minimum: const EdgeInsets.fromLTRB(8, 0, 8, 8),
child: Padding(
Expand Down
28 changes: 21 additions & 7 deletions lib/widgets/message_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class MessageListPage extends StatefulWidget {
State<MessageListPage> createState() => _MessageListPageState();
}

const _kFallbackStreamColor = Color(0xfff5f5f5);
// TODO(design) this seems ad-hoc; is there a better color?
const _kUnsubscribedStreamRecipientHeaderColor = Color(0xfff5f5f5);

class _MessageListPageState extends State<MessageListPage> {
final GlobalKey<ComposeBoxController> _composeBoxKey = GlobalKey();
Expand All @@ -56,21 +57,34 @@ class _MessageListPageState extends State<MessageListPage> {
Widget build(BuildContext context) {
final store = PerAccountStoreWidget.of(context);

final Color backgroundColor;
final Color? backgroundColor;
bool removeAppBarBottomBorder = false;
switch(widget.narrow) {
case AllMessagesNarrow():
backgroundColor = _kFallbackStreamColor;
backgroundColor = null; // i.e., inherit

case StreamNarrow(:final streamId):
case TopicNarrow(:final streamId):
backgroundColor = store.subscriptions[streamId]?.colorSwatch().barBackground
?? _kFallbackStreamColor;
?? _kUnsubscribedStreamRecipientHeaderColor;
// All recipient headers will match this color; remove distracting line
// (but are recipient headers even needed for topic narrows?)
removeAppBarBottomBorder = true;

case DmNarrow():
backgroundColor = _kFallbackStreamColor;
backgroundColor = _kDmRecipientHeaderColor;
Comment on lines -68 to +75
Copy link
Member

Choose a reason for hiding this comment

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

Ah good catch, thanks. I definitely see the difference in the DM narrow's app bar in the screenshots, and this looks better.

// All recipient headers will match this color; remove distracting line
// (but are recipient headers even needed?)
removeAppBarBottomBorder = true;
}

return Scaffold(
appBar: AppBar(title: MessageListAppBarTitle(narrow: widget.narrow),
backgroundColor: backgroundColor),
backgroundColor: backgroundColor,
shape: removeAppBarBottomBorder
? const Border()
: null, // i.e., inherit
),
// TODO question for Vlad: for a stream view, should we set
// [backgroundColor] based on stream color, as in this frame:
// https://www.figma.com/file/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=132%3A9684&mode=dev
Expand Down Expand Up @@ -640,7 +654,7 @@ class StreamMessageRecipientHeader extends StatelessWidget {
: Colors.black;
iconColor = swatch.iconOnBarBackground;
} else {
backgroundColor = _kFallbackStreamColor;
backgroundColor = _kUnsubscribedStreamRecipientHeaderColor;
contrastingColor = Colors.black;
iconColor = Colors.black;
}
Expand Down