mirror of
https://github.com/stonega/tsacdop
synced 2024-12-16 02:11:44 +01:00
a6fc34e7bb
modified: android/app/build.gradle modified: android/app/src/main/AndroidManifest.xml new file: android/app/src/main/res/drawable/launch_background_night.xml new file: android/app/src/main/res/drawable/normal_background.xml new file: android/app/src/main/res/values-night/styles.xml modified: android/app/src/main/res/values/styles.xml new file: assets/fireside.jpg new file: assets/logo.png modified: lib/class/audiostate.dart modified: lib/class/fireside_data.dart modified: lib/class/podcastlocal.dart modified: lib/class/settingstate.dart modified: lib/episodes/episodedetail.dart modified: lib/episodes/episodedownload.dart modified: lib/home/appbar/about.dart modified: lib/home/appbar/addpodcast.dart modified: lib/home/appbar/importompl.dart modified: lib/home/appbar/popupmenu.dart modified: lib/home/audiopanel.dart modified: lib/home/audioplayer.dart modified: lib/home/homescroll.dart modified: lib/home/hometab.dart new file: lib/home/paly_history.dart modified: lib/local_storage/key_value_storage.dart modified: lib/local_storage/sqflite_localpodcast.dart modified: lib/main.dart modified: lib/podcasts/podcastdetail.dart modified: lib/podcasts/podcastgroup.dart modified: lib/podcasts/podcastlist.dart modified: lib/podcasts/podcastmanage.dart new file: lib/settings/settting.dart new file: lib/settings/theme.dart new file: lib/util/colorize.dart modified: lib/util/episodegrid.dart modified: pubspec.lock modified: pubspec.yaml
68 lines
1.6 KiB
Dart
68 lines
1.6 KiB
Dart
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:tsacdop/local_storage/key_value_storage.dart';
|
|
|
|
class SettingState extends ChangeNotifier {
|
|
KeyValueStorage themestorage = KeyValueStorage('themes');
|
|
KeyValueStorage accentstorage = KeyValueStorage('accents');
|
|
bool _isLoading;
|
|
bool get isLoagding => _isLoading;
|
|
|
|
Future initData() async {
|
|
await _getTheme();
|
|
await _getAccentSetColor();
|
|
}
|
|
|
|
ThemeMode _theme;
|
|
ThemeMode get theme => _theme;
|
|
set setTheme(ThemeMode mode) {
|
|
_theme = mode;
|
|
_saveTheme();
|
|
notifyListeners();
|
|
}
|
|
|
|
Color _accentSetColor;
|
|
Color get accentSetColor => _accentSetColor;
|
|
|
|
set setAccentColor(Color color) {
|
|
_accentSetColor = color;
|
|
_saveAccentSetColor();
|
|
notifyListeners();
|
|
}
|
|
|
|
@override
|
|
void addListener(VoidCallback listener) {
|
|
super.addListener(listener);
|
|
_getTheme();
|
|
_getAccentSetColor();
|
|
}
|
|
|
|
_getTheme() async {
|
|
int mode = await themestorage.getInt();
|
|
_theme = ThemeMode.values[mode];
|
|
}
|
|
|
|
_saveTheme() async {
|
|
await themestorage.saveInt(_theme.index);
|
|
}
|
|
|
|
_getAccentSetColor() async {
|
|
String colorString = await accentstorage.getString();
|
|
print(colorString);
|
|
if (colorString.isNotEmpty) {
|
|
int color = int.parse('FF' + colorString.toUpperCase(), radix: 16);
|
|
_accentSetColor = Color(color).withOpacity(1.0);
|
|
print(_accentSetColor.toString());
|
|
} else {
|
|
_accentSetColor = Colors.blue[400];
|
|
}
|
|
}
|
|
|
|
_saveAccentSetColor() async {
|
|
await accentstorage
|
|
.saveString(_accentSetColor.toString().substring(10, 16));
|
|
print(_accentSetColor.toString());
|
|
}
|
|
}
|