mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-09 10:00:27 +00:00
Make network auto control setting reactive with proper GetX observable
Co-authored-by: monkeyWie <[email protected]>
This commit is contained in:
1 parent
14df9490cf
commit
27dc7aea52
2 files changed
+14
-6
No files matched your search
@@ -1,15 +1,19 @@
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../../database/database.dart';
|
||||
import '../../../../util/updater.dart';
|
||||
|
||||
class SettingController extends GetxController {
|
||||
final tapStatues = <String, bool>{}.obs;
|
||||
final latestVersion = Rxn<VersionInfo>();
|
||||
final networkAutoControl = false.obs;
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
fetchLatestVersion();
|
||||
// Initialize network auto control setting
|
||||
networkAutoControl.value = Database.instance.getNetworkAutoControl();
|
||||
}
|
||||
|
||||
// set all tap status to false
|
||||
@@ -27,4 +31,10 @@ class SettingController extends GetxController {
|
||||
void fetchLatestVersion() async {
|
||||
latestVersion.value = await checkUpdate();
|
||||
}
|
||||
|
||||
// update network auto control setting
|
||||
void updateNetworkAutoControl(bool value) {
|
||||
networkAutoControl.value = value;
|
||||
Database.instance.saveNetworkAutoControl(value);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user