-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* locale implementation * add localizations translates * update changelogs * update app version
- Loading branch information
Showing
15 changed files
with
145 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
|
||
part 'result.freezed.dart'; | ||
|
||
@freezed | ||
class Result<T> with _$Result<T> { | ||
|
||
const factory Result(T data) = _Result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:amiibo_network/generated/l10n.dart'; | ||
import 'package:amiibo_network/model/result.dart'; | ||
import 'package:amiibo_network/riverpod/preferences_provider.dart'; | ||
import 'package:amiibo_network/utils/string_extensions.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_hooks/flutter_hooks.dart'; | ||
import 'package:hooks_riverpod/hooks_riverpod.dart'; | ||
|
||
class LocaleDialog extends HookConsumerWidget { | ||
const LocaleDialog({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final localizations = MaterialLocalizations.of(context); | ||
final S translate = S.of(context); | ||
final selectedLocale = ref.watch(localeProvider); | ||
final ValueNotifier<String?> state = useState(selectedLocale?.languageCode); | ||
return AlertDialog( | ||
title: Text(translate.language), | ||
scrollable: true, | ||
alignment: Alignment.center, | ||
content: ListBody( | ||
children: [ | ||
RadioListTile<String?>( | ||
value: null, | ||
groupValue: state.value, | ||
title: Text(translate.system), | ||
onChanged: (value) => state.value = value, | ||
), | ||
for (final locale in S.delegate.supportedLocales) | ||
RadioListTile<String?>( | ||
value: locale.languageCode, | ||
groupValue: state.value, | ||
title: Text(translate.localization(locale.languageCode)), | ||
onChanged: (value) => state.value = value, | ||
), | ||
], | ||
), | ||
actions: [ | ||
TextButton( | ||
child: Text(localizations.cancelButtonLabel.capitalize()), | ||
onPressed: Navigator.of(context).pop, | ||
), | ||
ElevatedButton( | ||
child: Text(localizations.saveButtonLabel.capitalize()), | ||
onPressed: () async => | ||
Navigator.of(context).pop(Result<String?>(state.value)), | ||
), | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters