@@ -28,8 +28,6 @@ class _StateMainView extends State<MainView> {
2828
2929 bool isFullScreenModel = false ;
3030
31- Locale get locale => appSettings? .locale ?? Locale ('en' , 'US' );
32-
3331 bool isLoading = false ;
3432
3533 void onLoading () {
@@ -59,55 +57,61 @@ class _StateMainView extends State<MainView> {
5957 @override
6058 Widget build (BuildContext context) {
6159 MaterialTheme theme = MaterialTheme ();
62- return MaterialApp (
63- debugShowCheckedModeBanner: false ,
64- locale: locale,
65- builder: DevicePreview .appBuilder,
66- localizationsDelegates: const [
67- FlutterQuillLocalizations .delegate,
68- ...AppLocalizations .localizationsDelegates,
69- GlobalMaterialLocalizations .delegate,
70- GlobalWidgetsLocalizations .delegate,
71- GlobalCupertinoLocalizations .delegate,
72- ],
73- supportedLocales: AppLocalizations .supportedLocales,
74- theme: theme.light (),
75- darkTheme: theme.dark (),
76- highContrastTheme: theme.lightMediumContrast (),
77- highContrastDarkTheme: theme.darkMediumContrast (),
78- scrollBehavior: const MaterialScrollBehavior ().copyWith (
79- scrollbars: false ,
80- ),
81- navigatorKey: Navigation ().navigatorKey,
82- home: Builder (
83- builder: (context) {
84- return Stack (
85- children: [
86- AppLayout (
87- defaultWidget: DefaultTabController (
88- animationDuration: Duration .zero,
89- initialIndex: 1 ,
90- length: 3 ,
91- child: Scaffold (
92- drawer: DrawerView (),
93- appBar: isFullScreenModel ? null : AppBarView (),
94- body: SafeArea (
95- child: ContentView (isFullScreenModel: isFullScreenModel),
96- ),
97- floatingActionButton: ToggleFullscreenView (
98- onSreenStateChange: (bool isFullScreen) => setState (() {
99- isFullScreenModel = isFullScreen;
100- }),
60+ return ValueListenableBuilder <Locale >(
61+ valueListenable:
62+ appSettings? .currentLocale ?? ValueNotifier (const Locale ('en' , 'US' )),
63+ builder: (context, locale, child) => MaterialApp (
64+ debugShowCheckedModeBanner: false ,
65+ locale: locale,
66+ builder: DevicePreview .appBuilder,
67+ localizationsDelegates: const [
68+ FlutterQuillLocalizations .delegate,
69+ ...AppLocalizations .localizationsDelegates,
70+ GlobalMaterialLocalizations .delegate,
71+ GlobalWidgetsLocalizations .delegate,
72+ GlobalCupertinoLocalizations .delegate,
73+ ],
74+ supportedLocales: AppLocalizations .supportedLocales,
75+ theme: theme.light (),
76+ darkTheme: theme.dark (),
77+ highContrastTheme: theme.lightHighContrast (),
78+ highContrastDarkTheme: theme.dark (),
79+ scrollBehavior: const MaterialScrollBehavior ().copyWith (
80+ scrollbars: false ,
81+ ),
82+ navigatorKey: Navigation ().navigatorKey,
83+ home: Builder (
84+ builder: (context) {
85+ return Stack (
86+ children: [
87+ AppLayout (
88+ defaultWidget: DefaultTabController (
89+ animationDuration: Duration .zero,
90+ initialIndex: 1 ,
91+ length: 3 ,
92+ child: Scaffold (
93+ drawer: DrawerView (),
94+ appBar: isFullScreenModel ? null : AppBarView (),
95+ body: SafeArea (
96+ child: ContentView (
97+ isFullScreenModel: isFullScreenModel,
98+ ),
99+ ),
100+ floatingActionButton: ToggleFullscreenView (
101+ onSreenStateChange: (bool isFullScreen) => setState (() {
102+ isFullScreenModel = isFullScreen;
103+ }),
104+ ),
101105 ),
102106 ),
107+ context: context,
103108 ),
104- context: context,
105- ),
106- if (isLoading)
107- const Positioned .fill (child: Center (child: LoadingScreen ())),
108- ],
109- );
110- },
109+ if (isLoading)
110+ const Positioned .fill (child: Center (child: LoadingScreen ())),
111+ ],
112+ );
113+ },
114+ ),
111115 ),
112116 );
113117 }
0 commit comments