Exemple #1
0
 /// <summary>
 /// ShowToastSuccess
 /// </summary>
 /// <param name="message"></param>
 public void ShowToastSuccess(string message, Plugin.Toast.Abstractions.ToastLength toastLength = ToastLength.Short)
 {
     ShowToast(message, "#70B771", "#ffffff", toastLength);
 }
Exemple #2
0
 /// <summary>
 /// Show Custom Toast
 /// </summary>
 /// <param name="message"></param>
 /// <param name="bgColor"></param>
 /// <param name="txtColor"></param>
 public void ShowCustomToast(string message, string bgColor, string txtColor, Plugin.Toast.Abstractions.ToastLength toastLength = ToastLength.Short)
 {
     ShowToast(message, bgColor, txtColor, toastLength);
 }
Exemple #3
0
 /// <summary>
 /// ShowToastWarning
 /// </summary>
 /// <param name="message"></param>
 public void ShowToastWarning(string message, Plugin.Toast.Abstractions.ToastLength toastLength = ToastLength.Short)
 {
     ShowToast(message, "#faaa1d", "#ffffff", toastLength);
 }
Exemple #4
0
 /// <summary>
 /// ShowToastError
 /// </summary>
 /// <param name="message"></param>
 public void ShowToastError(string message, Plugin.Toast.Abstractions.ToastLength toastLength = ToastLength.Short)
 {
     ShowToast(message, "#9f333c", "#ffffff", toastLength);
 }
Exemple #5
0
 /// <summary>
 /// Show Message
 /// in a Toast
 /// </summary>
 /// <param name="message"></param>
 public void ShowToastMessage(string message, Plugin.Toast.Abstractions.ToastLength toastLength = ToastLength.Short)
 {
     ShowToast(message, "#000000", "#ffffff", toastLength);
 }
Exemple #6
0
        private void ShowToast(string message, string backgroundHexColor = null, string textHexColor = null, Plugin.Toast.Abstractions.ToastLength toastLength = ToastLength.Short)
        {
            var delay = toastLength == ToastLength.Short ? ShortDelay : LongDelay;

            _alert?.Dispose();
            _alertDelay = NSTimer.CreateScheduledTimer(delay, (obj) =>
            {
                DismissMessage();
            });

            _alert = UIAlertController.Create(null, message, UIAlertControllerStyle.Alert);
            var tView = _alert.View;

            if (!string.IsNullOrEmpty(backgroundHexColor))
            {
                var firstSubView     = tView.Subviews?.FirstOrDefault();
                var alertContentView = firstSubView?.Subviews?.FirstOrDefault();
                if (alertContentView != null)
                {
                    foreach (UIView uiView in alertContentView.Subviews)
                    {
                        uiView.BackgroundColor = UIColor.Clear.FromHexString(backgroundHexColor);
                    }
                }
            }
            var attributedString = new NSAttributedString(message, foregroundColor: UIColor.Clear.FromHexString(textHexColor ?? "#000000"));

            _alert.SetValueForKey(attributedString, new NSString("attributedMessage"));
            IosHelper.GetVisibleViewController().PresentViewController(_alert, true, null);
        }
Exemple #7
0
 private void ShowToast(string message, string backgroundHexColor = null, string textHexColor = null, Plugin.Toast.Abstractions.ToastLength toastLength = ToastLength.Short)
 {
     if (_lastAlertDelay != null && _lastAlert != null)
     {
         DismissMessage(_lastAlert, _lastAlertDelay, () => { CreateToast(message, backgroundHexColor, textHexColor, toastLength); });
     }
     else
     {
         CreateToast(message, backgroundHexColor, textHexColor, toastLength);
     }
 }