/// <summary> /// Create the specified target, title, text, okText, cancelText, okButtonColor, cancelButtonColor, okTextColor and cancelTextColor. /// </summary> /// <returns>The create.</returns> /// <param name="target">Target.</param> /// <param name="title">Title.</param> /// <param name="text">Text.</param> /// <param name="okText">Ok text.</param> /// <param name="cancelText">Cancel text.</param> /// <param name="okButtonColor">Ok button color.</param> /// <param name="cancelButtonColor">Cancel button color.</param> /// <param name="okTextColor">Ok text color.</param> /// <param name="cancelTextColor">Cancel text color.</param> public static PermissionPopup Create(VisualElement target, string title, string text, string okText = "OK", string cancelText = "Cancel", Color okButtonColor = default, Color cancelButtonColor = default, Color okTextColor = default, Color cancelTextColor = default) { var popup = new PermissionPopup(target) { Title = title, Text = text, OkText = okText, CancelText = cancelText }; if (okTextColor != default) { popup.OkTextColor = okTextColor; } if (okButtonColor != default) { popup.OkButtonColor = okButtonColor; } if (cancelTextColor != default) { popup.CancelTextColor = cancelTextColor; } if (cancelButtonColor != default) { popup.CancelButtonColor = cancelButtonColor; } popup.IsVisible = true; return(popup); }
/// <summary> /// Create the specified title, text, okText, cancelText, okButtonColor, cancelButtonColor, okTextColor and cancelTextColor. /// </summary> /// <param name="title">Title.</param> /// <param name="text">Text.</param> /// <param name="okText">Ok text.</param> /// <param name="cancelText">Cancel text.</param> /// <param name="okButtonColor">Ok button color.</param> /// <param name="cancelButtonColor">Cancel button color.</param> /// <param name="okTextColor">Ok text color.</param> /// <param name="cancelTextColor">Cancel text color.</param> public static PermissionPopup Create(string title, string text, string okText = "OK", string cancelText = "Cancel", Color okButtonColor = default, Color cancelButtonColor = default, Color okTextColor = default, Color cancelTextColor = default, FeedbackEffect pushedFeedback = FeedbackEffect.Inquiry) { var popup = new PermissionPopup { Title = title, Text = text, OkText = okText, CancelText = cancelText }; if (okTextColor != default) { popup.OkTextColor = okTextColor; } if (okButtonColor != default) { popup.OkButtonColor = okButtonColor; } if (cancelTextColor != default) { popup.CancelTextColor = cancelTextColor; } if (cancelButtonColor != default) { popup.CancelButtonColor = cancelButtonColor; } popup.PushedFeedback = pushedFeedback; popup.IsVisible = true; return(popup); }
/// <summary> /// Used internally to communicate with user when perplexing exception is triggered; /// </summary> /// <param name="e">Exception thrown that prompted request for help</param> /// <param name="additionalInfo">Any additional info you would like shared with you </param> /// <param name="path">Path to file where this request was called</param> /// <param name="lineNumber">Linenumber of where this request was called</param> /// <param name="methodName">Name of method from which this request was called</param> /// <returns></returns> public static async Task RequestUserHelp(Exception e, string additionalInfo = null, [System.Runtime.CompilerServices.CallerFilePath] string path = null, [System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = -1, [System.Runtime.CompilerServices.CallerMemberName] string methodName = null) { if (IsRequestUserHelpEnabled) { using (var popup = PermissionPopup.Create(RequestUserHelpMissiveTitle, RequestUserHelpMissiveMessage)) { popup.IsVisible = true; await popup.WaitForPoppedAsync(); if (popup.PermissionState == PermissionState.Ok) { var info = ""; if (!(e is null)) { info += "Exception Type: " + e.GetType() + "\n\nMessage: " + e.Message; } info += "\n\nMethod: " + methodName + "\n\nLine Number: " + lineNumber + "\n\nPath: " + path; if (!string.IsNullOrWhiteSpace(additionalInfo)) { info += "\n\nAdditionalInfo: " + additionalInfo; } info += "\n\nDeviceType: " + Xamarin.Essentials.DeviceInfo.DeviceType; info += "\n\nIdiom: " + Xamarin.Essentials.DeviceInfo.Idiom; info += "\n\nManufacturer : " + Xamarin.Essentials.DeviceInfo.Manufacturer; info += "\n\nModel : " + Xamarin.Essentials.DeviceInfo.Model; info += "\n\nPlatform : " + Xamarin.Essentials.DeviceInfo.Platform; info += "\n\nVersion : " + Xamarin.Essentials.DeviceInfo.Version; info += "\n\nVersionString : " + Xamarin.Essentials.DeviceInfo.VersionString; info += "\n\nStack Trace: " + (e?.StackTrace ?? Environment.StackTrace); try { var message = new EmailMessage { Subject = "Help with bug", Body = "I'm willing to help. Below is some information about what happened.\n\n" + info, To = new List <string> { RequestUserHelpEmailToAddress }, //Cc = ccRecipients, //Bcc = bccRecipients }; await Email.ComposeAsync(message); } catch (Exception) { using (var toast = Toast.Create("Email not available", "Email cannot be opened directly from this app ... but I still would like your help. Could you email me at [email protected] and include (via copy and paste into your email) the below information? Thank you for considering this! \n\n <b>INFORMATION:</b>\n\n" + info)) { } } } } } }