Skip to content

Commit dd97594

Browse files
committed
theme [nfc]: Pull outerThemeData out from app.dart to new theme.dart file
1 parent bb5e0e9 commit dd97594

File tree

4 files changed

+43
-36
lines changed

4 files changed

+43
-36
lines changed

lib/notifications/display.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import '../widgets/app.dart';
1616
import '../widgets/message_list.dart';
1717
import '../widgets/page.dart';
1818
import '../widgets/store.dart';
19+
import '../widgets/theme.dart';
1920

2021
/// Service for configuring our Android "notification channel".
2122
class NotificationChannelManager {

lib/widgets/app.dart

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import 'page.dart';
1515
import 'recent_dm_conversations.dart';
1616
import 'store.dart';
1717
import 'subscription_list.dart';
18-
import 'text.dart';
18+
import 'theme.dart';
1919

2020
class ZulipApp extends StatefulWidget {
2121
const ZulipApp({super.key, this.navigatorObservers});
@@ -109,34 +109,6 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
109109

110110
@override
111111
Widget build(BuildContext context) {
112-
final theme = ThemeData(
113-
typography: zulipTypography(context),
114-
appBarTheme: const AppBarTheme(
115-
// Set these two fields to prevent a color change in [AppBar]s when
116-
// there is something scrolled under it. If an app bar hasn't been
117-
// given a backgroundColor directly or by theme, it uses
118-
// ColorScheme.surfaceContainer for the scrolled-under state and
119-
// ColorScheme.surface otherwise, and those are different colors.
120-
scrolledUnderElevation: 0,
121-
backgroundColor: Color(0xfff5f5f5),
122-
123-
shape: Border(bottom: BorderSide(color: Color(0xffcccccc))),
124-
),
125-
// This applies Material 3's color system to produce a palette of
126-
// appropriately matching and contrasting colors for use in a UI.
127-
// The Zulip brand color is a starting point, but doesn't end up as
128-
// one that's directly used. (After all, we didn't design it for that
129-
// purpose; we designed a logo.) See docs:
130-
// https://api.flutter.dev/flutter/material/ColorScheme/ColorScheme.fromSeed.html
131-
// Or try this tool to see the whole palette:
132-
// https://m3.material.io/theme-builder#/custom
133-
colorScheme: ColorScheme.fromSeed(
134-
seedColor: kZulipBrandColor,
135-
),
136-
scaffoldBackgroundColor: const Color(0xfff6f6f6),
137-
tooltipTheme: const TooltipThemeData(preferBelow: false),
138-
);
139-
140112
return GlobalStoreWidget(
141113
child: Builder(builder: (context) {
142114
final globalStore = GlobalStoreWidget.of(context);
@@ -146,7 +118,7 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
146118
title: 'Zulip',
147119
localizationsDelegates: ZulipLocalizations.localizationsDelegates,
148120
supportedLocales: ZulipLocalizations.supportedLocales,
149-
theme: theme,
121+
theme: outerThemeData(context),
150122

151123
navigatorKey: ZulipApp.navigatorKey,
152124
navigatorObservers: widget.navigatorObservers ?? const [],
@@ -181,12 +153,6 @@ class _ZulipAppState extends State<ZulipApp> with WidgetsBindingObserver {
181153
}
182154
}
183155

184-
/// The Zulip "brand color", a purplish blue.
185-
///
186-
/// This is chosen as the sRGB midpoint of the Zulip logo's gradient.
187-
// As computed by Anders: https://github.com/zulip/zulip-mobile/pull/4467
188-
const kZulipBrandColor = Color.fromRGBO(0x64, 0x92, 0xfe, 1);
189-
190156
class ChooseAccountPage extends StatelessWidget {
191157
const ChooseAccountPage({super.key});
192158

lib/widgets/theme.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import 'package:flutter/material.dart';
2+
3+
import 'text.dart';
4+
5+
ThemeData outerThemeData(BuildContext context) {
6+
return ThemeData(
7+
typography: zulipTypography(context),
8+
appBarTheme: const AppBarTheme(
9+
// Set these two fields to prevent a color change in [AppBar]s when
10+
// there is something scrolled under it. If an app bar hasn't been
11+
// given a backgroundColor directly or by theme, it uses
12+
// ColorScheme.surfaceContainer for the scrolled-under state and
13+
// ColorScheme.surface otherwise, and those are different colors.
14+
scrolledUnderElevation: 0,
15+
backgroundColor: Color(0xfff5f5f5),
16+
17+
shape: Border(bottom: BorderSide(color: Color(0xffcccccc))),
18+
),
19+
// This applies Material 3's color system to produce a palette of
20+
// appropriately matching and contrasting colors for use in a UI.
21+
// The Zulip brand color is a starting point, but doesn't end up as
22+
// one that's directly used. (After all, we didn't design it for that
23+
// purpose; we designed a logo.) See docs:
24+
// https://api.flutter.dev/flutter/material/ColorScheme/ColorScheme.fromSeed.html
25+
// Or try this tool to see the whole palette:
26+
// https://m3.material.io/theme-builder#/custom
27+
colorScheme: ColorScheme.fromSeed(
28+
seedColor: kZulipBrandColor,
29+
),
30+
scaffoldBackgroundColor: const Color(0xfff6f6f6),
31+
tooltipTheme: const TooltipThemeData(preferBelow: false),
32+
);
33+
}
34+
35+
/// The Zulip "brand color", a purplish blue.
36+
///
37+
/// This is chosen as the sRGB midpoint of the Zulip logo's gradient.
38+
// As computed by Anders: https://github.com/zulip/zulip-mobile/pull/4467
39+
const kZulipBrandColor = Color.fromRGBO(0x64, 0x92, 0xfe, 1);

test/notifications/display_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import 'package:zulip/widgets/app.dart';
1818
import 'package:zulip/widgets/inbox.dart';
1919
import 'package:zulip/widgets/message_list.dart';
2020
import 'package:zulip/widgets/page.dart';
21+
import 'package:zulip/widgets/theme.dart';
2122

2223
import '../fake_async.dart';
2324
import '../model/binding.dart';

0 commit comments

Comments
 (0)