add setting page

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2022-08-13 12:43:35 +08:00
parent f812adedff
commit 5887334c2e
8 changed files with 1066 additions and 460 deletions

View File

@@ -55,7 +55,6 @@ class MyTheme {
bool isDarkTheme() {
final isDark = "Y" == Get.find<SharedPreferences>().getString("darkTheme");
debugPrint("current is dark theme: $isDark");
return isDark;
}
@@ -482,3 +481,35 @@ String translate(String name) {
}
return platformFFI.translate(name, localeName);
}
bool option2bool(String key, String value) {
bool res;
if (key.startsWith("enable-")) {
res = value != "N";
} else if (key.startsWith("allow-") ||
key == "stop-service" ||
key == "direct-server" ||
key == "stop-rendezvous-service") {
res = value == "Y";
} else {
assert(false);
res = value != "N";
}
return res;
}
String bool2option(String key, bool option) {
String res;
if (key.startsWith('enable-')) {
res = option ? '' : 'N';
} else if (key.startsWith('allow-') ||
key == "stop-service" ||
key == "direct-server" ||
key == "stop-rendezvous-service") {
res = option ? 'Y' : '';
} else {
assert(false);
res = option ? 'Y' : 'N';
}
return res;
}