pikapika/lib/basic/config/CategoriesColumnCount.dart

49 lines
1.3 KiB
Dart
Raw Normal View History

2022-09-05 03:36:25 +00:00
/// 多线程下载并发数
import 'package:event/event.dart';
import 'package:flutter/material.dart';
import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/Method.dart';
String _propertyName = "categoriesColumnCount";
late int categoriesColumnCount;
Event categoriesColumnCountEvent = Event();
Future initCategoriesColumnCount() async {
categoriesColumnCount =
int.parse(await method.loadProperty(_propertyName, "0"));
}
Widget categoriesColumnCountSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: const Text(
2023-05-08 09:57:28 +00:00
"首页分类展示列数",
2022-09-05 03:36:25 +00:00
),
2023-05-08 09:57:28 +00:00
subtitle:
Text(categoriesColumnCount == 0 ? "自动" : "$categoriesColumnCount"),
2022-09-05 03:36:25 +00:00
onTap: () async {
int? value = await chooseMapDialog(
context,
{
"自动": 0,
"2": 2,
"3": 3,
"4": 4,
"5": 5,
},
2023-05-08 09:57:28 +00:00
"选择首页分类展示列数");
2022-09-05 03:36:25 +00:00
if (value != null) {
2022-09-14 12:50:07 +00:00
await method.saveProperty(_propertyName, "$value");
2022-09-05 03:36:25 +00:00
categoriesColumnCount = value;
setState(() {});
categoriesColumnCountEvent.broadcast();
}
},
);
},
);
}