Skip to content

Commit c9cae02

Browse files
committed
settings: Add easy settings page using (adaptive) Material widgets
This will use generic Material-style controls on Android, and generic iOS-style controls on iOS. This does not aim to fully implement the draft design for the settings page. We offer it mainly to test settings, so the implementation is kept as simple as possible. Draft design for reference: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=446-21372&t=BZKpTQPSiBDNxwvB-0 Fixes: #1216 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 99d1bbe commit c9cae02

17 files changed

+350
-11
lines changed

assets/icons/ZulipIcons.ttf

868 Bytes
Binary file not shown.

assets/icons/settings.svg

Lines changed: 4 additions & 0 deletions
Loading

assets/l10n/app_en.arb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
"@chooseAccountPageTitle": {
2020
"description": "Title for the page to choose between Zulip accounts."
2121
},
22+
"settingsPageTitle": "Settings",
23+
"@settingsPageTitle": {
24+
"description": "Title for the settings page."
25+
},
2226
"switchAccountButton": "Switch account",
2327
"@switchAccountButton": {
2428
"description": "Label for main-menu button leading to the choose-account page."
@@ -791,6 +795,22 @@
791795
"voterNames": {"type": "String", "example": "Alice, Bob, Chad"}
792796
}
793797
},
798+
"themeSettingTitle": "THEME",
799+
"@themeSettingTitle": {
800+
"description": "Title for theme setting. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)"
801+
},
802+
"themeSettingDark": "Dark",
803+
"@themeSettingDark": {
804+
"description": "Label for dark theme setting."
805+
},
806+
"themeSettingLight": "Light",
807+
"@themeSettingLight": {
808+
"description": "Label for light theme setting."
809+
},
810+
"themeSettingSystem": "System",
811+
"@themeSettingSystem": {
812+
"description": "Label for system theme setting."
813+
},
794814
"pollWidgetQuestionMissing": "No question.",
795815
"@pollWidgetQuestionMissing": {
796816
"description": "Text to display for a poll when the question is missing"

lib/generated/l10n/zulip_localizations.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ abstract class ZulipLocalizations {
135135
/// **'Choose account'**
136136
String get chooseAccountPageTitle;
137137

138+
/// Title for the settings page.
139+
///
140+
/// In en, this message translates to:
141+
/// **'Settings'**
142+
String get settingsPageTitle;
143+
138144
/// Label for main-menu button leading to the choose-account page.
139145
///
140146
/// In en, this message translates to:
@@ -1155,6 +1161,30 @@ abstract class ZulipLocalizations {
11551161
/// **'({voterNames})'**
11561162
String pollVoterNames(String voterNames);
11571163

1164+
/// Title for theme setting. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)
1165+
///
1166+
/// In en, this message translates to:
1167+
/// **'THEME'**
1168+
String get themeSettingTitle;
1169+
1170+
/// Label for dark theme setting.
1171+
///
1172+
/// In en, this message translates to:
1173+
/// **'Dark'**
1174+
String get themeSettingDark;
1175+
1176+
/// Label for light theme setting.
1177+
///
1178+
/// In en, this message translates to:
1179+
/// **'Light'**
1180+
String get themeSettingLight;
1181+
1182+
/// Label for system theme setting.
1183+
///
1184+
/// In en, this message translates to:
1185+
/// **'System'**
1186+
String get themeSettingSystem;
1187+
11581188
/// Text to display for a poll when the question is missing
11591189
///
11601190
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
2323
@override
2424
String get chooseAccountPageTitle => 'Choose account';
2525

26+
@override
27+
String get settingsPageTitle => 'Settings';
28+
2629
@override
2730
String get switchAccountButton => 'Switch account';
2831

@@ -619,6 +622,18 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
619622
return '($voterNames)';
620623
}
621624

625+
@override
626+
String get themeSettingTitle => 'THEME';
627+
628+
@override
629+
String get themeSettingDark => 'Dark';
630+
631+
@override
632+
String get themeSettingLight => 'Light';
633+
634+
@override
635+
String get themeSettingSystem => 'System';
636+
622637
@override
623638
String get pollWidgetQuestionMissing => 'No question.';
624639

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
2323
@override
2424
String get chooseAccountPageTitle => 'Choose account';
2525

26+
@override
27+
String get settingsPageTitle => 'Settings';
28+
2629
@override
2730
String get switchAccountButton => 'Switch account';
2831

@@ -619,6 +622,18 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
619622
return '($voterNames)';
620623
}
621624

625+
@override
626+
String get themeSettingTitle => 'THEME';
627+
628+
@override
629+
String get themeSettingDark => 'Dark';
630+
631+
@override
632+
String get themeSettingLight => 'Light';
633+
634+
@override
635+
String get themeSettingSystem => 'System';
636+
622637
@override
623638
String get pollWidgetQuestionMissing => 'No question.';
624639

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
2323
@override
2424
String get chooseAccountPageTitle => 'アカウントを選択';
2525

26+
@override
27+
String get settingsPageTitle => 'Settings';
28+
2629
@override
2730
String get switchAccountButton => 'Switch account';
2831

@@ -619,6 +622,18 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
619622
return '($voterNames)';
620623
}
621624

