Basic Dark theme and option for theme in settings
This commit is contained in:
parent
9a1247de5f
commit
9aea09d582
lib
@ -44,6 +44,7 @@ class _AppState extends State<App> {
|
|||||||
context,
|
context,
|
||||||
controller: tabController,
|
controller: tabController,
|
||||||
navBarStyle: NavBarStyle.style6,
|
navBarStyle: NavBarStyle.style6,
|
||||||
|
backgroundColor: Theme.of(context).colorScheme.onSecondary,
|
||||||
decoration: const NavBarDecoration(
|
decoration: const NavBarDecoration(
|
||||||
border: Border.symmetric(vertical: BorderSide.none, horizontal: BorderSide(color: Colors.grey, width: 1))
|
border: Border.symmetric(vertical: BorderSide.none, horizontal: BorderSide(color: Colors.grey, width: 1))
|
||||||
),
|
),
|
||||||
@ -57,13 +58,13 @@ class _AppState extends State<App> {
|
|||||||
items: [
|
items: [
|
||||||
PersistentBottomNavBarItem(
|
PersistentBottomNavBarItem(
|
||||||
activeColorPrimary: Theme.of(context).primaryColor,
|
activeColorPrimary: Theme.of(context).primaryColor,
|
||||||
inactiveColorPrimary: Theme.of(context).disabledColor,
|
inactiveColorPrimary: Theme.of(context).colorScheme.secondary,
|
||||||
icon: const Icon(Icons.calendar_month),
|
icon: const Icon(Icons.calendar_month),
|
||||||
title: "Vertretung"
|
title: "Vertretung"
|
||||||
),
|
),
|
||||||
PersistentBottomNavBarItem(
|
PersistentBottomNavBarItem(
|
||||||
activeColorPrimary: Theme.of(context).primaryColor,
|
activeColorPrimary: Theme.of(context).primaryColor,
|
||||||
inactiveColorPrimary: Theme.of(context).disabledColor,
|
inactiveColorPrimary: Theme.of(context).colorScheme.secondary,
|
||||||
icon: Consumer<ChatListProps>(
|
icon: Consumer<ChatListProps>(
|
||||||
builder: (context, value, child) {
|
builder: (context, value, child) {
|
||||||
if(value.primaryLoading()) return const Icon(Icons.chat);
|
if(value.primaryLoading()) return const Icon(Icons.chat);
|
||||||
@ -86,13 +87,13 @@ class _AppState extends State<App> {
|
|||||||
),
|
),
|
||||||
PersistentBottomNavBarItem(
|
PersistentBottomNavBarItem(
|
||||||
activeColorPrimary: Theme.of(context).primaryColor,
|
activeColorPrimary: Theme.of(context).primaryColor,
|
||||||
inactiveColorPrimary: Theme.of(context).disabledColor,
|
inactiveColorPrimary: Theme.of(context).colorScheme.secondary,
|
||||||
icon: const Icon(Icons.folder),
|
icon: const Icon(Icons.folder),
|
||||||
title: "Dateien"
|
title: "Dateien"
|
||||||
),
|
),
|
||||||
PersistentBottomNavBarItem(
|
PersistentBottomNavBarItem(
|
||||||
activeColorPrimary: Theme.of(context).primaryColor,
|
activeColorPrimary: Theme.of(context).primaryColor,
|
||||||
inactiveColorPrimary: Theme.of(context).disabledColor,
|
inactiveColorPrimary: Theme.of(context).colorScheme.secondary,
|
||||||
icon: const Icon(Icons.more_horiz),
|
icon: const Icon(Icons.more_horiz),
|
||||||
title: "Mehr"
|
title: "Mehr"
|
||||||
),
|
),
|
||||||
|
32
lib/data/appTheme.dart
Normal file
32
lib/data/appTheme.dart
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class AppTheme extends ChangeNotifier {
|
||||||
|
ThemeMode _mode = ThemeMode.system;
|
||||||
|
ThemeMode get getMode => _mode;
|
||||||
|
|
||||||
|
void setTheme(ThemeMode newMode) {
|
||||||
|
_mode = newMode;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
static ThemeModeDisplay getDisplayOptions(ThemeMode theme) {
|
||||||
|
switch(theme) {
|
||||||
|
case ThemeMode.system:
|
||||||
|
return ThemeModeDisplay(icon: Icons.auto_awesome, displayName: "Systemvorgabe");
|
||||||
|
|
||||||
|
case ThemeMode.light:
|
||||||
|
return ThemeModeDisplay(icon: Icons.dark_mode_outlined, displayName: "Hell");
|
||||||
|
|
||||||
|
case ThemeMode.dark:
|
||||||
|
return ThemeModeDisplay(icon: Icons.dark_mode, displayName: "Dunkel");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ThemeModeDisplay {
|
||||||
|
final IconData icon;
|
||||||
|
final String displayName;
|
||||||
|
|
||||||
|
ThemeModeDisplay({required this.icon, required this.displayName});
|
||||||
|
}
|
@ -3,6 +3,7 @@ import 'dart:io';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:jiffy/jiffy.dart';
|
import 'package:jiffy/jiffy.dart';
|
||||||
|
import 'package:marianum_mobile/data/appTheme.dart';
|
||||||
import 'package:marianum_mobile/data/timetable/timetableProps.dart';
|
import 'package:marianum_mobile/data/timetable/timetableProps.dart';
|
||||||
import 'package:marianum_mobile/screen/login/login.dart';
|
import 'package:marianum_mobile/screen/login/login.dart';
|
||||||
import 'package:marianum_mobile/widget/errorView.dart';
|
import 'package:marianum_mobile/widget/errorView.dart';
|
||||||
@ -30,6 +31,7 @@ Future<void> main() async {
|
|||||||
MultiProvider(
|
MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider(create: (context) => AccountModel()),
|
ChangeNotifierProvider(create: (context) => AccountModel()),
|
||||||
|
ChangeNotifierProvider(create: (context) => AppTheme()),
|
||||||
ChangeNotifierProvider(create: (context) => TimetableProps()),
|
ChangeNotifierProvider(create: (context) => TimetableProps()),
|
||||||
ChangeNotifierProvider(create: (context) => ChatListProps()),
|
ChangeNotifierProvider(create: (context) => ChatListProps()),
|
||||||
ChangeNotifierProvider(create: (context) => ChatProps()),
|
ChangeNotifierProvider(create: (context) => ChatProps()),
|
||||||
@ -70,6 +72,10 @@ class _MainState extends State<Main> {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
|
||||||
|
|
||||||
|
return Directionality(
|
||||||
|
textDirection: TextDirection.ltr,
|
||||||
|
child: Consumer<AppTheme>(
|
||||||
|
builder: (context, value, child) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
localizationsDelegates: const [
|
localizationsDelegates: const [
|
||||||
@ -84,6 +90,8 @@ class _MainState extends State<Main> {
|
|||||||
|
|
||||||
|
|
||||||
title: 'Marianum Fulda',
|
title: 'Marianum Fulda',
|
||||||
|
|
||||||
|
themeMode: value.getMode,
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
primaryColor: marianumRed,
|
primaryColor: marianumRed,
|
||||||
@ -97,7 +105,7 @@ class _MainState extends State<Main> {
|
|||||||
onBackground: Colors.black,
|
onBackground: Colors.black,
|
||||||
error: marianumRed,
|
error: marianumRed,
|
||||||
background: Colors.white,
|
background: Colors.white,
|
||||||
secondary: marianumRed,
|
secondary: Colors.grey,
|
||||||
primary: marianumRed,
|
primary: marianumRed,
|
||||||
),
|
),
|
||||||
hintColor: marianumRed,
|
hintColor: marianumRed,
|
||||||
@ -112,6 +120,35 @@ class _MainState extends State<Main> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
darkTheme: ThemeData(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
primaryColor: marianumRed,
|
||||||
|
colorScheme: const ColorScheme(
|
||||||
|
brightness: Brightness.dark,
|
||||||
|
surface: Colors.white,
|
||||||
|
onSurface: Colors.white,
|
||||||
|
onSecondary: Colors.black,
|
||||||
|
onPrimary: Colors.black,
|
||||||
|
onError: marianumRed,
|
||||||
|
onBackground: Colors.black,
|
||||||
|
error: marianumRed,
|
||||||
|
background: Colors.black,
|
||||||
|
secondary: Colors.grey,
|
||||||
|
primary: marianumRed,
|
||||||
|
),
|
||||||
|
hintColor: marianumRed,
|
||||||
|
inputDecorationTheme: const InputDecorationTheme(
|
||||||
|
border: UnderlineInputBorder(borderSide: BorderSide(color: marianumRed)),
|
||||||
|
),
|
||||||
|
appBarTheme: const AppBarTheme(
|
||||||
|
backgroundColor: marianumRed,
|
||||||
|
),
|
||||||
|
progressIndicatorTheme: const ProgressIndicatorThemeData(
|
||||||
|
color: marianumRed,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
|
||||||
home: FutureBuilder<SharedPreferences>(
|
home: FutureBuilder<SharedPreferences>(
|
||||||
future: _storage,
|
future: _storage,
|
||||||
builder: (BuildContext context, AsyncSnapshot<SharedPreferences> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<SharedPreferences> snapshot) {
|
||||||
@ -128,5 +165,8 @@ class _MainState extends State<Main> {
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
|||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../data/accountModel.dart';
|
import '../../data/accountModel.dart';
|
||||||
|
import '../../data/appTheme.dart';
|
||||||
import 'debug/debugOverview.dart';
|
import 'debug/debugOverview.dart';
|
||||||
|
|
||||||
class Settings extends StatefulWidget {
|
class Settings extends StatefulWidget {
|
||||||
@ -72,6 +73,35 @@ class _SettingsState extends State<Settings> {
|
|||||||
|
|
||||||
const Divider(),
|
const Divider(),
|
||||||
|
|
||||||
|
Consumer<AppTheme>(
|
||||||
|
builder: (context, value, child) {
|
||||||
|
return ListTile(
|
||||||
|
leading: const Icon(Icons.dark_mode),
|
||||||
|
title: const Text("Farbgebung"),
|
||||||
|
trailing: DropdownButton<ThemeMode>(
|
||||||
|
value: value.getMode,
|
||||||
|
icon: const Icon(Icons.arrow_drop_down),
|
||||||
|
items: ThemeMode.values.map((e) => DropdownMenuItem<ThemeMode>(
|
||||||
|
value: e,
|
||||||
|
enabled: e != value.getMode,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
Icon(AppTheme.getDisplayOptions(e).icon),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text(AppTheme.getDisplayOptions(e).displayName),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)).toList(),
|
||||||
|
onChanged: (e) {
|
||||||
|
Provider.of<AppTheme>(context, listen: false).setTheme(e ?? ThemeMode.system);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
|
||||||
|
const Divider(),
|
||||||
|
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.info),
|
leading: const Icon(Icons.info),
|
||||||
title: const Text("Informationen und Lizenzen"),
|
title: const Text("Informationen und Lizenzen"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user