copy skip confirm

This commit is contained in:
niuhuan 2024-04-02 21:06:03 +08:00
parent d66ff4d536
commit c12750680e
5 changed files with 51 additions and 8 deletions

View File

@ -1,6 +1,7 @@
v1.7.8 v1.7.8
- [x] ♻️ iOS可以使用FaceID进行解锁App - [x] ♻️ iOS可以使用FaceID进行解锁App
- [x] ✨ 音量键快速翻阅下一章节(设置中开启) - [x] ✨ 音量键快速翻阅下一章节(设置中默认开启)
- [x] ✨ 长按复制不需要确认(设置中默认关闭)
v1.7.7 v1.7.7
- [x] 🐛 修复一些极端情况下崩溃 - [x] 🐛 修复一些极端情况下崩溃

View File

@ -6,6 +6,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart'; import 'package:permission_handler/permission_handler.dart';
import 'package:pikapika/basic/Common.dart'; import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/config/CopySkipConfirm.dart';
import 'package:pikapika/basic/config/Platform.dart'; import 'package:pikapika/basic/config/Platform.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@ -18,6 +19,11 @@ void copyToClipBoard(BuildContext context, String string) {
defaultToast(context, "已复制到剪切板"); defaultToast(context, "已复制到剪切板");
} }
void copyToClipBoardTips(BuildContext context, String string) {
FlutterClipboard.copy(string);
defaultToast(context, "已复制到剪切板 :\n$string");
}
/// web页面 /// web页面
Future<dynamic> openUrl(String url) async { Future<dynamic> openUrl(String url) async {
if (await canLaunch(url)) { if (await canLaunch(url)) {
@ -72,7 +78,7 @@ Future<dynamic> _saveImageAndroid(String path, BuildContext context) async {
late bool g; late bool g;
if (androidVersion < 30) { if (androidVersion < 30) {
g = await Permission.storage.request().isGranted; g = await Permission.storage.request().isGranted;
}else{ } else {
g = await Permission.manageExternalStorage.request().isGranted; g = await Permission.manageExternalStorage.request().isGranted;
} }
if (!g) { if (!g) {
@ -85,16 +91,18 @@ Future<dynamic> _saveImageAndroid(String path, BuildContext context) async {
Future<String?> chooseFolder(BuildContext context) async { Future<String?> chooseFolder(BuildContext context) async {
return FilePicker.platform.getDirectoryPath( return FilePicker.platform.getDirectoryPath(
dialogTitle: "选择一个文件夹, 将文件保存到这里", dialogTitle: "选择一个文件夹, 将文件保存到这里",
initialDirectory: Directory initialDirectory:
.fromUri(Uri.file(await currentChooserRoot())) Directory.fromUri(Uri.file(await currentChooserRoot())).absolute.path,
.absolute
.path,
); );
} }
/// ///
void confirmCopy(BuildContext context, String content) async { void confirmCopy(BuildContext context, String content) async {
if (await confirmDialog(context, "复制", content)) { if (copySkipConfirm()) {
copyToClipBoard(context, content); copyToClipBoardTips(context, content);
} else {
if (await confirmDialog(context, "复制", content)) {
copyToClipBoard(context, content);
}
} }
} }

View File

@ -0,0 +1,30 @@
import 'package:flutter/material.dart';
import '../Method.dart';
const _propertyName = "copySkipConfirm";
late bool _copySkipConfirm;
Future initCopySkipConfirm() async {
_copySkipConfirm = (await method.loadProperty(_propertyName, "false")) == "true";
}
bool copySkipConfirm() {
return _copySkipConfirm;
}
Widget copySkipConfirmSetting() {
return StatefulBuilder(
builder: (BuildContext context, void Function(void Function()) setState) {
return SwitchListTile(
title: const Text("长按复制不需要确认"),
value: _copySkipConfirm,
onChanged: (value) async {
await method.saveProperty(_propertyName, "$value");
_copySkipConfirm = value;
setState(() {});
},
);
},
);
}

View File

@ -11,6 +11,7 @@ import 'package:pikapika/basic/config/AutoFullScreen.dart';
import 'package:pikapika/basic/config/CategoriesColumnCount.dart'; import 'package:pikapika/basic/config/CategoriesColumnCount.dart';
import 'package:pikapika/basic/config/ChooserRoot.dart'; import 'package:pikapika/basic/config/ChooserRoot.dart';
import 'package:pikapika/basic/config/ContentFailedReloadAction.dart'; import 'package:pikapika/basic/config/ContentFailedReloadAction.dart';
import 'package:pikapika/basic/config/CopySkipConfirm.dart';
import 'package:pikapika/basic/config/DownloadAndExportPath.dart'; import 'package:pikapika/basic/config/DownloadAndExportPath.dart';
import 'package:pikapika/basic/config/DownloadThreadCount.dart'; import 'package:pikapika/basic/config/DownloadThreadCount.dart';
import 'package:pikapika/basic/config/EBookScrolling.dart'; import 'package:pikapika/basic/config/EBookScrolling.dart';
@ -127,6 +128,7 @@ class _InitScreenState extends State<InitScreen> {
await initEBookScrollingRange(); await initEBookScrollingRange();
await initEBookScrollingTrigger(); await initEBookScrollingTrigger();
await initVolumeNextChapter(); await initVolumeNextChapter();
await initCopySkipConfirm();
String? initUrl; String? initUrl;
if (Platform.isAndroid || Platform.isIOS) { if (Platform.isAndroid || Platform.isIOS) {

View File

@ -8,6 +8,7 @@ import 'package:pikapika/basic/config/AutoClean.dart';
import 'package:pikapika/basic/config/AutoFullScreen.dart'; import 'package:pikapika/basic/config/AutoFullScreen.dart';
import 'package:pikapika/basic/config/ChooserRoot.dart'; import 'package:pikapika/basic/config/ChooserRoot.dart';
import 'package:pikapika/basic/config/ContentFailedReloadAction.dart'; import 'package:pikapika/basic/config/ContentFailedReloadAction.dart';
import 'package:pikapika/basic/config/CopySkipConfirm.dart';
import 'package:pikapika/basic/config/DownloadAndExportPath.dart'; import 'package:pikapika/basic/config/DownloadAndExportPath.dart';
import 'package:pikapika/basic/config/DownloadThreadCount.dart'; import 'package:pikapika/basic/config/DownloadThreadCount.dart';
import 'package:pikapika/basic/config/EBookScrollingRange.dart'; import 'package:pikapika/basic/config/EBookScrollingRange.dart';
@ -101,6 +102,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
androidSecureFlagSetting(), androidSecureFlagSetting(),
authenticationSetting(), authenticationSetting(),
const Divider(), const Divider(),
copySkipConfirmSetting(),
iconLoadingSetting(), iconLoadingSetting(),
eBookScrollingSetting(), eBookScrollingSetting(),
eBookScrollingRangeSetting(), eBookScrollingRangeSetting(),