Skip to content

Commit b030737

Browse files
PIG208gnprice
authored andcommitted
settings: Add browser preference setting ui
The UI currently does not have a design, and is made to be as simple as possible to implement for now. Fixes: #1228 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 8901b79 commit b030737

12 files changed

+104
-0
lines changed

assets/l10n/app_en.arb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,10 @@
811811
"@themeSettingSystem": {
812812
"description": "Label for system theme setting."
813813
},
814+
"openLinksWithInAppBrowser": "Open links with in-app browser",
815+
"@openLinksWithInAppBrowser": {
816+
"description": "Label for toggling setting to open links with in-app browser"
817+
},
814818
"pollWidgetQuestionMissing": "No question.",
815819
"@pollWidgetQuestionMissing": {
816820
"description": "Text to display for a poll when the question is missing"

lib/generated/l10n/zulip_localizations.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,6 +1185,12 @@ abstract class ZulipLocalizations {
11851185
/// **'System'**
11861186
String get themeSettingSystem;
11871187

1188+
/// Label for toggling setting to open links with in-app browser
1189+
///
1190+
/// In en, this message translates to:
1191+
/// **'Open links with in-app browser'**
1192+
String get openLinksWithInAppBrowser;
1193+
11881194
/// Text to display for a poll when the question is missing
11891195
///
11901196
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
634634
@override
635635
String get themeSettingSystem => 'System';
636636

637+
@override
638+
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
639+
637640
@override
638641
String get pollWidgetQuestionMissing => 'No question.';
639642

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
634634
@override
635635
String get themeSettingSystem => 'System';
636636

637+
@override
638+
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
639+
637640
@override
638641
String get pollWidgetQuestionMissing => 'No question.';
639642

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
634634
@override
635635
String get themeSettingSystem => 'System';
636636

637+
@override
638+
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
639+
637640
@override
638641
String get pollWidgetQuestionMissing => 'No question.';
639642

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
634634
@override
635635
String get themeSettingSystem => 'System';
636636

637+
@override
638+
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
639+
637640
@override
638641
String get pollWidgetQuestionMissing => 'No question.';
639642

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
634634
@override
635635
String get themeSettingSystem => 'System';
636636

637+
@override
638+
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
639+
637640
@override
638641
String get pollWidgetQuestionMissing => 'Brak pytania.';
639642

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
634634
@override
635635
String get themeSettingSystem => 'System';
636636

637+
@override
638+
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
639+
637640
@override
638641
String get pollWidgetQuestionMissing => 'Нет вопроса.';
639642

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,9 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
634634
@override
635635
String get themeSettingSystem => 'System';
636636

637+
@override
638+
String get openLinksWithInAppBrowser => 'Open links with in-app browser';
639+
637640
@override
638641
String get pollWidgetQuestionMissing => 'Bez otázky.';
639642

lib/widgets/settings.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class SettingsPage extends StatelessWidget {
2424
title: Text(zulipLocalizations.settingsPageTitle)),
2525
body: Column(children: [
2626
const _ThemeSetting(),
27+
const _BrowserPreferenceSetting(),
2728
]));
2829
}
2930
}
@@ -54,3 +55,26 @@ class _ThemeSetting extends StatelessWidget {
5455
]);
5556
}
5657
}
58+
59+
class _BrowserPreferenceSetting extends StatelessWidget {
60+
const _BrowserPreferenceSetting();
61+
62+
void _handleChange(BuildContext context, bool newOpenLinksWithInAppBrowser) {
63+
GlobalStoreWidget.of(context).updateGlobalSettings(
64+
GlobalSettingsCompanion(browserPreference: Value(
65+
newOpenLinksWithInAppBrowser ? BrowserPreference.inApp
66+
: BrowserPreference.external)));
67+
}
68+
69+
@override
70+
Widget build(BuildContext context) {
71+
final zulipLocalizations = ZulipLocalizations.of(context);
72+
final openLinksWithInAppBrowser =
73+
GlobalStoreWidget.of(context).globalSettings.effectiveBrowserPreference
74+
== BrowserPreference.inApp;
75+
return SwitchListTile.adaptive(
76+
title: Text(zulipLocalizations.openLinksWithInAppBrowser),
77+
value: openLinksWithInAppBrowser,
78+
onChanged: (newValue) => _handleChange(context, newValue));
79+
}
80+
}

0 commit comments

Comments
 (0)