public virtual async Task <string> ActionSheetAsync(string title, string cancel, string destructive, CancellationToken?cancelToken = null, params string[] buttons) { var tcs = new TaskCompletionSource <string>(); var cfg = new ActionSheetConfig(); if (title != null) { cfg.Title = title; } // you must have a cancel option for actionsheetasync if (cancel == null) { throw new ArgumentException("You must have a cancel option for the async version"); } cfg.SetCancel(cancel, () => tcs.TrySetResult(cancel)); if (destructive != null) { cfg.SetDestructive(destructive, () => tcs.TrySetResult(destructive)); } foreach (var btn in buttons) { cfg.Add(btn, () => tcs.TrySetResult(btn)); } var disp = this.ActionSheet(cfg); using (cancelToken?.Register(disp.Dispose)) { return(await tcs.Task); } }
public virtual Task <string> ActionSheetAsync(string title, string cancel, string destructive, CancellationToken?cancelToken = null, params string[] buttons) { var tcs = new TaskCompletionSource <string>(); var cfg = new ActionSheetConfig(); if (title != null) { cfg.Title = title; } if (cancel != null) { cfg.SetCancel(cancel, () => tcs.TrySetResult(cancel)); } if (destructive != null) { cfg.SetDestructive(destructive, () => tcs.TrySetResult(destructive)); } foreach (var btn in buttons) { cfg.Add(btn, () => tcs.TrySetResult(btn)); } var disp = this.ActionSheet(cfg); cancelToken?.Register(disp.Dispose); return(tcs.Task); }
public virtual Task<string> ActionSheetAsync(string title, string cancel, string destructive, params string[] buttons) { var tcs = new TaskCompletionSource<string>(); var cfg = new ActionSheetConfig(); if (title != null) cfg.Title = title; if (cancel != null) cfg.SetCancel(cancel, () => tcs.TrySetResult(cancel)); if (destructive != null) cfg.SetDestructive(destructive, () => tcs.TrySetResult(destructive)); foreach (var btn in buttons) cfg.Add(btn, () => tcs.TrySetResult(btn)); this.ActionSheet(cfg); return tcs.Task; }
ICommand CreateActionSheetCommand(bool useBottomSheet, bool cancel, int items, string message = null) { return new Command(() => { var cfg = new ActionSheetConfig() .SetTitle("Test Title") .SetMessage(message) .SetUseBottomSheet(useBottomSheet); IBitmap testImage = null; try { testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result; } catch { Debug.WriteLine("Could not load image"); } for (var i = 0; i < items; i++) { var display = i + 1; cfg.Add( "Option " + display, () => this.Result($"Option {display} Selected"), testImage ); } cfg.SetDestructive(null, () => this.Result("Destructive BOOM Selected"), testImage); if (cancel) cfg.SetCancel(null, () => this.Result("Cancel Selected"), testImage); var disp = this.Dialogs.ActionSheet(cfg); if (this.AutoCancel) { Task.Delay(TimeSpan.FromSeconds(3)) .ContinueWith(x => disp.Dispose()); } }); }
void ActionSheet() { var cfg = new ActionSheetConfig() .SetTitle("Test Title"); for (var i = 0; i < 5; i++) { var display = (i + 1); cfg.Add( "Option " + display, () => this.Result($"Option {display} Selected") ); } cfg.SetDestructive(action: () => this.Result("Destructive BOOM Selected")); cfg.SetCancel(action: () => this.Result("Cancel Selected")); UserDialogs.Instance.ActionSheet(cfg); }
void ActionSheet() { var cfg = new ActionSheetConfig() .SetTitle("Test Title"); var testImage = BitmapLoader.Current.LoadFromResource("icon.png", null, null).Result; for (var i = 0; i < 5; i++) { var display = (i + 1); cfg.Add( "Option " + display, () => this.Result($"Option {display} Selected"), testImage ); } cfg.SetDestructive(action: () => this.Result("Destructive BOOM Selected")); cfg.SetCancel(action: () => this.Result("Cancel Selected")); UserDialogs.Instance.ActionSheet(cfg); }
private void ActionSheet() { var cfg = new ActionSheetConfig() .SetTitle("Test Title"); for (var i = 0; i < 5; i++) { var display = (i + 1); cfg.Add( "Option " + display, () => this.lblResult.Text = String.Format("Option {0} Selected", display) ); } cfg.SetDestructive(action: () => this.lblResult.Text = "Destructive BOOM Selected"); cfg.SetCancel(action: () => this.lblResult.Text = "Cancel Selected"); UserDialogs.Instance.ActionSheet(cfg); }