mirror of
https://github.com/inventree/inventree-app.git
synced 2025-06-15 11:45:31 +00:00
Adds "dark mode" support (#317)
* Adds "dark mode" support - Uses adaptive_theme package * CI fixes * More fixes * Update release notes
This commit is contained in:
@ -1,7 +1,9 @@
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
|
||||
import "package:adaptive_theme/adaptive_theme.dart";
|
||||
import "package:font_awesome_flutter/font_awesome_flutter.dart";
|
||||
import "package:flutter_localized_locales/flutter_localized_locales.dart";
|
||||
import "package:one_context/one_context.dart";
|
||||
|
||||
import "package:inventree/api_form.dart";
|
||||
import "package:inventree/l10.dart";
|
||||
@ -9,6 +11,8 @@ import "package:inventree/l10n/supported_locales.dart";
|
||||
import "package:inventree/main.dart";
|
||||
import "package:inventree/preferences.dart";
|
||||
|
||||
import "package:inventree/widget/progress.dart";
|
||||
|
||||
|
||||
class InvenTreeAppSettingsWidget extends StatefulWidget {
|
||||
@override
|
||||
@ -28,23 +32,32 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
bool reportErrors = true;
|
||||
bool strictHttps = false;
|
||||
|
||||
bool darkMode = false;
|
||||
|
||||
Locale? locale;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
loadSettings();
|
||||
loadSettings(OneContext().context!);
|
||||
}
|
||||
|
||||
Future <void> loadSettings() async {
|
||||
Future <void> loadSettings(BuildContext context) async {
|
||||
|
||||
showLoadingOverlay(context);
|
||||
|
||||
barcodeSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_BARCODE, true) as bool;
|
||||
serverSounds = await InvenTreeSettingsManager().getValue(INV_SOUNDS_SERVER, true) as bool;
|
||||
reportErrors = await InvenTreeSettingsManager().getValue(INV_REPORT_ERRORS, true) as bool;
|
||||
strictHttps = await InvenTreeSettingsManager().getValue(INV_STRICT_HTTPS, false) as bool;
|
||||
|
||||
darkMode = AdaptiveTheme.of(context).mode.isDark;
|
||||
|
||||
locale = await InvenTreeSettingsManager().getSelectedLocale();
|
||||
|
||||
hideLoadingOverlay();
|
||||
|
||||
if (mounted) {
|
||||
setState(() {});
|
||||
}
|
||||
@ -168,6 +181,24 @@ class _InvenTreeAppSettingsState extends State<InvenTreeAppSettingsWidget> {
|
||||
),
|
||||
leading: FaIcon(FontAwesomeIcons.mobile),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().darkMode),
|
||||
subtitle: Text(L10().darkModeEnable),
|
||||
leading: FaIcon(FontAwesomeIcons.moon),
|
||||
trailing: Switch(
|
||||
value: darkMode,
|
||||
onChanged: (bool value) {
|
||||
if (value) {
|
||||
AdaptiveTheme.of(context).setDark();
|
||||
} else {
|
||||
AdaptiveTheme.of(context).setLight();
|
||||
}
|
||||
setState(() {
|
||||
darkMode = value;
|
||||
});
|
||||
}
|
||||
)
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10().strictHttps),
|
||||
subtitle: Text(L10().strictHttpsDetails),
|
||||
|
Reference in New Issue
Block a user