pikapika/lib/basic/config/UsingRightClickPop.dart

49 lines
1.2 KiB
Dart

/// 自动全屏
import 'dart:io';
import 'package:flutter/material.dart';
import '../Common.dart';
import '../Method.dart';
const _propertyName = "usingRightClickPop";
late bool _usingRightClickPop;
Future<void> initUsingRightClickPop() async {
_usingRightClickPop =
(await method.loadProperty(_propertyName, "false")) == "true";
}
bool currentUsingRightClickPop() {
return _usingRightClickPop;
}
Future<void> _chooseUsingRightClickPop(BuildContext context) async {
String? result =
await chooseListDialog<String>(context, "鼠标右键返回上一页", ["", ""]);
if (result != null) {
var target = result == "";
await method.saveProperty(_propertyName, "$target");
_usingRightClickPop = target;
}
}
Widget usingRightClickPopSetting() {
if (!(Platform.isWindows || Platform.isMacOS || Platform.isLinux)) {
return Container();
}
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return ListTile(
title: const Text("鼠标右键返回上一页"),
subtitle: Text(_usingRightClickPop ? "" : ""),
onTap: () async {
await _chooseUsingRightClickPop(context);
setState(() {});
},
);
},
);
}