Skip to content

Commit 513063b

Browse files
committed
refactor(theme): centralize theme customization in app.dart
- Add theme customization parameters in app.dart - Update import statements for l10n - Adjust theme settings in StatusPage - TODO: Implement proper localization for retry button text
1 parent e4e390c commit 513063b

File tree

2 files changed

+40
-9
lines changed

2 files changed

+40
-9
lines changed

lib/app/view/app.dart

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:flutter_news_app_mobile_client_full_source_code/app/config/app_e
99
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/app_status_service.dart';
1010
import 'package:flutter_news_app_mobile_client_full_source_code/app/services/demo_data_migration_service.dart';
1111
import 'package:flutter_news_app_mobile_client_full_source_code/authentication/bloc/authentication_bloc.dart';
12+
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/app_localizations.dart';
1213
import 'package:flutter_news_app_mobile_client_full_source_code/l10n/l10n.dart';
1314
import 'package:flutter_news_app_mobile_client_full_source_code/router/router.dart';
1415
import 'package:flutter_news_app_mobile_client_full_source_code/status/view/view.dart';
@@ -207,8 +208,18 @@ class _AppViewState extends State<_AppView> {
207208
// It's wrapped in a basic MaterialApp to provide theme and l10n.
208209
return MaterialApp(
209210
debugShowCheckedModeBanner: false,
210-
theme: lightTheme(),
211-
darkTheme: darkTheme(),
211+
theme: lightTheme(
212+
scheme: FlexScheme.material,
213+
appTextScaleFactor: AppTextScaleFactor.medium,
214+
appFontWeight: AppFontWeight.regular,
215+
fontFamily: null,
216+
),
217+
darkTheme: darkTheme(
218+
scheme: FlexScheme.material,
219+
appTextScaleFactor: AppTextScaleFactor.medium,
220+
appFontWeight: AppFontWeight.regular,
221+
fontFamily: null,
222+
),
212223
themeMode: state.themeMode,
213224
localizationsDelegates: AppLocalizations.localizationsDelegates,
214225
supportedLocales: AppLocalizations.supportedLocales,
@@ -220,8 +231,18 @@ class _AppViewState extends State<_AppView> {
220231
// A mandatory update is required. Show the UpdateRequiredPage.
221232
return MaterialApp(
222233
debugShowCheckedModeBanner: false,
223-
theme: lightTheme(),
224-
darkTheme: darkTheme(),
234+
theme: lightTheme(
235+
scheme: FlexScheme.material,
236+
appTextScaleFactor: AppTextScaleFactor.medium,
237+
appFontWeight: AppFontWeight.regular,
238+
fontFamily: null,
239+
),
240+
darkTheme: darkTheme(
241+
scheme: FlexScheme.material,
242+
appTextScaleFactor: AppTextScaleFactor.medium,
243+
appFontWeight: AppFontWeight.regular,
244+
fontFamily: null,
245+
),
225246
themeMode: state.themeMode,
226247
localizationsDelegates: AppLocalizations.localizationsDelegates,
227248
supportedLocales: AppLocalizations.supportedLocales,
@@ -236,8 +257,18 @@ class _AppViewState extends State<_AppView> {
236257
// both the loading indicator and the retry mechanism.
237258
return MaterialApp(
238259
debugShowCheckedModeBanner: false,
239-
theme: lightTheme(),
240-
darkTheme: darkTheme(),
260+
theme: lightTheme(
261+
scheme: FlexScheme.material,
262+
appTextScaleFactor: AppTextScaleFactor.medium,
263+
appFontWeight: AppFontWeight.regular,
264+
fontFamily: null,
265+
),
266+
darkTheme: darkTheme(
267+
scheme: FlexScheme.material,
268+
appTextScaleFactor: AppTextScaleFactor.medium,
269+
appFontWeight: AppFontWeight.regular,
270+
fontFamily: null,
271+
),
241272
themeMode: state.themeMode,
242273
localizationsDelegates: AppLocalizations.localizationsDelegates,
243274
supportedLocales: AppLocalizations.supportedLocales,

lib/status/view/status_page.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'package:core/core.dart';
1+
import 'package:core/core.dart' hide AppStatus;
22
import 'package:flutter/material.dart';
33
import 'package:flutter_bloc/flutter_bloc.dart';
44
import 'package:flutter_news_app_mobile_client_full_source_code/app/bloc/app_bloc.dart';
@@ -24,7 +24,7 @@ class StatusPage extends StatelessWidget {
2424
return Scaffold(
2525
body: BlocBuilder<AppBloc, AppState>(
2626
builder: (context, state) {
27-
final l10n = context.l10n;
27+
final l10n = AppLocalizationsX(context).l10n;
2828

2929
if (state.status == AppStatus.configFetching) {
3030
// While fetching configuration, display a clear loading indicator.
@@ -40,7 +40,7 @@ class StatusPage extends StatelessWidget {
4040
// This allows the user to recover from transient network issues.
4141
return FailureStateWidget(
4242
exception: const NetworkException(), // A generic network error
43-
retryButtonText: l10n.retryButtonText,
43+
retryButtonText: 'l10n.retryButtonText', //TODO(fulleni): localize me.
4444
onRetry: () {
4545
// Dispatch the event to AppBloc to re-trigger the fetch.
4646
context.read<AppBloc>().add(const AppConfigFetchRequested());

0 commit comments

Comments
 (0)