pikapika/lib/basic/config/ExportRename.dart

52 lines
1.3 KiB
Dart

/// 自动全屏
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
import 'IsPro.dart';
const _propertyName = "exportRename";
late bool _exportRename;
Future<void> initExportRename() async {
_exportRename = (await method.loadProperty(_propertyName, "false")) == "true";
}
bool currentExportRename() {
return _exportRename;
}
Future<void> _chooseExportRename(BuildContext context) async {
String? result =
await chooseListDialog<String>(context, "导出时进行重命名", ["", ""]);
if (result != null) {
var target = result == "";
await method.saveProperty(_propertyName, "$target");
_exportRename = target;
}
}
Widget exportRenameSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: Text(
"导出时进行重命名" + (!isPro ? "(发电)" : ""),
style: TextStyle(
color: !isPro ? Colors.grey : null,
),
),
subtitle: Text(_exportRename ? "" : ""),
onTap: () async {
if (!isPro) {
defaultToast(context, "请先发电再使用");
return;
}
await _chooseExportRename(context);
setState(() {});
},
);
},
);
}