feat: 首页单列模式

This commit is contained in:
guozhigq
2023-08-27 11:51:36 +08:00
parent 1d0b91f80b
commit b9e78bf2ec
10 changed files with 250 additions and 208 deletions

View File

@ -8,12 +8,14 @@ class SetSwitchItem extends StatefulWidget {
final String? subTitle;
final String? setKey;
final bool? defaultVal;
final Function? callFn;
const SetSwitchItem({
this.title,
this.subTitle,
this.setKey,
this.defaultVal,
this.callFn,
Key? key,
}) : super(key: key);
@ -32,12 +34,15 @@ class _SetSwitchItemState extends State<SetSwitchItem> {
val = Setting.get(widget.setKey, defaultValue: widget.defaultVal ?? false);
}
void switchChange(value) {
void switchChange(value) async {
val = value ?? !val;
Setting.put(widget.setKey, val);
await Setting.put(widget.setKey, val);
if (widget.setKey == SettingBoxKey.autoUpdate && value == true) {
Utils.checkUpdata();
}
if (widget.callFn != null) {
widget.callFn!.call(val);
}
setState(() {});
}