pikapika/lib/basic/config/IconLoading.dart

44 lines
1.1 KiB
Dart
Raw Normal View History

2022-09-05 03:05:46 +00:00
/// 自动全屏
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
const _propertyName = "iconLoading";
late bool _iconLoading;
Future<void> initIconLoading() async {
_iconLoading =
(await method.loadProperty(_propertyName, "false")) == "true";
}
bool currentIconLoading() {
return _iconLoading;
}
Future<void> _chooseIconLoading(BuildContext context) async {
String? result =
await chooseListDialog<String>(context, "使用静态图标代替加载动画", ["", ""]);
if (result != null) {
var target = result == "";
await method.saveProperty(_propertyName, "$target");
_iconLoading = target;
}
}
Widget iconLoadingSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: const Text("使用静态图标代替加载动画"),
subtitle: Text(_iconLoading ? "" : ""),
onTap: () async {
await _chooseIconLoading(context);
setState(() {});
},
);
},
);
}