mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-07-24 17:20:51 +02:00
fix(dialog): On Android, do not add a Cancel button to message dialogs (#873)
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"dialog": "patch"
|
||||||
|
---
|
||||||
|
|
||||||
|
On Android, do not add a `Cancel` button to message dialogs.
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
import { open, save, confirm } from "@tauri-apps/plugin-dialog";
|
import { open, save, confirm, message } from "@tauri-apps/plugin-dialog";
|
||||||
import { readFile } from "@tauri-apps/plugin-fs";
|
import { readFile } from "@tauri-apps/plugin-fs";
|
||||||
|
|
||||||
export let onMessage;
|
export let onMessage;
|
||||||
@@ -22,6 +22,16 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function prompt() {
|
async function prompt() {
|
||||||
|
confirm("Do you want to do something?")
|
||||||
|
.then((res) =>
|
||||||
|
onMessage(
|
||||||
|
res ? "Yes" : "No"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
.catch(onMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function promptCustom() {
|
||||||
confirm("Is Tauri awesome?", {
|
confirm("Is Tauri awesome?", {
|
||||||
okLabel: "Absolutely",
|
okLabel: "Absolutely",
|
||||||
cancelLabel: "Totally",
|
cancelLabel: "Totally",
|
||||||
@@ -34,6 +44,10 @@
|
|||||||
.catch(onMessage);
|
.catch(onMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function msg() {
|
||||||
|
await message("Tauri is awesome!");
|
||||||
|
}
|
||||||
|
|
||||||
function openDialog() {
|
function openDialog() {
|
||||||
open({
|
open({
|
||||||
title: "My wonderful open dialog",
|
title: "My wonderful open dialog",
|
||||||
@@ -130,3 +144,5 @@
|
|||||||
>Open save dialog</button
|
>Open save dialog</button
|
||||||
>
|
>
|
||||||
<button class="btn" id="prompt-dialog" on:click={prompt}>Prompt</button>
|
<button class="btn" id="prompt-dialog" on:click={prompt}>Prompt</button>
|
||||||
|
<button class="btn" id="custom-prompt-dialog" on:click={promptCustom}>Prompt (custom)</button>
|
||||||
|
<button class="btn" id="message-dialog" on:click={msg}>Message</button>
|
||||||
|
|||||||
@@ -190,16 +190,16 @@ class DialogPlugin(private val activity: Activity): Plugin(activity) {
|
|||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
handler(false, true)
|
handler(false, true)
|
||||||
}
|
}
|
||||||
.setNegativeButton(
|
|
||||||
args.cancelButtonLabel ?: "Cancel"
|
|
||||||
) { dialog, _ ->
|
|
||||||
dialog.dismiss()
|
|
||||||
handler(false, false)
|
|
||||||
}
|
|
||||||
.setOnCancelListener { dialog ->
|
.setOnCancelListener { dialog ->
|
||||||
dialog.dismiss()
|
dialog.dismiss()
|
||||||
handler(true, false)
|
handler(true, false)
|
||||||
}
|
}
|
||||||
|
if (args.cancelButtonLabel != null) {
|
||||||
|
builder.setNegativeButton( args.cancelButtonLabel) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
handler(false, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
val dialog = builder.create()
|
val dialog = builder.create()
|
||||||
dialog.show()
|
dialog.show()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user