pull/306/head
Lucas Nogueira 2 years ago
parent 6aaa50164c
commit c9a68e60e1
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

@ -185,12 +185,14 @@ class DialogPlugin: Plugin {
let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert) let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertController.Style.alert)
alert.addAction(UIAlertAction(title: cancelButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in alert.addAction(UIAlertAction(title: cancelButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in
invoke.resolve([ invoke.resolve([
"value": false "value": false,
"cancelled": false
]) ])
})) }))
alert.addAction(UIAlertAction(title: okButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in alert.addAction(UIAlertAction(title: okButtonLabel, style: UIAlertAction.Style.default, handler: { (_) -> Void in
invoke.resolve([ invoke.resolve([
"value": true "value": true,
"cancelled": false
]) ])
})) }))

@ -12,7 +12,9 @@ use crate::{Dialog, FileDialogBuilder, FileResponse, MessageDialogKind, Result};
#[derive(Serialize)] #[derive(Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum OpenResponse { pub enum OpenResponse {
#[cfg(desktop)]
Folders(Option<Vec<PathBuf>>), Folders(Option<Vec<PathBuf>>),
#[cfg(desktop)]
Folder(Option<PathBuf>), Folder(Option<PathBuf>),
Files(Option<Vec<FileResponse>>), Files(Option<Vec<FileResponse>>),
File(Option<FileResponse>), File(Option<FileResponse>),
@ -46,12 +48,14 @@ pub struct OpenDialogOptions {
/// If [`Self::directory`] is true, indicates that it will be read recursively later. /// If [`Self::directory`] is true, indicates that it will be read recursively later.
/// Defines whether subdirectories will be allowed on the scope or not. /// Defines whether subdirectories will be allowed on the scope or not.
#[serde(default)] #[serde(default)]
#[cfg_attr(mobile, allow(dead_code))]
recursive: bool, recursive: bool,
} }
/// The options for the save dialog API. /// The options for the save dialog API.
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
#[cfg_attr(mobile, allow(dead_code))]
pub struct SaveDialogOptions { pub struct SaveDialogOptions {
/// The title of the dialog window. /// The title of the dialog window.
title: Option<String>, title: Option<String>,

@ -206,6 +206,7 @@ pub struct FileResponse {
} }
impl FileResponse { impl FileResponse {
#[cfg(desktop)]
fn new(path: PathBuf) -> Self { fn new(path: PathBuf) -> Self {
Self { Self {
base64_data: None, base64_data: None,

@ -2,8 +2,6 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
use std::path::PathBuf;
use serde::{de::DeserializeOwned, Deserialize}; use serde::{de::DeserializeOwned, Deserialize};
use tauri::{ use tauri::{
plugin::{PluginApi, PluginHandle}, plugin::{PluginApi, PluginHandle},
@ -87,7 +85,7 @@ pub fn pick_files<R: Runtime, F: FnOnce(Option<Vec<FileResponse>>) + Send + 'sta
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct ShowMessageDialogResponse { struct ShowMessageDialogResponse {
#[serde(default)] #[allow(dead_code)]
cancelled: bool, cancelled: bool,
value: bool, value: bool,
} }

Loading…
Cancel
Save