Skip to content

Commit e67e092

Browse files
authored
feat: update dialog Rust API, add note on path format for mobile (#2765)
1 parent 80fb259 commit e67e092

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

src/content/docs/plugin/dialog.mdx

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,20 @@ in Rust:
9191
- [Build a Message Dialog](#build-a-message-dialog)
9292
- [Build a File Selector Dialog](#build-a-file-selector-dialog)
9393

94-
---
94+
:::note
95+
The file dialog APIs returns file system paths on Linux, Windows and macOS.
96+
97+
On iOS, a `file://<path>` URIs are returned.
98+
99+
On Android, [content URIs] are returned.
100+
101+
The [filesystem plugin] works with any path format out of the box.
102+
:::
95103

96104
### JavaScript
97105

98106
See all [Dialog Options](/reference/javascript/dialog/) at the JavaScript API reference.
99107

100-
{/* ASK */}
101-
102108
#### Create Yes/No Dialog
103109

104110
Shows a question dialog with `Yes` and `No` buttons.
@@ -118,8 +124,6 @@ console.log(answer);
118124
// Prints boolean to the console
119125
```
120126

121-
{/* CONFIRM */}
122-
123127
#### Create Ok/Cancel Dialog
124128

125129
Shows a question dialog with `Ok` and `Cancel` buttons.
@@ -139,8 +143,6 @@ console.log(confirmation);
139143
// Prints boolean to the console
140144
```
141145

142-
{/* MESSAGE */}
143-
144146
#### Create Message Dialog
145147

146148
Shows a message dialog with an `Ok` button. Keep in mind that if the user closes the dialog it will return `false`.
@@ -154,8 +156,6 @@ import { message } from '@tauri-apps/plugin-dialog';
154156
await message('File not found', { title: 'Tauri', kind: 'error' });
155157
```
156158

157-
{/* OPEN */}
158-
159159
#### Open a File Selector Dialog
160160

161161
Open a file/directory selection dialog.
@@ -176,8 +176,6 @@ console.log(file);
176176
// Prints file path or URI
177177
```
178178

179-
{/* SAVE */}
180-
181179
#### Save to File Dialog
182180

183181
Open a file/directory save dialog.
@@ -211,26 +209,24 @@ Refer to the [Rust API reference](https://docs.rs/tauri-plugin-dialog/) to see a
211209
Shows a question dialog with `Absolutely` and `Totally` buttons.
212210

213211
```rust
214-
use tauri_plugin_dialog::DialogExt;
212+
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons};
215213

216214
let answer = app.dialog()
217215
.message("Tauri is Awesome")
218216
.title("Tauri is Awesome")
219-
.ok_button_label("Absolutely")
220-
.cancel_button_label("Totally")
217+
.buttons(MessageDialogButtons::OkCancelCustom("Absolutely", "Totally"))
221218
.blocking_show();
222219
```
223220

224221
If you need a non blocking operation you can use `show()` instead:
225222

226223
```rust
227-
use tauri_plugin_dialog::DialogExt;
224+
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons};
228225

229226
app.dialog()
230227
.message("Tauri is Awesome")
231228
.title("Tauri is Awesome")
232-
.ok_button_label("Absolutely")
233-
.cancel_button_label("Totally")
229+
.buttons(MessageDialogButtons::OkCancelCustom("Absolutely", "Totally"))
234230
.show(|result| match result {
235231
true => // do something,
236232
false =>// do something,
@@ -254,13 +250,13 @@ let ans = app.dialog()
254250
If you need a non blocking operation you can use `show()` instead:
255251

256252
```rust
257-
use tauri_plugin_dialog::{DialogExt, MessageDialogKind};
253+
use tauri_plugin_dialog::{DialogExt, MessageDialogButtons, MessageDialogKind};
258254

259255
app.dialog()
260256
.message("Tauri is Awesome")
261257
.kind(MessageDialogKind::Info)
262258
.title("Information")
263-
.ok_button_label("Absolutely")
259+
.buttons(MessageDialogButtons::OkCustom("Absolutely"))
264260
.show(|result| match result {
265261
true => // do something,
266262
false => // do something,
@@ -316,3 +312,6 @@ app.dialog()
316312
```
317313

318314
<PluginPermissions plugin={frontmatter.plugin} />
315+
316+
[content URIs]: https://developer.android.com/guide/topics/providers/content-provider-basics
317+
[filesystem plugin]: /plugin/file-system

0 commit comments

Comments
 (0)