public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context) { var taskCompletionSource = new TaskCompletionSource <bool>(); Brush brush; var element = _customRenderer.Render(type, title, description, context, out brush); ToastPromtsHostControl.EnqueueItem(element, b => taskCompletionSource.TrySetResult(b), brush, tappable: _customRenderer.IsTappable, timeout: duration, showCloseButton: _customRenderer.HasCloseButton); return(taskCompletionSource.Task); }
public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null) { var taskCompletionSource = new TaskCompletionSource <bool>(); Activity currentActivity = Xamarin.Forms.Forms.Context as Activity; if (currentActivity == null) { return(Task.FromResult(false)); } View view = _customRenderer.Render(currentActivity, type, title, description, context); Crouton crouton = new Crouton(currentActivity, view, (int)duration.TotalMilliseconds, b => taskCompletionSource.TrySetResult(b), context); crouton.Show(); return(taskCompletionSource.Task); }
public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null, bool clickable = true) { var taskCompletionSource = new TaskCompletionSource <bool>(); if (activity == null) { return(Task.FromResult(false)); } var view = customRenderer.Render(activity, type, title, description, context); var crouton = new Crouton(activity, view, (int)duration.TotalMilliseconds, b => { if (clickable) { taskCompletionSource.TrySetResult(b); } }, context); crouton.Show(); return(taskCompletionSource.Task); }