Merge pull request #55 from ente-io/fix_locale
Fix locale detection for AppLock
This commit is contained in:
commit
7c5d95d8e3
4 changed files with 25 additions and 25 deletions
|
@ -9,6 +9,7 @@ import 'package:ente_auth/ente_theme_data.dart';
|
|||
import 'package:ente_auth/events/signed_in_event.dart';
|
||||
import 'package:ente_auth/events/signed_out_event.dart';
|
||||
import "package:ente_auth/l10n/l10n.dart";
|
||||
import 'package:ente_auth/locale.dart';
|
||||
import "package:ente_auth/onboarding/view/onboarding_page.dart";
|
||||
import 'package:ente_auth/services/update_service.dart';
|
||||
import 'package:ente_auth/ui/home_page.dart';
|
||||
|
@ -27,9 +28,6 @@ class App extends StatefulWidget {
|
|||
class _AppState extends State<App> {
|
||||
StreamSubscription<SignedOutEvent> _signedOutEvent;
|
||||
StreamSubscription<SignedInEvent> _signedInEvent;
|
||||
static const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -82,15 +80,7 @@ class _AppState extends State<App> {
|
|||
darkTheme: dartTheme,
|
||||
debugShowCheckedModeBanner: false,
|
||||
supportedLocales: supportedLocales,
|
||||
localeListResolutionCallback: (locales, supportedLocales) {
|
||||
for (Locale locale in locales) {
|
||||
if (supportedLocales.contains(locale)) {
|
||||
return locale;
|
||||
}
|
||||
}
|
||||
// if device language is not supported by the app, use en as default
|
||||
return const Locale('en');
|
||||
},
|
||||
localeListResolutionCallback: localResolutionCallBack,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
routes: _getRoutes,
|
||||
),
|
||||
|
@ -103,15 +93,7 @@ class _AppState extends State<App> {
|
|||
darkTheme: darkThemeData,
|
||||
debugShowCheckedModeBanner: false,
|
||||
supportedLocales: supportedLocales,
|
||||
localeListResolutionCallback: (locales, supportedLocales) {
|
||||
for (Locale locale in locales) {
|
||||
if (supportedLocales.contains(locale)) {
|
||||
return locale;
|
||||
}
|
||||
}
|
||||
// if device language is not supported by the app, use en as default
|
||||
return const Locale('en');
|
||||
},
|
||||
localeListResolutionCallback: localResolutionCallBack,
|
||||
localizationsDelegates: const [
|
||||
AppLocalizations.delegate,
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
|
|
18
lib/locale.dart
Normal file
18
lib/locale.dart
Normal file
|
@ -0,0 +1,18 @@
|
|||
import 'dart:ui';
|
||||
|
||||
// list of locales which are enabled for auth app.
|
||||
// Add more language to the list only when at least 90% of the strings are
|
||||
// translated in the corresponding language.
|
||||
const List<Locale> supportedLocales = <Locale>[
|
||||
Locale('en'),
|
||||
];
|
||||
|
||||
Locale localResolutionCallBack(locales, supportedLocales) {
|
||||
for (Locale locale in locales) {
|
||||
if (supportedLocales.contains(locale)) {
|
||||
return locale;
|
||||
}
|
||||
}
|
||||
// if device language is not supported by the app, use en as default
|
||||
return const Locale('en');
|
||||
}
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ente_auth/locale.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
/// A widget which handles app lifecycle events for showing and hiding a lock screen.
|
||||
/// This should wrap around a `MyApp` widget (or equivalent).
|
||||
|
@ -108,8 +108,8 @@ class _AppLockState extends State<AppLock> with WidgetsBindingObserver {
|
|||
themeMode: ThemeMode.system,
|
||||
theme: widget.lightTheme,
|
||||
darkTheme: widget.darkTheme,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: supportedLocales,
|
||||
localeListResolutionCallback: localResolutionCallBack,
|
||||
onGenerateRoute: (settings) {
|
||||
switch (settings.name) {
|
||||
case '/lock-screen':
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: ente_auth
|
||||
description: ente two-factor authenticator
|
||||
version: 1.0.28+28
|
||||
version: 1.0.29+29
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Add table
Reference in a new issue