Skip to content

Commit

Permalink
Language Select
Browse files Browse the repository at this point in the history
  • Loading branch information
hhanh00 committed Apr 14, 2024
1 parent 3fef1e5 commit d186ef4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/appsettings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ extension AppSettingsExtension on AppSettings {
if (!hasCustomSendSettings())
customSendSettings = CustomSendSettings()..defaults();
if (!hasBackgroundSync()) backgroundSync = 1;
if (!hasLanguage()) language = 'en';
}

static AppSettings load(SharedPreferences prefs) {
Expand Down
1 change: 1 addition & 0 deletions lib/init.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class _AppState extends State<App> {
),
);
return MaterialApp.router(
locale: Locale(appSettings.language),
title: APP_NAME,
debugShowCheckedModeBanner: false,
theme: theme,
Expand Down
14 changes: 14 additions & 0 deletions lib/settings.pb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AppSettings extends $pb.GeneratedMessage {
$core.bool? customSend,
CustomSendSettings? customSendSettings,
$core.int? backgroundSync,
$core.String? language,
}) {
final $result = create();
if (confirmations != null) {
Expand Down Expand Up @@ -122,6 +123,9 @@ class AppSettings extends $pb.GeneratedMessage {
if (backgroundSync != null) {
$result.backgroundSync = backgroundSync;
}
if (language != null) {
$result.language = language;
}
return $result;
}
AppSettings._() : super();
Expand Down Expand Up @@ -155,6 +159,7 @@ class AppSettings extends $pb.GeneratedMessage {
..aOB(27, _omitFieldNames ? '' : 'customSend')
..aOM<CustomSendSettings>(28, _omitFieldNames ? '' : 'customSendSettings', subBuilder: CustomSendSettings.create)
..a<$core.int>(30, _omitFieldNames ? '' : 'backgroundSync', $pb.PbFieldType.OU3)
..aOS(31, _omitFieldNames ? '' : 'language')
..hasRequiredFields = false
;

Expand Down Expand Up @@ -416,6 +421,15 @@ class AppSettings extends $pb.GeneratedMessage {
$core.bool hasBackgroundSync() => $_has(25);
@$pb.TagNumber(30)
void clearBackgroundSync() => clearField(30);

@$pb.TagNumber(31)
$core.String get language => $_getSZ(26);
@$pb.TagNumber(31)
set language($core.String v) { $_setString(26, v); }
@$pb.TagNumber(31)
$core.bool hasLanguage() => $_has(26);
@$pb.TagNumber(31)
void clearLanguage() => clearField(31);
}

class CoinSettings extends $pb.GeneratedMessage {
Expand Down
22 changes: 20 additions & 2 deletions lib/theme_editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,26 @@ class _ThemeEditorState extends State<ThemeEditorTab>
return FormBuilder(
key: formKey,
child: Column(children: [
FormBuilderSwitch(name: 'dark', title: Text(s.dark),
initialValue: _dark, onChanged: (v) => setState(() => setDark(v!)),),
FormBuilderRadioGroup(
decoration: InputDecoration(label: Text('Language')),
name: 'language',
initialValue: appSettings.language,
options: [
FormBuilderFieldOption(value: 'en', child: Text('English')),
FormBuilderFieldOption(value: 'fr', child: Text('Français')),
FormBuilderFieldOption(value: 'es', child: Text('Spanish')),
FormBuilderFieldOption(value: 'pt', child: Text('Português')),
],
onChanged: (v) => widget.appSettings.language = v!,
),
Divider(),
Gap(8),
FormBuilderSwitch(
name: 'dark',
title: Text(s.dark),
initialValue: _dark,
onChanged: (v) => setState(() => setDark(v!)),
),
Gap(16),
Wrap(
spacing: 8,
Expand Down
1 change: 1 addition & 0 deletions proto/settings.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ message AppSettings {
bool custom_send = 27;
CustomSendSettings custom_send_settings = 28;
uint32 background_sync = 30;
string language = 31;
}

message CoinSettings {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.5.7+521
version: 1.5.7+522

environment:
sdk: ">=3.0.0 <4.0.0"
Expand Down

0 comments on commit d186ef4

Please sign in to comment.