public override void Confirm(ConfirmConfig config) { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => new AlertDialog .Builder(this.getTopActivity()) .SetCancelable(false) .SetMessage(config.Message) .SetTitle(config.Title) .SetPositiveButton(config.OkText, (o, e) => config.OnConfirm(true)) .SetNegativeButton(config.CancelText, (o, e) => config.OnConfirm(false)) .Show() ); }
public override void Confirm(ConfirmConfig config) { UIApplication.SharedApplication.InvokeOnMainThread(() => { if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var dlg = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert); dlg.AddAction(UIAlertAction.Create(config.OkText, UIAlertActionStyle.Default, x => config.OnConfirm(true))); dlg.AddAction(UIAlertAction.Create(config.CancelText, UIAlertActionStyle.Default, x => config.OnConfirm(false))); this.Present(dlg); } else { var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, config.CancelText, config.OkText); dlg.Clicked += (s, e) => { var ok = ((int)dlg.CancelButtonIndex != (int)e.ButtonIndex); config.OnConfirm(ok); }; dlg.Show(); } }); }