@@ -2,12 +2,14 @@ import 'package:flutter/material.dart';
22
33import 'package:go_router/go_router.dart' ;
44import 'package:matrix/matrix.dart' ;
5+ import 'package:provider/provider.dart' ;
56import 'package:shared_preferences/shared_preferences.dart' ;
67
78import 'package:fluffychat/config/routes.dart' ;
89import 'package:fluffychat/config/setting_keys.dart' ;
910import 'package:fluffychat/config/themes.dart' ;
1011import 'package:fluffychat/l10n/l10n.dart' ;
12+ import 'package:fluffychat/config/locale_provide.dart' ;
1113import 'package:fluffychat/widgets/app_lock.dart' ;
1214import 'package:fluffychat/widgets/theme_builder.dart' ;
1315import '../utils/custom_scroll_behaviour.dart' ;
@@ -27,43 +29,42 @@ class FluffyChatApp extends StatelessWidget {
2729 this .pincode,
2830 });
2931
30- /// getInitialLink may rereturn the value multiple times if this view is
31- /// opened multiple times for example if the user logs out after they logged
32- /// in with qr code or magic link.
3332 static bool gotInitialLink = false ;
3433
35- // Router must be outside of build method so that hot reload does not reset
36- // the current path.
3734 static final GoRouter router = GoRouter (
3835 routes: AppRoutes .routes,
3936 debugLogDiagnostics: true ,
4037 );
4138
4239 @override
4340 Widget build (BuildContext context) {
44- return ThemeBuilder (
45- builder: (context, themeMode, primaryColor) => MaterialApp .router (
46- title: AppSettings .applicationName.value,
47- themeMode: themeMode,
48- theme: FluffyThemes .buildTheme (context, Brightness .light, primaryColor),
49- darkTheme:
50- FluffyThemes .buildTheme (context, Brightness .dark, primaryColor),
51- scrollBehavior: CustomScrollBehavior (),
52- localizationsDelegates: L10n .localizationsDelegates,
53- supportedLocales: L10n .supportedLocales,
54- routerConfig: router,
55- builder: (context, child) => AppLockWidget (
56- pincode: pincode,
57- clients: clients,
58- // Need a navigator above the Matrix widget for
59- // displaying dialogs
60- child: Matrix (
61- clients: clients,
62- store: store,
63- child: testWidget ?? child,
64- ),
65- ),
66- ),
67- );
41+ return ChangeNotifierProvider <LocaleProvider >(
42+ create: (_) => LocaleProvider (),
43+ child: ThemeBuilder (
44+ builder: (context, themeMode, primaryColor) {
45+ return MaterialApp .router (
46+ title: AppSettings .applicationName.value,
47+ themeMode: themeMode,
48+ theme: FluffyThemes .buildTheme (
49+ context, Brightness .light, primaryColor),
50+ darkTheme: FluffyThemes .buildTheme (
51+ context, Brightness .dark, primaryColor),
52+ scrollBehavior: CustomScrollBehavior (),
53+ locale: context.watch <LocaleProvider >().locale,
54+ localizationsDelegates: L10n .localizationsDelegates,
55+ supportedLocales: L10n .supportedLocales,
56+ routerConfig: router,
57+ builder: (context, child) => AppLockWidget (
58+ pincode: pincode,
59+ clients: clients,
60+ child: Matrix (
61+ clients: clients,
62+ store: store,
63+ child: testWidget ?? child,
64+ ),
65+ ),
66+ );
67+ },
68+ ));
6869 }
6970}
0 commit comments