import 'package:flutter/material.dart'; import 'package:plasmoid/preferences.dart'; class AppSettings extends ChangeNotifier { bool _showTags = true; bool _showIcons = true; bool _colorIcons = true; bool _darkTheme = false; bool _sortLastUsed = true; bool _autoFocus = true; bool _showStatusIcons = true; bool _hideDemoted = false; bool get showTags => _showTags; bool get showIcons => _showIcons; bool get colorIcons => _colorIcons; bool get darkTheme => _darkTheme; bool get sortLastUsed => _sortLastUsed; bool get autoFocus => _autoFocus; bool get showStatusIcons => _showStatusIcons; bool get hideDemoted => _hideDemoted; final SharedPreferencesService _prefsService = SharedPreferencesService(); AppSettings() { _loadSettings(); } Future _loadSettings() async { _showTags = _prefsService.getBool('showTags', true); _showIcons = _prefsService.getBool('showIcons', true); _colorIcons = _prefsService.getBool('colorIcons', true); _darkTheme = _prefsService.getBool('darkTheme', false); _sortLastUsed = _prefsService.getBool('sortLastUsed', true); _autoFocus = _prefsService.getBool('autoFocus', true); _showStatusIcons = _prefsService.getBool('showStatusIcons', true); _hideDemoted = _prefsService.getBool('hideDemoted', false); notifyListeners(); } Future updateSetting(String key, bool value) async { switch (key) { case 'showTags': _showTags = value; break; case 'showIcons': _showIcons = value; break; case 'colorIcons': _colorIcons = value; break; case 'darkTheme': _darkTheme = value; break; case 'sortLastUsed': _sortLastUsed = value; break; case 'autoFocus': _autoFocus = value; break; case 'showStatusIcons': _showStatusIcons = value; break; case 'hideDemoted': _hideDemoted = value; break; } await _prefsService.setBool(key, value); notifyListeners(); // Notify listeners after updating the setting } }