/// <summary> /// Shows the specified Alert within the applciation. /// </summary> /// <param name="title">The title.</param> /// <param name="body">The body.</param> /// <param name="content">The content.</param> /// <param name="buttons">The buttons.</param> /// <returns></returns> public async Task Show(string title, string body, View content, List <AlertButton> buttons) { var tcs = new TaskCompletionSource <object>(); var adf = new AlertDialogFragment { Title = title, Body = body, Content = content, Buttons = buttons, tsc = tcs }; var FragmentManager = ((Activity)Forms.Context).FragmentManager; FragmentTransaction ft = FragmentManager.BeginTransaction(); //Remove fragment else it will crash as it is already added to backstack Fragment prev = FragmentManager.FindFragmentByTag("alert"); if (prev != null) { ft.Remove(prev); } ft.AddToBackStack(null); adf.Cancelable = false; adf.Show(ft, "alert"); Log.Debug("TSC", tcs.Task.Status.ToString()); await tcs.Task; }
public async Task Show(string title, string body, View content, List <AlertButton> buttons) { var tcs = new TaskCompletionSource <object>(); var adf = new AlertDialogFragment { Title = title, Body = body, Content = content, Buttons = buttons }; var FragmentManager = ((Activity)Forms.Context).FragmentManager; FragmentTransaction ft = FragmentManager.BeginTransaction(); //Remove fragment else it will crash as it is already added to backstack Fragment prev = FragmentManager.FindFragmentByTag("alert"); if (prev != null) { ft.Remove(prev); } if (title.Contains("welkom")) { tcs.SetResult(null); } ft.AddToBackStack(null); adf.Show(ft, "alert"); await tcs.Task; }