Compare commits

..

No commits in common. "main" and "v0.2.0" have entirely different histories.
main ... v0.2.0

2 changed files with 71 additions and 85 deletions

View File

@ -263,7 +263,6 @@ void main() async {
'name', name, 'name', name,
'description', description, 'description', description,
'website', website, 'website', website,
'contactName', "contactName",
'contactEmail', "contactEmail", 'contactEmail', "contactEmail",
'contactPhone', "contactPhone", 'contactPhone', "contactPhone",
'locationName', "locationName", 'locationName', "locationName",

View File

@ -21,7 +21,6 @@ void main() async {
)); ));
} }
/// Main app page loader and theme manager
class MainApp extends StatefulWidget { class MainApp extends StatefulWidget {
final int? initialPage; final int? initialPage;
@ -32,24 +31,6 @@ 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 &&
@ -77,76 +58,82 @@ class _MainAppState extends State<MainApp> {
} }
} }
/// Static theme for dark mode @override
ThemeData _darkThemeData() { Widget build(BuildContext context) {
return ThemeData( SystemChrome.setPreferredOrientations([
scaffoldBackgroundColor: const Color(0xFF121212), DeviceOrientation.portraitUp,
colorScheme: ColorScheme.dark( DeviceOrientation.portraitDown,
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,
),
),
);
}
/// Static theme for light mode return MaterialApp(
ThemeData _lightThemeData() { title: 'Job Link',
return ThemeData( themeMode: themeMode,
scaffoldBackgroundColor: Colors.grey.shade300, darkTheme: ThemeData(
colorScheme: ColorScheme.light( scaffoldBackgroundColor: const Color(0xFF121212),
brightness: Brightness.light, colorScheme: ColorScheme.dark(
primary: Colors.blue.shade700, brightness: Brightness.dark,
onPrimary: Colors.white, primary: Colors.blue.shade700,
secondary: Colors.blue.shade300, onPrimary: Colors.white,
onSecondary: Colors.black, secondary: Colors.blue.shade900,
surface: Colors.grey.shade100, onSecondary: Colors.white,
surfaceContainer: Colors.grey.shade200, surface: const Color.fromARGB(255, 31, 31, 31),
tertiary: Colors.green, surfaceContainer: const Color.fromARGB(255, 46, 46, 46),
), tertiary: Colors.green.shade900,
iconTheme: const IconThemeData(color: Colors.black), ),
inputDecorationTheme: InputDecorationTheme( iconTheme: const IconThemeData(color: Colors.white),
// border: OutlineInputBorder(), useMaterial3: true,
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,
),
), ),
), ),
useMaterial3: true, theme: ThemeData(
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),
); );
} }
} }