diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/Toast.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/Toast.java index 9450d837d7..5e3de683fe 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/Toast.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/Toast.java @@ -20,7 +20,7 @@ public void show(PluginCall call) { return; } - String durationType = call.getString("durationType", "short"); + String durationType = call.getString("duration", "short"); int duration = android.widget.Toast.LENGTH_SHORT; if("long".equals(durationType)) { diff --git a/core/src/core-plugin-definitions.ts b/core/src/core-plugin-definitions.ts index 6107ac14df..f2e13d6d65 100644 --- a/core/src/core-plugin-definitions.ts +++ b/core/src/core-plugin-definitions.ts @@ -1652,6 +1652,9 @@ export interface ToastPlugin extends Plugin { export interface ToastShowOptions { text: string; + /** + * Duration of the toast, either 'short' (2000ms, default) or 'long' (3500ms) + */ duration?: 'short' | 'long'; position?: 'top' | 'center' | 'bottom'; } diff --git a/core/src/web/toast.ts b/core/src/web/toast.ts index af2eb5e3ea..afb686461e 100644 --- a/core/src/web/toast.ts +++ b/core/src/web/toast.ts @@ -11,9 +11,9 @@ export class ToastPluginWeb extends WebPlugin implements ToastPlugin { } async show(options: ToastShowOptions) { - let duration = 3000; + let duration = 2000; if (options.duration) { - duration = options.duration === 'long' ? 5000 : 3000; + duration = options.duration === 'long' ? 3500 : 2000; } const toast = document.createElement('pwa-toast') as any; toast.duration = duration; diff --git a/ios/Capacitor/Capacitor/Plugins/Toast.swift b/ios/Capacitor/Capacitor/Plugins/Toast.swift index 407355b3cb..ce0f0c58be 100644 --- a/ios/Capacitor/Capacitor/Plugins/Toast.swift +++ b/ios/Capacitor/Capacitor/Plugins/Toast.swift @@ -10,8 +10,8 @@ public class CAPToastPlugin : CAPPlugin { call.error("text must be provided and must be a string.") return } - let durationStyle = call.get("durationStyle", String.self, "long")! - let duration = durationStyle == "short" ? 1500 : 3000 + let durationType = call.get("duration", String.self, "short")! + let duration = durationType == "long" ? 3500 : 2000 let position = call.get("position", String.self, "bottom") DispatchQueue.main.async {