feat(flutter): 应用克莱因蓝主题与印尼语适配
This commit is contained in:
1 parent
e1147cfcba
commit
10d448c8ba
31 files changed
+891
-521
No files matched your search
@@ -3,6 +3,19 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// Resolves the selected or system language to one of the supported app locales.
|
||||
///
|
||||
/// Indonesian is the launch-market fallback when a device uses an unsupported
|
||||
/// language. The legacy `in` code is treated as Indonesian as well.
|
||||
Locale resolveAppLocale(Locale? selected, Locale? deviceLocale) {
|
||||
final code = (selected ?? deviceLocale)?.languageCode;
|
||||
return switch (code) {
|
||||
'zh' => const Locale('zh'),
|
||||
'en' => const Locale('en'),
|
||||
_ => const Locale('id'),
|
||||
};
|
||||
}
|
||||
|
||||
class LocaleController extends ChangeNotifier {
|
||||
LocaleController({SharedPreferencesAsync? preferences})
|
||||
: _preferences = preferences ?? SharedPreferencesAsync();
|
||||
@@ -17,6 +30,7 @@ class LocaleController extends ChangeNotifier {
|
||||
_locale = switch (code) {
|
||||
'en' => const Locale('en'),
|
||||
'zh' => const Locale('zh'),
|
||||
'id' => const Locale('id'),
|
||||
_ => null,
|
||||
};
|
||||
notifyListeners();
|
||||
@@ -29,6 +43,7 @@ class LocaleController extends ChangeNotifier {
|
||||
_locale = switch (code) {
|
||||
'en' => const Locale('en'),
|
||||
'zh' => const Locale('zh'),
|
||||
'id' => const Locale('id'),
|
||||
_ => null,
|
||||
};
|
||||
notifyListeners();
|
||||
|
||||
Reference in new issue
Block a user