625+
@override
626+
String get themeSettingTitle => 'THEME';
627+
628+
@override
629+
String get themeSettingDark => 'Dark';
630+
631+
@override
632+
String get themeSettingLight => 'Light';
633+
634+
@override
635+
String get themeSettingSystem => 'System';
636+
622637
@override
623638
String get pollWidgetQuestionMissing => 'No question.';
624639

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
2323
@override
2424
String get chooseAccountPageTitle => 'Choose account';
2525

26+
@override
27+
String get settingsPageTitle => 'Settings';
28+
2629
@override
2730
String get switchAccountButton => 'Switch account';
2831

@@ -619,6 +622,18 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
619622
return '($voterNames)';
620623
}
621624

625+
@override
626+
String get themeSettingTitle => 'THEME';
627+
628+
@override
629+
String get themeSettingDark => 'Dark';
630+
631+
@override
632+
String get themeSettingLight => 'Light';
633+
634+
@override
635+
String get themeSettingSystem => 'System';
636+
622637
@override
623638
String get pollWidgetQuestionMissing => 'No question.';
624639

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
2323
@override
2424
String get chooseAccountPageTitle => 'Wybierz konto';
2525

26+
@override
27+
String get settingsPageTitle => 'Settings';
28+
2629
@override
2730
String get switchAccountButton => 'Przełącz konto';
2831

@@ -619,6 +622,18 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
619622
return '($voterNames)';
620623
}
621624

625+
@override
626+
String get themeSettingTitle => 'THEME';
627+
628+
@override
629+
String get themeSettingDark => 'Dark';
630+
631+
@override
632+
String get themeSettingLight => 'Light';
633+
634+
@override
635+
String get themeSettingSystem => 'System';
636+
622637
@override
623638
String get pollWidgetQuestionMissing => 'Brak pytania.';
624639

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
2323
@override
2424
String get chooseAccountPageTitle => 'Выберите учетную запись';
2525

26+
@override
27+
String get settingsPageTitle => 'Settings';
28+
2629
@override
2730
String get switchAccountButton => 'Сменить учетную запись';
2831

@@ -619,6 +622,18 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
619622
return '($voterNames)';
620623
}
621624

625+
@override
626+
String get themeSettingTitle => 'THEME';
627+
628+
@override
629+
String get themeSettingDark => 'Dark';
630+
631+
@override
632+
String get themeSettingLight => 'Light';
633+
634+
@override
635+
String get themeSettingSystem => 'System';
636+
622637
@override
623638
String get pollWidgetQuestionMissing => 'Нет вопроса.';
624639

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
2323
@override
2424
String get chooseAccountPageTitle => 'Zvoliť účet';
2525

26+
@override
27+
String get settingsPageTitle => 'Settings';
28+
2629
@override
2730
String get switchAccountButton => 'Zmeniť účet';
2831

@@ -619,6 +622,18 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
619622
return '($voterNames)';
620623
}
621624

625+
@override
626+
String get themeSettingTitle => 'THEME';
627+
628+
@override
629+
String get themeSettingDark => 'Dark';
630+
631+
@override
632+
String get themeSettingLight => 'Light';
633+
634+
@override
635+
String get themeSettingSystem => 'System';
636+
622637
@override
623638
String get pollWidgetQuestionMissing => 'Bez otázky.';
624639

lib/model/settings.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import '../generated/l10n/zulip_localizations.dart';
2+
13
/// The user's choice of visual theme for the app.
24
///
35
/// See [zulipThemeData] for how themes are determined.
@@ -9,5 +11,16 @@ enum ThemeSetting {
911
light,
1012

1113
/// Corresponds to [Brightness.dark].
12-
dark,
14+
dark;
15+
16+
static String displayName({
17+
required ThemeSetting? themeSetting,
18+
required ZulipLocalizations zulipLocalizations,
19+
}) {
20+
return switch (themeSetting) {
21+
null => zulipLocalizations.themeSettingSystem,
22+
ThemeSetting.light => zulipLocalizations.themeSettingLight,
23+
ThemeSetting.dark => zulipLocalizations.themeSettingDark,
24+
};
25+
}
1326
}

lib/widgets/home.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'message_list.dart';
1717
import 'page.dart';
1818
import 'profile.dart';
1919
import 'recent_dm_conversations.dart';
20+
import 'settings.dart';
2021
import 'store.dart';
2122
import 'subscription_list.dart';
2223
import 'text.dart';
@@ -280,7 +281,7 @@ void _showMainMenu(BuildContext context, {
280281
const _SwitchAccountButton(),
281282
// TODO(#198): Set my status
282283
// const SizedBox(height: 8),
283-
// TODO(#97): Settings
284+
const _SettingsButton(),
284285
// TODO(#661): Notifications
285286
// const SizedBox(height: 8),
286287
const _AboutZulipButton(),
@@ -567,6 +568,23 @@ class _SwitchAccountButton extends _MenuButton {
567568
}
568569
}
569570

571+
class _SettingsButton extends _MenuButton {
572+
const _SettingsButton();
573+
574+
@override
575+
IconData get icon => ZulipIcons.settings;
576+
577+
@override
578+
String label(ZulipLocalizations zulipLocalizations) {
579+
return zulipLocalizations.settingsPageTitle;
580+
}
581+
582+
@override
583+
void onPressed(BuildContext context) {
584+
Navigator.of(context).push(SettingsPage.buildRoute(context: context));
585+
}
586+
}
587+
570588
class _AboutZulipButton extends _MenuButton {
571589
const _AboutZulipButton();
572590

0 commit comments

Comments
 (0)