main.dart formatting / commenting
This commit is contained in:
parent
72e27525e7
commit
b203a1aa6c
@ -21,6 +21,7 @@ void main() async {
|
||||
));
|
||||
}
|
||||
|
||||
/// Main app page loader and theme manager
|
||||
class MainApp extends StatefulWidget {
|
||||
final int? initialPage;
|
||||
|
||||
@ -31,6 +32,24 @@ class MainApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MainAppState extends State<MainApp> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// prevent landscape mode (it looks bad)
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
|
||||
return MaterialApp(
|
||||
title: 'Job Link',
|
||||
themeMode: themeMode,
|
||||
darkTheme: _darkThemeData(),
|
||||
theme: _lightThemeData(),
|
||||
home: Home(themeCallback: _switchTheme, initialPage: widget.initialPage),
|
||||
);
|
||||
}
|
||||
|
||||
/// Switch the theme mode based on the currently selected theme and the system prefs
|
||||
void _switchTheme() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
if (MediaQuery.of(context).platformBrightness == Brightness.dark &&
|
||||
@ -58,17 +77,9 @@ class _MainAppState extends State<MainApp> {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setPreferredOrientations([
|
||||
DeviceOrientation.portraitUp,
|
||||
DeviceOrientation.portraitDown,
|
||||
]);
|
||||
|
||||
return MaterialApp(
|
||||
title: 'Job Link',
|
||||
themeMode: themeMode,
|
||||
darkTheme: ThemeData(
|
||||
/// Static theme for dark mode
|
||||
ThemeData _darkThemeData() {
|
||||
return ThemeData(
|
||||
scaffoldBackgroundColor: const Color(0xFF121212),
|
||||
colorScheme: ColorScheme.dark(
|
||||
brightness: Brightness.dark,
|
||||
@ -99,8 +110,12 @@ class _MainAppState extends State<MainApp> {
|
||||
filled: true,
|
||||
),
|
||||
),
|
||||
),
|
||||
theme: ThemeData(
|
||||
);
|
||||
}
|
||||
|
||||
/// Static theme for light mode
|
||||
ThemeData _lightThemeData() {
|
||||
return ThemeData(
|
||||
scaffoldBackgroundColor: Colors.grey.shade300,
|
||||
colorScheme: ColorScheme.light(
|
||||
brightness: Brightness.light,
|
||||
@ -132,8 +147,6 @@ class _MainAppState extends State<MainApp> {
|
||||
),
|
||||
),
|
||||
useMaterial3: true,
|
||||
),
|
||||
home: Home(themeCallback: _switchTheme, initialPage: widget.initialPage),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user