Skip to content

Commit 197ac45

Browse files
committed
settings: Add settings page with vanilla Flutter widgets
This does not aim to fully implement the wip design for the settings page. We offer it mainly to test settings, so the implementation is kept as simple as possible. WIP design: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=446-21372&t=BZKpTQPSiBDNxwvB-0 Fixes: zulip#1216 Signed-off-by: Zixuan James Li <[email protected]>
1 parent c54b92a commit 197ac45

17 files changed

+355
-11
lines changed

assets/icons/ZulipIcons.ttf

864 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."
@@ -783,6 +787,22 @@
783787
"voterNames": {"type": "String", "example": "Alice, Bob, Chad"}
784788
}
785789
},
790+
"themeSettingTitle": "THEME",
791+
"@themeSettingTitle": {
792+
"description": "Title for theme setting. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)"
793+
},
794+
"themeSettingDark": "Dark",
795+
"@themeSettingDark": {
796+
"description": "Label for dark theme setting."
797+
},
798+
"themeSettingLight": "Light",
799+
"@themeSettingLight": {
800+
"description": "Label for light theme setting."
801+
},
802+
"themeSettingSystem": "System",
803+
"@themeSettingSystem": {
804+
"description": "Label for system theme setting."
805+
},
786806
"pollWidgetQuestionMissing": "No question.",
787807
"@pollWidgetQuestionMissing": {
788808
"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:
@@ -1143,6 +1149,30 @@ abstract class ZulipLocalizations {
11431149
/// **'({voterNames})'**
11441150
String pollVoterNames(String voterNames);
11451151

1152+
/// Title for theme setting. (Use ALL CAPS for cased alphabets: Latin, Greek, Cyrillic, etc.)
1153+
///
1154+
/// In en, this message translates to:
1155+
/// **'THEME'**
1156+
String get themeSettingTitle;
1157+
1158+
/// Label for dark theme setting.
1159+
///
1160+
/// In en, this message translates to:
1161+
/// **'Dark'**
1162+
String get themeSettingDark;
1163+
1164+
/// Label for light theme setting.
1165+
///
1166+
/// In en, this message translates to:
1167+
/// **'Light'**
1168+
String get themeSettingLight;
1169+
1170+
/// Label for system theme setting.
1171+
///
1172+
/// In en, this message translates to:
1173+
/// **'System'**
1174+
String get themeSettingSystem;
1175+
11461176
/// Text to display for a poll when the question is missing
11471177
///
11481178
/// 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

@@ -613,6 +616,18 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
613616
return '($voterNames)';
614617
}
615618

619+
@override
620+
String get themeSettingTitle => 'THEME';
621+
622+
@override
623+
String get themeSettingDark => 'Dark';
624+
625+
@override
626+
String get themeSettingLight => 'Light';
627+
628+
@override
629+
String get themeSettingSystem => 'System';
630+
616631
@override
617632
String get pollWidgetQuestionMissing => 'No question.';
618633

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

@@ -613,6 +616,18 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
613616
return '($voterNames)';
614617
}
615618

619+
@override
620+
String get themeSettingTitle => 'THEME';
621+
622+
@override
623+
String get themeSettingDark => 'Dark';
624+
625+
@override
626+
String get themeSettingLight => 'Light';
627+
628+
@override
629+
String get themeSettingSystem => 'System';
630+
616631
@override
617632
String get pollWidgetQuestionMissing => 'No question.';
618633

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

@@ -613,6 +616,18 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
613616
return '($voterNames)';
614617
}
615618

619+
@override
620+
String get themeSettingTitle => 'THEME';
621+
622+
@override
623+
String get themeSettingDark => 'Dark';
624+
625+
@override
626+
String get themeSettingLight => 'Light';
627+
628+
@override
629+
String get themeSettingSystem => 'System';
630+
616631
@override
617632
String get pollWidgetQuestionMissing => 'No question.';
618633

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

@@ -613,6 +616,18 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
613616
return '($voterNames)';
614617
}
615618

619+
@override
620+
String get themeSettingTitle => 'THEME';
621+
622+
@override
623+
String get themeSettingDark => 'Dark';
624+
625+
@override
626+
String get themeSettingLight => 'Light';
627+
628+
@override
629+
String get themeSettingSystem => 'System';
630+
616631
@override
617632
String get pollWidgetQuestionMissing => 'No question.';
618633

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

@@ -613,6 +616,18 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
613616
return '($voterNames)';
614617
}
615618

619+
@override
620+
String get themeSettingTitle => 'THEME';
621+
622+
@override
623+
String get themeSettingDark => 'Dark';
624+
625+
@override
626+
String get themeSettingLight => 'Light';
627+
628+
@override
629+
String get themeSettingSystem => 'System';
630+
616631
@override
617632
String get pollWidgetQuestionMissing => 'Brak pytania.';
618633

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

@@ -613,6 +616,18 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
613616
return '($voterNames)';
614617
}
615618

619+
@override
620+
String get themeSettingTitle => 'THEME';
621+
622+
@override
623+
String get themeSettingDark => 'Dark';
624+
625+
@override
626+
String get themeSettingLight => 'Light';
627+
628+
@override
629+
String get themeSettingSystem => 'System';
630+
616631
@override
617632
String get pollWidgetQuestionMissing => 'Нет вопроса.';
618633

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

@@ -613,6 +616,18 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
613616
return '($voterNames)';
614617
}
615618

619+
@override
620+
String get themeSettingTitle => 'THEME';
621+
622+
@override
623+
String get themeSettingDark => 'Dark';
624+
625+
@override
626+
String get themeSettingLight => 'Light';
627+
628+
@override
629+
String get themeSettingSystem => 'System';
630+
616631
@override
617632
String get pollWidgetQuestionMissing => 'Bez otázky.';
618633

lib/model/settings.dart

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import 'package:flutter/foundation.dart';
2+
3+
import '../generated/l10n/zulip_localizations.dart';
4+
15
/// The user's choice of visual theme for the app
26
///
37
/// See [zulipThemeData] for how themes are determined.
@@ -9,5 +13,19 @@ enum ThemeSetting {
913
light,
1014

1115
/// Corresponds to [Brightness.dark].
12-
dark,
16+
dark;
17+
18+
static String displayName({
19+
required ThemeSetting? themeSetting,
20+
required ZulipLocalizations zulipLocalizations,
21+
}) {
22+
switch (themeSetting) {
23+
case null:
24+
return zulipLocalizations.themeSettingSystem;
25+
case ThemeSetting.light:
26+
return zulipLocalizations.themeSettingLight;
27+
case ThemeSetting.dark:
28+
return zulipLocalizations.themeSettingDark;
29+
}
30+
}
1331
}

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)