-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Muska-Ami/dev
Dark theme(beta)
- Loading branch information
Showing
18 changed files
with
413 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:nyalcf/prefs/LauncherSettingPrefs.dart'; | ||
import 'package:package_info_plus/package_info_plus.dart'; | ||
|
||
class DSettingLauncherController extends GetxController { | ||
var app_name = ''.obs; | ||
var app_version = ''.obs; | ||
var app_package_name = ''.obs; | ||
|
||
var theme_auto = false.obs; | ||
var theme_dark = false.obs; | ||
var theme_light_seed = ''.obs; | ||
var theme_light_seed_enable = false.obs; | ||
|
||
load() async { | ||
final packageInfo = await PackageInfo.fromPlatform(); | ||
app_name.value = packageInfo.appName; | ||
app_version.value = packageInfo.version; | ||
app_package_name.value = packageInfo.packageName; | ||
|
||
final settings = await LauncherSettingPrefs.getInfo(); | ||
theme_auto.value = settings.theme_auto; | ||
theme_dark.value = settings.theme_dark; | ||
theme_light_seed.value = settings.theme_light_seed; | ||
theme_light_seed_enable.value = settings.theme_light_seed_enable; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,51 @@ | ||
class SettingStorage {} | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
|
||
import 'package:nyalcf/model/Setting.dart'; | ||
import 'package:nyalcf/util/FileIO.dart'; | ||
|
||
class SettingStorage { | ||
static final _path = FileIO.support_path; | ||
|
||
static void init() { | ||
_path.then((path) { | ||
if (!Directory(path).existsSync()) Directory(path).createSync(); | ||
final infoF = File('${path}/settings.json'); | ||
if (!infoF.existsSync()) { | ||
Map<String, dynamic> json = { | ||
'theme': { | ||
'auto': true, | ||
'dark': { | ||
'enable': false, | ||
}, | ||
'light': { | ||
'seed': { | ||
'enable': false, | ||
'value': '66ccff', | ||
}, | ||
} | ||
}, | ||
}; | ||
infoF.writeAsStringSync(jsonEncode(json)); | ||
} | ||
}); | ||
} | ||
|
||
/// 保存数据 | ||
static Future<void> save(Setting data) async { | ||
final String write_data = jsonEncode(data); | ||
await File('${await _path}/settings.json') | ||
.writeAsString(write_data, encoding: utf8); | ||
} | ||
|
||
/// 读取数据 | ||
static Future<Setting?> read() async { | ||
try { | ||
final String result = | ||
File('${await _path}/settings.json').readAsStringSync(encoding: utf8); | ||
return Setting.fromJson(jsonDecode(result)); | ||
} catch (e) { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
class Setting { | ||
Setting({ | ||
required this.theme_auto, | ||
required this.theme_dark, | ||
required this.theme_light_seed_enable, | ||
required this.theme_light_seed, | ||
}); | ||
|
||
final bool theme_auto; | ||
final bool theme_dark; | ||
final bool theme_light_seed_enable; | ||
final String theme_light_seed; | ||
|
||
Map<String, dynamic> toJson() => { | ||
'theme': { | ||
'auto': theme_auto, | ||
'dark': { | ||
'enable': theme_dark, | ||
}, | ||
'light': { | ||
'seed': { | ||
'enable': theme_light_seed_enable, | ||
'value': theme_light_seed, | ||
}, | ||
} | ||
}, | ||
}; | ||
|
||
Setting.fromJson(Map<String, dynamic> json) | ||
: theme_auto = json['theme']['auto'], | ||
theme_dark = json['theme']['dark']['enable'], | ||
theme_light_seed = json['theme']['light']['seed']['value'], | ||
theme_light_seed_enable = json['theme']['light']['seed']['enable']; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.