|
| 1 | +import 'package:app/themes_setup.dart'; |
1 | 2 | import 'package:flutter/material.dart'; |
2 | 3 | import 'package:localisation/strings.dart'; |
3 | 4 | import 'package:responsive_framework/responsive_framework.dart'; |
4 | 5 | import 'package:services/services.dart'; |
| 6 | + |
5 | 7 | import 'package:themes/themes.dart'; |
6 | 8 |
|
7 | 9 | import 'navigation/app_router.dart'; |
8 | 10 | import 'navigation/route_paths.dart'; |
9 | 11 |
|
10 | 12 | class MyApp extends StatelessWidget { |
11 | | - const MyApp({Key? key}) : super(key: key); |
| 13 | + const MyApp({super.key}); |
12 | 14 |
|
13 | 15 | @override |
14 | 16 | Widget build(BuildContext context) { |
15 | 17 | return ThemeBuilder( |
16 | | - themes: [ |
17 | | - ThemeData( |
18 | | - backgroundColor: Colors.red, |
19 | | - colorScheme: ColorScheme.fromSwatch().copyWith( |
20 | | - secondary: Colors.blue, |
21 | | - brightness: Brightness.light, |
22 | | - )), |
23 | | - ], |
| 18 | + defaultThemeMode: ThemeMode.system, |
| 19 | + themes: getThemes(), |
24 | 20 | darkTheme: ThemeData( |
25 | | - backgroundColor: Colors.blue[700], |
26 | 21 | colorScheme: ColorScheme.fromSwatch().copyWith( |
| 22 | + background: Colors.blue[700], |
27 | 23 | secondary: Colors.yellow[700], |
28 | 24 | brightness: Brightness.dark, |
29 | 25 | ), |
30 | 26 | ), |
31 | 27 | lightTheme: ThemeData( |
32 | | - backgroundColor: Colors.blue[300], |
33 | 28 | colorScheme: ColorScheme.fromSwatch().copyWith( |
| 29 | + background: Colors.blue[300], |
34 | 30 | secondary: Colors.yellow[300], |
35 | 31 | brightness: Brightness.light, |
36 | 32 | ), |
37 | 33 | ), |
38 | | - builder: (context, regularTheme, darkTheme, themeMode) => MaterialApp( |
39 | | - navigatorKey: AppService.navigatorKey, |
40 | | - builder: (context, widget) => ResponsiveWrapper.builder( |
41 | | - ClampingScrollWrapper.builder(context, widget!), |
42 | | - maxWidth: 1400, |
43 | | - minWidth: 360, |
44 | | - defaultScale: true, |
45 | | - breakpoints: [ |
46 | | - const ResponsiveBreakpoint.resize(360, name: MOBILE), |
47 | | - const ResponsiveBreakpoint.autoScale(800, name: TABLET), |
48 | | - const ResponsiveBreakpoint.autoScale(1000, name: TABLET), |
49 | | - const ResponsiveBreakpoint.resize(1200, name: DESKTOP), |
50 | | - const ResponsiveBreakpoint.autoScale(2460, name: "4K"), |
51 | | - ], |
52 | | - ), |
53 | | - localizationsDelegates: const [ |
54 | | - Strings.delegate, |
55 | | - GlobalMaterialLocalizations.delegate, |
56 | | - GlobalWidgetsLocalizations.delegate |
57 | | - ], |
58 | | - supportedLocales: Strings.delegate.supportedLocales, |
59 | | - onGenerateTitle: (context) => Strings.of(context).appName, |
60 | | - debugShowCheckedModeBanner: false, |
61 | | - initialRoute: RoutePaths.splash, |
62 | | - theme: regularTheme, |
63 | | - darkTheme: darkTheme, |
64 | | - themeMode: themeMode, |
65 | | - onGenerateRoute: AppRouter.generateRoute), |
| 34 | + builder: (context, regularTheme, darkTheme, themeMode) { |
| 35 | + return MaterialApp( |
| 36 | + key: AppService.appKey, |
| 37 | + navigatorKey: AppService.navigatorKey, |
| 38 | + builder: (context, widget) => ResponsiveWrapper.builder( |
| 39 | + ClampingScrollWrapper.builder(context, widget!), |
| 40 | + maxWidth: 1400, |
| 41 | + minWidth: 360, |
| 42 | + defaultScale: true, |
| 43 | + breakpoints: [ |
| 44 | + const ResponsiveBreakpoint.resize(360, name: MOBILE), |
| 45 | + const ResponsiveBreakpoint.autoScale(800, name: TABLET), |
| 46 | + const ResponsiveBreakpoint.autoScale(1000, name: TABLET), |
| 47 | + const ResponsiveBreakpoint.resize(1200, name: DESKTOP), |
| 48 | + const ResponsiveBreakpoint.autoScale(2460, name: "4K"), |
| 49 | + ], |
| 50 | + ), |
| 51 | + localizationsDelegates: const [ |
| 52 | + Strings.delegate, |
| 53 | + GlobalMaterialLocalizations.delegate, |
| 54 | + GlobalWidgetsLocalizations.delegate |
| 55 | + ], |
| 56 | + supportedLocales: Strings.delegate.supportedLocales, |
| 57 | + onGenerateTitle: (context) => Strings.of(context).appName, |
| 58 | + debugShowCheckedModeBanner: false, |
| 59 | + initialRoute: RoutePaths.splash, |
| 60 | + theme: regularTheme, |
| 61 | + darkTheme: darkTheme, |
| 62 | + themeMode: themeMode, |
| 63 | + onGenerateRoute: AppRouter.generateRoute); |
| 64 | + }, |
66 | 65 | ); |
67 | 66 | } |
68 | 67 | } |
0 commit comments