pikapika/lib/basic/config/ShowCommentAtDownload.dart

42 lines
1.1 KiB
Dart
Raw Normal View History

2022-08-20 15:16:13 +00:00
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
const _propertyName = "showCommentAtDownload";
late bool _showCommentAtDownload;
Future initShowCommentAtDownload() async {
_showCommentAtDownload = (await method.loadProperty(_propertyName, "false")) == "true";
}
bool showCommentAtDownload() {
return _showCommentAtDownload;
}
Future<void> _chooseShowCommentAtDownload(BuildContext context) async {
String? result =
await chooseListDialog<String>(context, "在下载显示评论区", ["", ""]);
if (result != null) {
var target = result == "";
await method.saveProperty(_propertyName, "$target");
_showCommentAtDownload = target;
}
}
Widget showCommentAtDownloadSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: const Text("在下载显示评论区"),
subtitle: Text(_showCommentAtDownload ? "" : ""),
onTap: () async {
await _chooseShowCommentAtDownload(context);
setState(() {});
},
);
},
);
}