pikapika/lib/basic/config/IconLoading.dart

54 lines
1.4 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 {
2023-01-31 10:50:51 +00:00
_iconLoading = (await method.loadProperty(_propertyName, "false")) == "true";
2022-09-05 03:05:46 +00:00
}
bool currentIconLoading() {
return _iconLoading;
}
Future<void> _chooseIconLoading(BuildContext context) async {
String? result =
2023-01-31 10:50:51 +00:00
await chooseListDialog<String>(context, "尽量减少UI动画", ["", ""]);
2022-09-05 03:05:46 +00:00
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(
2023-01-31 10:50:51 +00:00
title: const Text("尽量减少UI动画"),
2023-06-14 10:17:32 +00:00
subtitle: Text(_iconLoading ? "" : ""),
2022-09-05 03:05:46 +00:00
onTap: () async {
await _chooseIconLoading(context);
setState(() {});
},
);
},
);
}
2023-01-31 10:50:51 +00:00
Route<T> mixRoute<T>({required WidgetBuilder builder}) {
if (currentIconLoading()) {
return PageRouteBuilder(
pageBuilder: (context, animation1, animation2) => builder.call(context),
transitionDuration: Duration.zero,
reverseTransitionDuration: Duration.zero,
);
}
return MaterialPageRoute(builder: builder);
}