feat: 首页单列模式
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:pilipala/models/common/theme_type.dart';
|
||||
@ -75,6 +76,13 @@ class _StyleSettingState extends State<StyleSetting> {
|
||||
setKey: SettingBoxKey.iosTransition,
|
||||
defaultVal: false,
|
||||
),
|
||||
SetSwitchItem(
|
||||
title: '首页单列',
|
||||
subTitle: '每行展示一个内容卡片',
|
||||
setKey: SettingBoxKey.enableSingleRow,
|
||||
defaultVal: false,
|
||||
callFn: (val) => {SmartDialog.showToast('下次启动时生效')},
|
||||
),
|
||||
ListTile(
|
||||
dense: false,
|
||||
onTap: () {
|
||||
|
||||
@ -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(() {});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user