remove locale name package (-3 MB)
This commit is contained in:
parent
40e9439252
commit
b60ebf6698
5 changed files with 19 additions and 30 deletions
|
@ -24,7 +24,6 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_localized_locales/flutter_localized_locales.dart';
|
||||
import 'package:overlay_support/overlay_support.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
@ -107,7 +106,6 @@ class _AvesAppState extends State<AvesApp> {
|
|||
locale: settingsLocale,
|
||||
localizationsDelegates: [
|
||||
...AppLocalizations.localizationsDelegates,
|
||||
LocaleNamesLocalizationsDelegate(),
|
||||
],
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
);
|
||||
|
|
|
@ -79,10 +79,10 @@ class Constants {
|
|||
sourceUrl: 'https://github.com/FirebaseExtended/flutterfire',
|
||||
),
|
||||
Dependency(
|
||||
name: 'Flutter ijkplayer',
|
||||
name: 'fijkplayer',
|
||||
license: 'MIT',
|
||||
licenseUrl: 'https://github.com/CaiJingLong/flutter_ijkplayer/blob/master/LICENSE',
|
||||
sourceUrl: 'https://github.com/CaiJingLong/flutter_ijkplayer',
|
||||
licenseUrl: 'https://github.com/deckerst/fijkplayer/blob/master/LICENSE',
|
||||
sourceUrl: 'https://github.com/deckerst/fijkplayer',
|
||||
),
|
||||
Dependency(
|
||||
name: 'Google API Availability',
|
||||
|
@ -231,8 +231,8 @@ class Constants {
|
|||
Dependency(
|
||||
name: 'Expansion Tile Card',
|
||||
license: 'BSD 3-Clause',
|
||||
licenseUrl: 'https://github.com/Skylled/expansion_tile_card/blob/master/LICENSE',
|
||||
sourceUrl: 'https://github.com/Skylled/expansion_tile_card',
|
||||
licenseUrl: 'https://github.com/deckerst/expansion_tile_card/blob/master/LICENSE',
|
||||
sourceUrl: 'https://github.com/deckerst/expansion_tile_card',
|
||||
),
|
||||
Dependency(
|
||||
name: 'Flutter Highlight',
|
||||
|
@ -240,12 +240,6 @@ class Constants {
|
|||
licenseUrl: 'https://github.com/git-touch/highlight/blob/master/LICENSE',
|
||||
sourceUrl: 'https://github.com/git-touch/highlight',
|
||||
),
|
||||
Dependency(
|
||||
name: 'Flutter Localized Locales',
|
||||
license: 'MIT',
|
||||
licenseUrl: 'https://github.com/guidezpl/flutter-localized-locales/blob/master/LICENSE',
|
||||
sourceUrl: 'https://github.com/guidezpl/flutter-localized-locales',
|
||||
),
|
||||
Dependency(
|
||||
name: 'Flutter Map',
|
||||
license: 'BSD 3-Clause',
|
||||
|
|
|
@ -9,11 +9,8 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
import 'package:flutter_localized_locales/flutter_localized_locales.dart';
|
||||
|
||||
class LanguageTile extends StatelessWidget {
|
||||
final Locale _systemLocale = WidgetsBinding.instance.window.locale;
|
||||
|
||||
static const _systemLocaleOption = Locale('system');
|
||||
|
||||
@override
|
||||
|
@ -21,14 +18,13 @@ class LanguageTile extends StatelessWidget {
|
|||
final current = settings.locale;
|
||||
return ListTile(
|
||||
title: Text(context.l10n.settingsLanguage),
|
||||
subtitle: Text('${current == null ? '${context.l10n.settingsSystemDefault} • ${_getLocaleName(_systemLocale)}' : _getLocaleName(current)}'),
|
||||
subtitle: Text('${current == null ? context.l10n.settingsSystemDefault : _getLocaleName(current)}'),
|
||||
onTap: () async {
|
||||
final value = await showDialog<Locale>(
|
||||
context: context,
|
||||
builder: (context) => AvesSelectionDialog<Locale>(
|
||||
initialValue: settings.locale ?? _systemLocaleOption,
|
||||
options: _getLocaleOptions(context),
|
||||
optionSubtitleBuilder: (locale) => locale == _systemLocaleOption ? _getLocaleName(_systemLocale) : null,
|
||||
title: context.l10n.settingsLanguage,
|
||||
),
|
||||
);
|
||||
|
@ -41,12 +37,20 @@ class LanguageTile extends StatelessWidget {
|
|||
);
|
||||
}
|
||||
|
||||
String _getLocaleName(Locale locale) => LocaleNamesLocalizationsDelegate.nativeLocaleNames[locale.toString()];
|
||||
String _getLocaleName(Locale locale) {
|
||||
// the package `flutter_localized_locales` has the answer for all locales
|
||||
// but it comes with 3 MB of assets
|
||||
switch (locale.languageCode) {
|
||||
case 'en':
|
||||
return 'English';
|
||||
case 'ko':
|
||||
return '한국어';
|
||||
}
|
||||
return locale.toString();
|
||||
}
|
||||
|
||||
LinkedHashMap<Locale, String> _getLocaleOptions(BuildContext context) {
|
||||
final supportedLocales = List<Locale>.from(AppLocalizations.supportedLocales);
|
||||
supportedLocales.removeWhere((locale) => locale == _systemLocale);
|
||||
final displayLocales = supportedLocales.map((locale) => MapEntry(locale, _getLocaleName(locale))).toList()..sort((a, b) => compareAsciiUpperCase(a.value, b.value));
|
||||
final displayLocales = AppLocalizations.supportedLocales.map((locale) => MapEntry(locale, _getLocaleName(locale))).toList()..sort((a, b) => compareAsciiUpperCase(a.value, b.value));
|
||||
|
||||
return LinkedHashMap.of({
|
||||
_systemLocaleOption: context.l10n.settingsSystemDefault,
|
||||
|
|
|
@ -321,13 +321,6 @@ packages:
|
|||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_localized_locales:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_localized_locales
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.1"
|
||||
flutter_map:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
|
@ -42,7 +42,6 @@ dependencies:
|
|||
firebase_analytics:
|
||||
firebase_crashlytics:
|
||||
flutter_highlight:
|
||||
flutter_localized_locales:
|
||||
flutter_map:
|
||||
flutter_markdown:
|
||||
flutter_staggered_animations:
|
||||
|
@ -108,6 +107,7 @@ flutter:
|
|||
# - /android/app/src/main/res/values-{language}/strings.xml
|
||||
# - /android/app/src/debug/res/values-{language}/strings.xml (optional)
|
||||
# - /android/app/src/profile/res/values-{language}/strings.xml (optional)
|
||||
# - edit locale name resolution for language setting
|
||||
|
||||
# generate `AppLocalizations`
|
||||
# % flutter gen-l10n
|
||||
|
|
Loading…
Reference in a new issue