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

@ -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: () {

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(() {});
}