public virtual Task AlertAsync(AlertConfig config) { var tcs = new TaskCompletionSource<object>(); config.OnOk = () => tcs.TrySetResult(null); this.Alert(config); return tcs.Task; }
public override void Alert(AlertConfig config) { Xamarin.Forms.Device.BeginInvokeOnMainThread(() => new AlertDialog .Builder(this.getTopActivity()) .SetCancelable(false) .SetMessage(config.Message) .SetTitle(config.Title) .SetPositiveButton(config.OkText, (o, e) => config.OnOk.TryExecute()) .Show() ); }
public override void Alert(AlertConfig config) { UIApplication.SharedApplication.InvokeOnMainThread(() => { if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0)) { var alert = UIAlertController.Create(config.Title ?? String.Empty, config.Message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(Catalog.GetString("Ok"), UIAlertActionStyle.Default, x => { if (config.OnOk != null) config.OnOk(); })); this.Present(alert); } else { var dlg = new UIAlertView(config.Title ?? String.Empty, config.Message, null, null, config.OkText); if (config.OnOk != null) dlg.Clicked += (s, e) => config.OnOk(); dlg.Show(); } }); }
public abstract void Alert(AlertConfig config);