pikapika/lib/basic/config/DownloadThreadCount.dart

43 lines
1.2 KiB
Dart
Raw Normal View History

2021-11-04 05:56:25 +00:00
/// 多线程下载并发数
2021-10-31 06:01:19 +00:00
import 'package:flutter/material.dart';
2021-11-11 03:00:38 +00:00
import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/Method.dart';
2021-10-31 06:01:19 +00:00
2022-07-09 07:11:26 +00:00
import 'IsPro.dart';
2021-10-31 06:01:19 +00:00
late int _downloadThreadCount;
const _values = [1, 2, 3, 4, 5];
Future initDownloadThreadCount() async {
_downloadThreadCount = await method.loadDownloadThreadCount();
}
Widget downloadThreadCountSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
2022-07-09 07:11:26 +00:00
title: Text(
"下载线程数" + (!isPro ? "(发电)" : ""),
style: TextStyle(
color: !isPro ? Colors.grey : null,
),
),
2021-10-31 06:01:19 +00:00
subtitle: Text("$_downloadThreadCount"),
onTap: () async {
2022-07-09 07:11:26 +00:00
if (!isPro) {
defaultToast(context, "请先发电再使用");
return;
}
2021-10-31 06:01:19 +00:00
int? value = await chooseListDialog(context, "选择下载线程数", _values);
if (value != null) {
await method.saveDownloadThreadCount(value);
_downloadThreadCount = value;
setState(() {});
}
},
);
},
);
}