Skip to content

Commit

Permalink
✨ copy skip confirm
Browse files Browse the repository at this point in the history
  • Loading branch information
niuhuan committed Apr 2, 2024
1 parent d66ff4d commit c127506
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 8 deletions.
3 changes: 2 additions & 1 deletion ci/version.info.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
v1.7.8
- [x] ♻️ iOS可以使用FaceID进行解锁App
- [x] ✨ 音量键快速翻阅下一章节(设置中开启)
- [x] ✨ 音量键快速翻阅下一章节(设置中默认开启)
- [x] ✨ 长按复制不需要确认(设置中默认关闭)

v1.7.7
- [x] 🐛 修复一些极端情况下崩溃
22 changes: 15 additions & 7 deletions lib/basic/Cross.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:pikapika/basic/Common.dart';
import 'package:pikapika/basic/config/CopySkipConfirm.dart';
import 'package:pikapika/basic/config/Platform.dart';
import 'package:url_launcher/url_launcher.dart';

Expand All @@ -18,6 +19,11 @@ void copyToClipBoard(BuildContext context, String string) {
defaultToast(context, "已复制到剪切板");
}

void copyToClipBoardTips(BuildContext context, String string) {
FlutterClipboard.copy(string);
defaultToast(context, "已复制到剪切板 :\n$string");
}

/// 打开web页面
Future<dynamic> openUrl(String url) async {
if (await canLaunch(url)) {
Expand Down Expand Up @@ -72,7 +78,7 @@ Future<dynamic> _saveImageAndroid(String path, BuildContext context) async {
late bool g;
if (androidVersion < 30) {
g = await Permission.storage.request().isGranted;
}else{
} else {
g = await Permission.manageExternalStorage.request().isGranted;
}
if (!g) {
Expand All @@ -85,16 +91,18 @@ Future<dynamic> _saveImageAndroid(String path, BuildContext context) async {
Future<String?> chooseFolder(BuildContext context) async {
return FilePicker.platform.getDirectoryPath(
dialogTitle: "选择一个文件夹, 将文件保存到这里",
initialDirectory: Directory
.fromUri(Uri.file(await currentChooserRoot()))
.absolute
.path,
initialDirectory:
Directory.fromUri(Uri.file(await currentChooserRoot())).absolute.path,
);
}

/// 复制对话框
void confirmCopy(BuildContext context, String content) async {
if (await confirmDialog(context, "复制", content)) {
copyToClipBoard(context, content);
if (copySkipConfirm()) {
copyToClipBoardTips(context, content);
} else {
if (await confirmDialog(context, "复制", content)) {
copyToClipBoard(context, content);
}
}
}
30 changes: 30 additions & 0 deletions lib/basic/config/CopySkipConfirm.dart
Original file line number Diff line number Diff line change
@@ -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(() {});
},
);
},
);
}
2 changes: 2 additions & 0 deletions lib/screens/InitScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:pikapika/basic/config/AutoFullScreen.dart';
import 'package:pikapika/basic/config/CategoriesColumnCount.dart';
import 'package:pikapika/basic/config/ChooserRoot.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/DownloadThreadCount.dart';
import 'package:pikapika/basic/config/EBookScrolling.dart';
Expand Down Expand Up @@ -127,6 +128,7 @@ class _InitScreenState extends State<InitScreen> {
await initEBookScrollingRange();
await initEBookScrollingTrigger();
await initVolumeNextChapter();
await initCopySkipConfirm();

String? initUrl;
if (Platform.isAndroid || Platform.isIOS) {
Expand Down
2 changes: 2 additions & 0 deletions lib/screens/SettingsScreen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:pikapika/basic/config/AutoClean.dart';
import 'package:pikapika/basic/config/AutoFullScreen.dart';
import 'package:pikapika/basic/config/ChooserRoot.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/DownloadThreadCount.dart';
import 'package:pikapika/basic/config/EBookScrollingRange.dart';
Expand Down Expand Up @@ -101,6 +102,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
androidSecureFlagSetting(),
authenticationSetting(),
const Divider(),
copySkipConfirmSetting(),
iconLoadingSetting(),
eBookScrollingSetting(),
eBookScrollingRangeSetting(),
Expand Down

0 comments on commit c127506

Please sign in to comment.