public static Task <bool> Confirm(this IUserDialogs dialogs, string message, string title = null, string okText = null, string cancelText = null) => dialogs.Confirm(new ConfirmConfig { Title = title, Message = message, OkLabel = okText, CancelLabel = cancelText });
public void Show(ConfirmConfig config) { _userDialogsInstance.Confirm(new Acr.UserDialogs.ConfirmConfig { CancelText = config.CancelText, OkText = config.OkText, Title = config.Title, Message = config.Message, OnAction = config.OnAction }); }
public void ViewModelMethod() { userDialogs.Confirm(new ConfirmConfig { OnConfirm = result => { if (result) { anotherService.Method(); } } }); }
private void ActionSaveCommand() { try { Dialogs.Confirm(new ConfirmConfig { CancelText = "Cancel", OkText = "Accept", OnAction = CheckSaveAction, Message = "Are you sure you wish to save these settings...", Title = "Save Changes" }); } catch (Exception ex) { Dialogs.Alert($"Sorry an Error has occured - {ex.Message}"); } }
public PendingViewModel(INavigationService navigation, IHttpTransferManager httpTransfers, IUserDialogs dialogs) { this.httpTransfers = httpTransfers; this.dialogs = dialogs; this.Create = navigation.NavigateCommand("CreateTransfer"); this.Load = ReactiveCommand.CreateFromTask(async() => { var transfers = await httpTransfers.GetTransfers(); this.Transfers = transfers .Select(transfer => { var vm = new HttpTransferViewModel { Identifier = transfer.Identifier, Uri = transfer.Uri, IsUpload = transfer.IsUpload, Cancel = ReactiveCommand.CreateFromTask(async() => { var confirm = await dialogs.Confirm("Are you sure you want to cancel all transfers?", "Confirm", "Yes", "No"); if (confirm) { await this.httpTransfers.Cancel(transfer.Identifier); await this.Load.Execute(); } }) }; ToViewModel(vm, transfer); return(vm); }) .ToList(); }); this.CancelAll = ReactiveCommand.CreateFromTask(async() => { await httpTransfers.Cancel(); await this.Load.Execute().ToTask(); }); this.BindBusyCommand(this.Load); }
protected void ShowConfirmMessageBox(string title, string message, Action <bool> onConfirmAction) { IUserDialogs dlg = Mvx.Resolve <IUserDialogs> (); if (dlg == null) { return; } InvokeOnMainThread(() => { ConfirmConfig cfg = new ConfirmConfig(); cfg.SetTitle(title); cfg.SetMessage(message); cfg.UseYesNo(); cfg.SetOkText("Si"); cfg.SetAction(onConfirmAction); dlg.Confirm(cfg); }); }
public MonitoringViewModel(INavigationService navigator, IUserDialogs dialogs, IBeaconManager beaconManager) { this.dialogs = dialogs; this.beaconManager = beaconManager; this.Add = navigator.NavigateCommand( "CreateBeacon", p => p.Add("Monitoring", true) ); this.Load = ReactiveCommand.CreateFromTask(async() => { var regions = await this.beaconManager.GetMonitoredRegions(); this.Regions = regions .Select(x => new CommandItem { Text = $"{x.Identifier}", Detail = $"{x.Uuid}/{x.Major ?? 0}/{x.Minor ?? 0}", PrimaryCommand = ReactiveCommand.CreateFromTask(async() => { await this.beaconManager.StopMonitoring(x.Identifier); this.Load.Execute(null); }) }) .ToList(); }); this.StopAllMonitoring = ReactiveCommand.CreateFromTask(async() => { var result = await dialogs.Confirm("Are you sure you wish to stop all monitoring"); if (result) { await this.beaconManager.StopAllMonitoring(); this.Load.Execute(null); } }); }
public PendingViewModel(INotificationManager notifications, IUserDialogs dialogs) { this.Load = ReactiveCommand.CreateFromTask(async() => { var pending = await notifications.GetPending(); this.PendingList = pending .Select(x => new CommandItem { Text = $"[{x.Id}] {x.Title}", Detail = $"[{x.ScheduleDate.Value}] {x.Message}", PrimaryCommand = ReactiveCommand.CreateFromTask(async() => { await notifications.Cancel(x.Id); ((ICommand)this.Load).Execute(null); }) }) .ToList(); }); this.BindBusyCommand(this.Load); this.Clear = ReactiveCommand.CreateFromTask( async() => { var confirm = await dialogs.Confirm("Clear All Pending Notifications?", "Confirm", "Yes", "No"); if (confirm) { await notifications.Clear(); ((ICommand)this.Load).Execute(null); } } //this.WhenAny( // x => x.PendingList, // x => x.GetValue()?.Any() ?? false //) ); }
public ListViewModel(IJobManager jobManager, INavigationService navigator, IUserDialogs dialogs) { this.jobManager = jobManager; this.dialogs = dialogs; this.Create = navigator.NavigateCommand("CreateJob"); this.LoadJobs = ReactiveCommand.CreateFromTask(async() => { var jobs = await jobManager.GetJobs(); this.Jobs = jobs .Select(x => new CommandItem { Text = x.Identifier, Detail = x.LastRunUtc?.ToLocalTime().ToString("G") ?? "Never Run", PrimaryCommand = ReactiveCommand.CreateFromTask(() => jobManager.Run(x.Identifier)), SecondaryCommand = ReactiveCommand.CreateFromTask(async() => { await jobManager.Cancel(x.Identifier); this.LoadJobs.Execute(); }) }) .ToList(); }); this.BindBusyCommand(this.LoadJobs); this.RunAllJobs = ReactiveCommand.CreateFromTask(async() => { if (!await this.AssertJobs()) { return; } if (this.jobManager.IsRunning) { await dialogs.Alert("Job Manager is already running"); } else { await this.jobManager.RunAll(); dialogs.Toast("Job Batch Started"); } }); this.CancelAllJobs = ReactiveCommand.CreateFromTask(async _ => { if (!await this.AssertJobs()) { return; } var confirm = await dialogs.Confirm("Are you sure you wish to cancel all jobs?"); if (confirm) { await this.jobManager.CancelAll(); this.LoadJobs.Execute(); } }); }