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 {
|
class MainApp extends StatefulWidget {
|
||||||
final int? initialPage;
|
final int? initialPage;
|
||||||
|
|
||||||
@ -31,6 +32,24 @@ class MainApp extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _MainAppState extends State<MainApp> {
|
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 {
|
void _switchTheme() async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
if (MediaQuery.of(context).platformBrightness == Brightness.dark &&
|
if (MediaQuery.of(context).platformBrightness == Brightness.dark &&
|
||||||
@ -58,17 +77,9 @@ class _MainAppState extends State<MainApp> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
/// Static theme for dark mode
|
||||||
Widget build(BuildContext context) {
|
ThemeData _darkThemeData() {
|
||||||
SystemChrome.setPreferredOrientations([
|
return ThemeData(
|
||||||
DeviceOrientation.portraitUp,
|
|
||||||
DeviceOrientation.portraitDown,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return MaterialApp(
|
|
||||||
title: 'Job Link',
|
|
||||||
themeMode: themeMode,
|
|
||||||
darkTheme: ThemeData(
|
|
||||||
scaffoldBackgroundColor: const Color(0xFF121212),
|
scaffoldBackgroundColor: const Color(0xFF121212),
|
||||||
colorScheme: ColorScheme.dark(
|
colorScheme: ColorScheme.dark(
|
||||||
brightness: Brightness.dark,
|
brightness: Brightness.dark,
|
||||||
@ -99,8 +110,12 @@ class _MainAppState extends State<MainApp> {
|
|||||||
filled: true,
|
filled: true,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
theme: ThemeData(
|
}
|
||||||
|
|
||||||
|
/// Static theme for light mode
|
||||||
|
ThemeData _lightThemeData() {
|
||||||
|
return ThemeData(
|
||||||
scaffoldBackgroundColor: Colors.grey.shade300,
|
scaffoldBackgroundColor: Colors.grey.shade300,
|
||||||
colorScheme: ColorScheme.light(
|
colorScheme: ColorScheme.light(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
@ -132,8 +147,6 @@ class _MainAppState extends State<MainApp> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
|
||||||
home: Home(themeCallback: _switchTheme, initialPage: widget.initialPage),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user