@@ -10,7 +10,7 @@ use tauri_plugin_fs::FsExt;
10
10
11
11
use crate :: {
12
12
Dialog , FileDialogBuilder , FilePath , MessageDialogButtons , MessageDialogKind , Result , CANCEL ,
13
- OK ,
13
+ NO , OK , YES ,
14
14
} ;
15
15
16
16
#[ derive( Serialize ) ]
@@ -299,16 +299,25 @@ pub(crate) async fn ask<R: Runtime>(
299
299
title : Option < String > ,
300
300
message : String ,
301
301
kind : Option < MessageDialogKind > ,
302
- ok_button_label : Option < String > ,
303
- cancel_button_label : Option < String > ,
302
+ yes_button_label : Option < String > ,
303
+ no_button_label : Option < String > ,
304
304
) -> Result < bool > {
305
305
Ok ( message_dialog (
306
306
window,
307
307
dialog,
308
308
title,
309
309
message,
310
310
kind,
311
- get_ok_cancel_type ( ok_button_label, cancel_button_label) ,
311
+ if let Some ( yes_button_label) = yes_button_label {
312
+ MessageDialogButtons :: OkCancelCustom (
313
+ yes_button_label,
314
+ no_button_label. unwrap_or ( NO . to_string ( ) ) ,
315
+ )
316
+ } else if let Some ( no_button_label) = no_button_label {
317
+ MessageDialogButtons :: OkCancelCustom ( YES . to_string ( ) , no_button_label)
318
+ } else {
319
+ MessageDialogButtons :: YesNo
320
+ } ,
312
321
) )
313
322
}
314
323
@@ -328,22 +337,15 @@ pub(crate) async fn confirm<R: Runtime>(
328
337
title,
329
338
message,
330
339
kind,
331
- get_ok_cancel_type ( ok_button_label, cancel_button_label) ,
340
+ if let Some ( ok_button_label) = ok_button_label {
341
+ MessageDialogButtons :: OkCancelCustom (
342
+ ok_button_label,
343
+ cancel_button_label. unwrap_or ( CANCEL . to_string ( ) ) ,
344
+ )
345
+ } else if let Some ( cancel_button_label) = cancel_button_label {
346
+ MessageDialogButtons :: OkCancelCustom ( OK . to_string ( ) , cancel_button_label)
347
+ } else {
348
+ MessageDialogButtons :: OkCancel
349
+ } ,
332
350
) )
333
351
}
334
-
335
- fn get_ok_cancel_type (
336
- ok_button_label : Option < String > ,
337
- cancel_button_label : Option < String > ,
338
- ) -> MessageDialogButtons {
339
- if let Some ( ok_button_label) = ok_button_label {
340
- MessageDialogButtons :: OkCancelCustom (
341
- ok_button_label,
342
- cancel_button_label. unwrap_or ( CANCEL . to_string ( ) ) ,
343
- )
344
- } else if let Some ( cancel_button_label) = cancel_button_label {
345
- MessageDialogButtons :: OkCancelCustom ( OK . to_string ( ) , cancel_button_label)
346
- } else {
347
- MessageDialogButtons :: OkCancel
348
- }
349
- }
0 commit comments