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,82 +77,76 @@ class _MainAppState extends State<MainApp> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
/// Static theme for dark mode
|
||||||
Widget build(BuildContext context) {
|
ThemeData _darkThemeData() {
|
||||||
SystemChrome.setPreferredOrientations([
|
return ThemeData(
|
||||||
DeviceOrientation.portraitUp,
|
scaffoldBackgroundColor: const Color(0xFF121212),
|
||||||
DeviceOrientation.portraitDown,
|
colorScheme: ColorScheme.dark(
|
||||||
]);
|
brightness: Brightness.dark,
|
||||||
|
primary: Colors.blue.shade700,
|
||||||
|
onPrimary: Colors.white,
|
||||||
|
secondary: Colors.blue.shade900,
|
||||||
|
onSecondary: Colors.white,
|
||||||
|
surface: const Color.fromARGB(255, 31, 31, 31),
|
||||||
|
surfaceContainer: const Color.fromARGB(255, 46, 46, 46),
|
||||||
|
tertiary: Colors.green.shade900,
|
||||||
|
),
|
||||||
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
|
useMaterial3: true,
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.grey.withOpacity(0.1),
|
||||||
|
labelStyle: const TextStyle(color: Colors.grey),
|
||||||
|
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.focused) &&
|
||||||
|
!states.contains(WidgetState.hovered)) {
|
||||||
|
return TextStyle(color: Colors.blue.shade700);
|
||||||
|
}
|
||||||
|
return const TextStyle(color: Colors.grey);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
dropdownMenuTheme: const DropdownMenuThemeData(
|
||||||
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
|
filled: true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return MaterialApp(
|
/// Static theme for light mode
|
||||||
title: 'Job Link',
|
ThemeData _lightThemeData() {
|
||||||
themeMode: themeMode,
|
return ThemeData(
|
||||||
darkTheme: ThemeData(
|
scaffoldBackgroundColor: Colors.grey.shade300,
|
||||||
scaffoldBackgroundColor: const Color(0xFF121212),
|
colorScheme: ColorScheme.light(
|
||||||
colorScheme: ColorScheme.dark(
|
brightness: Brightness.light,
|
||||||
brightness: Brightness.dark,
|
primary: Colors.blue.shade700,
|
||||||
primary: Colors.blue.shade700,
|
onPrimary: Colors.white,
|
||||||
onPrimary: Colors.white,
|
secondary: Colors.blue.shade300,
|
||||||
secondary: Colors.blue.shade900,
|
onSecondary: Colors.black,
|
||||||
onSecondary: Colors.white,
|
surface: Colors.grey.shade100,
|
||||||
surface: const Color.fromARGB(255, 31, 31, 31),
|
surfaceContainer: Colors.grey.shade200,
|
||||||
surfaceContainer: const Color.fromARGB(255, 46, 46, 46),
|
tertiary: Colors.green,
|
||||||
tertiary: Colors.green.shade900,
|
),
|
||||||
),
|
iconTheme: const IconThemeData(color: Colors.black),
|
||||||
iconTheme: const IconThemeData(color: Colors.white),
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
useMaterial3: true,
|
// border: OutlineInputBorder(),
|
||||||
|
filled: true,
|
||||||
|
fillColor: Colors.grey.withOpacity(0.25),
|
||||||
|
labelStyle: TextStyle(color: Colors.grey.shade700),
|
||||||
|
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
||||||
|
if (states.contains(WidgetState.focused) &&
|
||||||
|
!states.contains(WidgetState.hovered)) {
|
||||||
|
return TextStyle(color: Colors.blue.shade700);
|
||||||
|
}
|
||||||
|
return TextStyle(color: Colors.grey.shade700);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
dropdownMenuTheme: const DropdownMenuThemeData(
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
inputDecorationTheme: InputDecorationTheme(
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: Colors.grey.withOpacity(0.1),
|
|
||||||
labelStyle: const TextStyle(color: Colors.grey),
|
|
||||||
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
|
||||||
if (states.contains(WidgetState.focused) &&
|
|
||||||
!states.contains(WidgetState.hovered)) {
|
|
||||||
return TextStyle(color: Colors.blue.shade700);
|
|
||||||
}
|
|
||||||
return const TextStyle(color: Colors.grey);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
dropdownMenuTheme: const DropdownMenuThemeData(
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
theme: ThemeData(
|
useMaterial3: true,
|
||||||
scaffoldBackgroundColor: Colors.grey.shade300,
|
|
||||||
colorScheme: ColorScheme.light(
|
|
||||||
brightness: Brightness.light,
|
|
||||||
primary: Colors.blue.shade700,
|
|
||||||
onPrimary: Colors.white,
|
|
||||||
secondary: Colors.blue.shade300,
|
|
||||||
onSecondary: Colors.black,
|
|
||||||
surface: Colors.grey.shade100,
|
|
||||||
surfaceContainer: Colors.grey.shade200,
|
|
||||||
tertiary: Colors.green,
|
|
||||||
),
|
|
||||||
iconTheme: const IconThemeData(color: Colors.black),
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
// border: OutlineInputBorder(),
|
|
||||||
filled: true,
|
|
||||||
fillColor: Colors.grey.withOpacity(0.25),
|
|
||||||
labelStyle: TextStyle(color: Colors.grey.shade700),
|
|
||||||
floatingLabelStyle: WidgetStateTextStyle.resolveWith((states) {
|
|
||||||
if (states.contains(WidgetState.focused) &&
|
|
||||||
!states.contains(WidgetState.hovered)) {
|
|
||||||
return TextStyle(color: Colors.blue.shade700);
|
|
||||||
}
|
|
||||||
return TextStyle(color: Colors.grey.shade700);
|
|
||||||
}),
|
|
||||||
),
|
|
||||||
dropdownMenuTheme: const DropdownMenuThemeData(
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
useMaterial3: true,
|
|
||||||
),
|
|
||||||
home: Home(themeCallback: _switchTheme, initialPage: widget.initialPage),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user