From 667242fafdecf91ed3db6e4ece758421509df1fd Mon Sep 17 00:00:00 2001 From: fulleni Date: Thu, 7 Aug 2025 11:11:51 +0100 Subject: [PATCH 1/2] feat(localization): add UiKitLocalizations to localizationsDelegates - Add UiKitLocalizations.localizationsDelegates to the existing AppLocalizations.localizationsDelegates for dark mode toggle buttons in iOS. - Implemented in three MaterialApp widgets within the _AppViewState class. --- lib/app/view/app.dart | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/app/view/app.dart b/lib/app/view/app.dart index 029c37a..95f0a25 100644 --- a/lib/app/view/app.dart +++ b/lib/app/view/app.dart @@ -238,7 +238,10 @@ class _AppViewState extends State<_AppView> { fontFamily: null, ), themeMode: state.themeMode, - localizationsDelegates: AppLocalizations.localizationsDelegates, + localizationsDelegates: const [ + ...AppLocalizations.localizationsDelegates, + ...UiKitLocalizations.localizationsDelegates, + ], supportedLocales: AppLocalizations.supportedLocales, locale: state.locale, home: const MaintenancePage(), @@ -262,7 +265,10 @@ class _AppViewState extends State<_AppView> { fontFamily: null, ), themeMode: state.themeMode, - localizationsDelegates: AppLocalizations.localizationsDelegates, + localizationsDelegates: const [ + ...AppLocalizations.localizationsDelegates, + ...UiKitLocalizations.localizationsDelegates, + ], supportedLocales: AppLocalizations.supportedLocales, locale: state.locale, home: const UpdateRequiredPage(), @@ -289,7 +295,10 @@ class _AppViewState extends State<_AppView> { fontFamily: null, ), themeMode: state.themeMode, - localizationsDelegates: AppLocalizations.localizationsDelegates, + localizationsDelegates: const [ + ...AppLocalizations.localizationsDelegates, + ...UiKitLocalizations.localizationsDelegates, + ], supportedLocales: AppLocalizations.supportedLocales, locale: state.locale, home: const StatusPage(), From 48ed29a1acd9fdda1ba2b40eb5314faa96f69c32 Mon Sep 17 00:00:00 2001 From: fulleni Date: Thu, 7 Aug 2025 17:28:38 +0100 Subject: [PATCH 2/2] refactor(app): simplify status resolution logic - Remove conditional distinction between initial fetch and background check - Consolidate status resolution logic for both scenarios - Improve code readability and reduce complexity --- lib/app/bloc/app_bloc.dart | 21 +++++++-------------- lib/app/services/app_status_service.dart | 20 ++++++++------------ 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/lib/app/bloc/app_bloc.dart b/lib/app/bloc/app_bloc.dart index 44c77d2..dfb7f0c 100644 --- a/lib/app/bloc/app_bloc.dart +++ b/lib/app/bloc/app_bloc.dart @@ -461,20 +461,13 @@ class AppBloc extends Bloc { // --- POST-CHECK STATE RESOLUTION --- // If no critical status was found, we resolve the final state. - - // For an initial fetch, we transition from configFetching to the correct - // authenticated/anonymous state. - if (!event.isBackgroundCheck) { - final finalStatus = state.user!.appRole == AppUserRole.standardUser - ? AppStatus.authenticated - : AppStatus.anonymous; - emit(state.copyWith(remoteConfig: remoteConfig, status: finalStatus)); - } else { - // For a background check, the status is already correct (e.g., authenticated). - // We just need to update the remoteConfig in the state silently. - // The status does not need to change, preventing a disruptive UI rebuild. - emit(state.copyWith(remoteConfig: remoteConfig)); - } + // This logic applies to both initial fetches (transitioning from + // configFetching) and background checks (transitioning from a state + // like underMaintenance back to a running state). + final finalStatus = state.user!.appRole == AppUserRole.standardUser + ? AppStatus.authenticated + : AppStatus.anonymous; + emit(state.copyWith(remoteConfig: remoteConfig, status: finalStatus)); } on HttpException catch (e) { print( '[AppBloc] Failed to fetch AppConfig (HttpException) for user ${state.user?.id}: ${e.runtimeType} - ${e.message}', diff --git a/lib/app/services/app_status_service.dart b/lib/app/services/app_status_service.dart index 2a2bb7a..858c8e1 100644 --- a/lib/app/services/app_status_service.dart +++ b/lib/app/services/app_status_service.dart @@ -30,9 +30,9 @@ class AppStatusService with WidgetsBindingObserver { required BuildContext context, required Duration checkInterval, required AppEnvironment environment, - }) : _context = context, - _checkInterval = checkInterval, - _environment = environment { + }) : _context = context, + _checkInterval = checkInterval, + _environment = environment { // Immediately register this service as a lifecycle observer. WidgetsBinding.instance.addObserver(this); // Start the periodic checks. @@ -62,18 +62,16 @@ class AppStatusService with WidgetsBindingObserver { _timer = Timer.periodic(_checkInterval, (_) { // In demo mode, periodic checks are not needed as there's no backend. if (_environment == AppEnvironment.demo) { - print( - '[AppStatusService] Demo mode: Skipping periodic check.', - ); + print('[AppStatusService] Demo mode: Skipping periodic check.'); return; } print( '[AppStatusService] Periodic check triggered. Requesting AppConfig fetch.', ); // Add the event to the AppBloc to fetch the latest config. - _context - .read() - .add(const AppConfigFetchRequested(isBackgroundCheck: true)); + _context.read().add( + const AppConfigFetchRequested(isBackgroundCheck: true), + ); }); } @@ -92,9 +90,7 @@ class AppStatusService with WidgetsBindingObserver { // We are only interested in the 'resumed' state. if (state == AppLifecycleState.resumed) { - print( - '[AppStatusService] App resumed. Requesting AppConfig fetch.', - ); + print('[AppStatusService] App resumed. Requesting AppConfig fetch.'); // When the app comes to the foreground, immediately trigger a check. // This is crucial for catching maintenance mode that was enabled // while the app was in the background.