mirror of
https://github.com/venera-app/venera.git
synced 2025-09-27 15:57:25 +00:00
experimental support for set new storage path on iOS
This commit is contained in:
@@ -32,11 +32,16 @@ class _AppSettingsState extends State<AppSettings> {
|
||||
title: "Set New Storage Path".tl,
|
||||
actionTitle: "Set".tl,
|
||||
callback: () async {
|
||||
if (App.isMobile) {
|
||||
var result;
|
||||
if (App.isAndroid) {
|
||||
context.showMessage(message: "Not supported".tl);
|
||||
return;
|
||||
}
|
||||
var result = await selectDirectory();
|
||||
else if (App.isIOS) {
|
||||
result = await selectDirectoryIOS();
|
||||
} else {
|
||||
result = await selectDirectory();
|
||||
}
|
||||
if (result == null) return;
|
||||
var loadingDialog = showLoadingDialog(
|
||||
App.rootContext,
|
||||
|
@@ -160,6 +160,22 @@ class DirectoryPicker {
|
||||
}
|
||||
}
|
||||
|
||||
class IOSDirectoryPicker {
|
||||
static const MethodChannel _channel = MethodChannel("venera/method_channel");
|
||||
|
||||
// 调用 iOS 目录选择方法
|
||||
static Future<String?> selectDirectory() async {
|
||||
try {
|
||||
final String? path = await _channel.invokeMethod('selectDirectory');
|
||||
return path;
|
||||
} catch (e) {
|
||||
print("Error selecting directory: $e");
|
||||
// 返回报错信息
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<file_selector.XFile?> selectFile({required List<String> ext}) async {
|
||||
file_selector.XTypeGroup typeGroup = file_selector.XTypeGroup(
|
||||
label: 'files',
|
||||
@@ -181,6 +197,11 @@ Future<String?> selectDirectory() async {
|
||||
return path;
|
||||
}
|
||||
|
||||
// selectDirectoryIOS
|
||||
Future<String?> selectDirectoryIOS() async {
|
||||
return IOSDirectoryPicker.selectDirectory();
|
||||
}
|
||||
|
||||
Future<void> saveFile(
|
||||
{Uint8List? data, required String filename, File? file}) async {
|
||||
if (data == null && file == null) {
|
||||
|
Reference in New Issue
Block a user