/// <summary>
        /// Provides the background colour for message type
        /// </summary>
        /// <returns>The background colour for message type.</returns>
        /// <param name="type">Message type</param>
        public UIColor BackgroundColorForMessageType(ToastNotificationType type)
        {
            UIColor backgroundColor = null;

            switch (type)
            {
            case ToastNotificationType.Error:
                backgroundColor = errorBackgroundColor;
                break;

            case ToastNotificationType.Success:
                backgroundColor = successBackgroundColor;
                break;

            case ToastNotificationType.Info:
                backgroundColor = infoBackgroundColor;
                break;

            case ToastNotificationType.Warning:
                backgroundColor = warningBackgroundColor;
                break;
            }

            return(backgroundColor);
        }
        /// <summary>
        /// Provides the icon for message type
        /// </summary>
        /// <returns>The icon for message type.</returns>
        /// <param name="type">Message type</param>
        public UIImage IconImageForMessageType(ToastNotificationType type)
        {
            UIImage iconImage = null;

            switch (type)
            {
            case ToastNotificationType.Error:
                iconImage = UIImage.FromBundle(ErrorIcon);
                break;

            case ToastNotificationType.Success:
                iconImage = UIImage.FromBundle(SuccessIcon);
                break;

            case ToastNotificationType.Info:
                iconImage = UIImage.FromBundle(InfoIcon);
                break;

            case ToastNotificationType.Warning:
                iconImage = UIImage.FromBundle(WarningIcon);
                break;
            }

            return(iconImage);
        }
        /// <summary>
        /// Provides the stroke colour for message type
        /// </summary>
        /// <returns>The stroke colour for message type.</returns>
        /// <param name="type">Message type</param>
        public UIColor StrokeColorForMessageType(ToastNotificationType type)
        {
            UIColor strokeColor = null;

            switch (type)
            {
            case ToastNotificationType.Error:
                strokeColor = errorStrokeColor;
                break;

            case ToastNotificationType.Success:
                strokeColor = successStrokeColor;
                break;

            case ToastNotificationType.Info:
                strokeColor = infoStrokeColor;
                break;

            case ToastNotificationType.Warning:
                strokeColor = warningStrokeColor;
                break;
            }

            return(strokeColor);
        }
 public static void ToToast(this string message, ToastNotificationType type = ToastNotificationType.Info, string title = null, int millisecondsDelay = 500)
 {
     Device.BeginInvokeOnMainThread(() => {
         var toaster = DependencyService.Get <IToastNotifier>();
         toaster?.Notify(type, title ?? type.ToString().ToUpper(), message, millisecondsDelay);
     });
 }
Example #5
0
        public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();

            MessageBarManager.SharedInstance.ShowMessage(title, description, type, b => taskCompletionSource.TrySetResult(b), duration, _customStyle);
            return(taskCompletionSource.Task);
        }
Example #6
0
 public static void ToToast(this string message, ToastNotificationType type = ToastNotificationType.Info, string title = null)
 {
     Device.BeginInvokeOnMainThread(() => {
         var toaster = DependencyService.Get <IToastNotifier>();
         toaster?.Notify(type, title ?? type.ToString().ToUpper(), message, TimeSpan.FromSeconds(2.5f));
     });
 }
        public Task <bool> Notify(string message, ToastNotificationType type = ToastNotificationType.Info, string title = null)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();

            Toast.MakeText(Forms.Context, message, ToastLength.Short).Show();
            return(taskCompletionSource.Task);
        }
Example #8
0
        public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();

            Toast.MakeText(Forms.Context, description, ToastLength.Short).Show();
            return(taskCompletionSource.Task);
        }
Example #9
0
        public virtual View Render(Activity activity, ToastNotificationType type, string title, string description, object context)
        {
            var view = activity.LayoutInflater.Inflate(Resource.Layout.crouton, null);

            var titleTv = view.FindViewById <TextView>(Resource.Id.title);
            var descTv  = view.FindViewById <TextView>(Resource.Id.desc);
            var image   = view.FindViewById <ImageView>(Resource.Id.image);

            titleTv.Text = title;
            descTv.Text  = description;

            switch (type)
            {
            case ToastNotificationType.Info:
                image.SetImageResource(Resource.Drawable.info);
                view.SetBackgroundColor(new Color(42, 112, 153));
                break;

            case ToastNotificationType.Success:
                image.SetImageResource(Resource.Drawable.success);
                view.SetBackgroundColor(new Color(69, 145, 34));
                break;

            case ToastNotificationType.Warning:
                image.SetImageResource(Resource.Drawable.warning);
                view.SetBackgroundColor(new Color(180, 125, 1));
                break;

            case ToastNotificationType.Error:
                image.SetImageResource(Resource.Drawable.error);
                view.SetBackgroundColor(new Color(206, 24, 24));
                break;

            case ToastNotificationType.Custom:
                _imageSetterForCustomType(context, image);
                view.SetBackgroundColor(_backgroundColorForCustomTypeResolver(context));
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            // First, we get application metrics
            IWindowManager windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast <IWindowManager>();
            var            metrics       = new Android.Util.DisplayMetrics();

            windowManager.DefaultDisplay.GetMetrics(metrics);

            // then we convert statusbar height in dpi to real pixels
            int statusBarDpiHeight = 24;
            int sizeInPixels       = Convert.ToInt32(Math.Ceiling(statusBarDpiHeight * metrics.Density));

            // and least we set the Y of the view to be just under the statusbar
            view.SetY(sizeInPixels);

            return(view);
        }
Example #10
0
		public Task<bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null)
		{
			var taskCompletionSource = new TaskCompletionSource<bool>();

//			global::Android.Views.View parent = ((Activity)Forms.Context).Window.DecorView.FindViewById(16908290);
//			Snackbar.Make(parent, description, Snackbar.LengthLong).Show();
			Toast.MakeText(Forms.Context, description, ToastLength.Short).Show();

			return taskCompletionSource.Task;
		}
Example #11
0
        public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();

//			global::Android.Views.View parent = ((Activity)Forms.Context).Window.DecorView.FindViewById(16908290);
//			Snackbar.Make(parent, description, Snackbar.LengthLong).Show();
            Toast.MakeText(Forms.Context, description, ToastLength.Short).Show();

            return(taskCompletionSource.Task);
        }
Example #12
0
        public static string ToCss(this ToastNotificationType color)
        {
            string colorvalue;

            colorvalue = color == ToastNotificationType.Warning ? "alert alert-warning" :
                         color == ToastNotificationType.Error ? "alert alert-danger" :
                         color == ToastNotificationType.Info ? "alert alert-info" :
                         color == ToastNotificationType.Success ? "alert alert-success" : "";

            return(colorvalue);
        }
Example #13
0
        public virtual View Render(Activity activity, ToastNotificationType type, string title, string description, object context)
        {
            var view = activity.LayoutInflater.Inflate(Resource.Layout.crouton, null);

            var titleTv = view.FindViewById <TextView>(Resource.Id.title);
            var descTv  = view.FindViewById <TextView>(Resource.Id.desc);
            var image   = view.FindViewById <ImageView>(Resource.Id.image);

            titleTv.Text = title;
            descTv.Text  = description;

            switch (type)
            {
            case ToastNotificationType.Info:
                image.SetImageResource(Resource.Drawable.info);
                view.SetBackgroundColor(new Color(42, 112, 153));
                break;

            case ToastNotificationType.Success:
                image.SetImageResource(Resource.Drawable.success);
                view.SetBackgroundColor(new Color(69, 145, 34));
                break;

            case ToastNotificationType.Warning:
                image.SetImageResource(Resource.Drawable.warning);
                view.SetBackgroundColor(new Color(180, 125, 1));
                break;

            case ToastNotificationType.Error:
                image.SetImageResource(Resource.Drawable.error);
                view.SetBackgroundColor(new Color(206, 24, 24));
                break;

            case ToastNotificationType.Custom:
                _imageSetterForCustomType(context, image);
                view.SetBackgroundColor(_backgroundColorForCustomTypeResolver(context));
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            // Only way I could think of doing it without adding a XF reference, but I now have a magic string.
            var isAppCompat = activity.GetType().BaseType.ToString() != "Xamarin.Forms.Platform.Android.FormsApplicationActivity";

            if (isAppCompat)
            {
                // and least we set the Y of the view to be just under the statusbar
                view.SetY(GetStatusBarHeight());
            }

            return(view);
        }
 public Task<bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context, bool clickable = true)
 {
     var taskCompletionSource = new TaskCompletionSource<bool>();
     MessageBarManager.SharedInstance.ShowMessage(title, description, type, b =>
         {
             if (clickable)
             {
                 taskCompletionSource.TrySetResult(b);
             }
         }, duration, _customStyle);
     return taskCompletionSource.Task;
 }
Example #15
0
 private async void ShowRequiredToast(ToastNotificationType type, string message)
 {
     try
     {
         var  notificator = DependencyService.Get <IToastNotificator>();
         bool tapped      = await notificator.Notify(type, "Fill Your Detalis", "Fill your " + message, TimeSpan.FromSeconds(2));
     }
     catch (Exception ex)
     {
         Console.WriteLine("TOAST Error:", ex);
     }
 }
        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);
        }
Example #17
0
		public virtual View Render(Activity activity, ToastNotificationType type, string title, string description, object context)
		{
			var view = activity.LayoutInflater.Inflate(Resource.Layout.crouton, null);

			var titleTv = view.FindViewById<TextView>(Resource.Id.title);
			var descTv = view.FindViewById<TextView>(Resource.Id.desc);
			var image = view.FindViewById<ImageView>(Resource.Id.image);

			titleTv.Text = title;
			descTv.Text = description;

			switch (type)
			{
				case ToastNotificationType.Info:
					image.SetImageResource(Resource.Drawable.info);
					view.SetBackgroundColor(new Color(42, 112, 153));
					break;
				case ToastNotificationType.Success:
					image.SetImageResource(Resource.Drawable.success);
					view.SetBackgroundColor(new Color(69, 145, 34));
					break;
				case ToastNotificationType.Warning:
					image.SetImageResource(Resource.Drawable.warning);
					view.SetBackgroundColor(new Color(180, 125, 1));
					break;
				case ToastNotificationType.Error:
					image.SetImageResource(Resource.Drawable.error);
					view.SetBackgroundColor(new Color(206, 24, 24));
					break;
				case ToastNotificationType.Custom:
					_imageSetterForCustomType(context, image);
					view.SetBackgroundColor(_backgroundColorForCustomTypeResolver(context));
					break;
				default:
					throw new ArgumentOutOfRangeException("type");
			}

			// First, we get application metrics
			IWindowManager windowManager = Application.Context.GetSystemService(Context.WindowService).JavaCast<IWindowManager>();
			var metrics = new Android.Util.DisplayMetrics();
			windowManager.DefaultDisplay.GetMetrics(metrics);

			// then we convert statusbar height in dpi to real pixels
			int statusBarDpiHeight = 24;
			int sizeInPixels = Convert.ToInt32(Math.Ceiling(statusBarDpiHeight * metrics.Density));

			// and least we set the Y of the view to be just under the statusbar
			view.SetY(sizeInPixels);

			return view;
		}
        private MessageView(NSString title, NSString description, ToastNotificationType type)
            : base(RectangleF.Empty)
        {
            BackgroundColor = UIColor.Clear;
            ClipsToBounds = false;
            UserInteractionEnabled = true;
            Title = title;
            Description = description;
            MessageType = type;
            Height = 0.0f;
            Width = 0.0f;
            Hit = false;

            NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification, OrientationChanged);
        }
Example #19
0
        private MessageView(NSString title, NSString description, ToastNotificationType type)
            : base(RectangleF.Empty)
        {
            BackgroundColor        = UIColor.Clear;
            ClipsToBounds          = false;
            UserInteractionEnabled = true;
            this.title             = title;
            this.description       = description;
            messageType            = type;
            Height = 0.0f;
            Width  = 0.0f;
            Hit    = false;

            NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification, orientationChanged);
        }
        /// <summary>
        /// Shows the message
        /// </summary>
        /// <param name="title">Messagebar title</param>
        /// <param name="description">Messagebar description</param>
        /// <param name="type">Message type</param>
        /// <param name = "onDismiss">OnDismiss callback</param>
        /// <param name="duration"></param>
        /// <param name="styleSheet"></param>
        public void ShowMessage(string title, string description, ToastNotificationType type, Action<bool> onDismiss, TimeSpan duration, MessageBarStyleSheet styleSheet = null)
        {
            var messageView = new MessageView(title, description, type, onDismiss, duration);
            messageView.StylesheetProvider = styleSheet;
            messageView.Hidden = true;

            MessageWindowView.AddSubview(messageView);
            MessageWindowView.BringSubviewToFront(messageView);

            _messageBarQueue.Enqueue(messageView);

            if (!_messageVisible)
            {
                ShowNextMessage();
            }
        }
        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);
        }
        /// <summary>
        /// Shows the message
        /// </summary>
        /// <param name="title">Messagebar title</param>
        /// <param name="description">Messagebar description</param>
        /// <param name="type">Message type</param>
        /// <param name = "onDismiss">OnDismiss callback</param>
        /// <param name="duration"></param>
        /// <param name="styleSheet"></param>
        public void ShowMessage(string title, string description, ToastNotificationType type, Action <bool> onDismiss, TimeSpan duration, MessageBarStyleSheet styleSheet = null)
        {
            var messageView = new MessageView(title, description, type, onDismiss, duration);

            messageView.StylesheetProvider = styleSheet;
            messageView.Hidden             = true;

            MessageWindowView.AddSubview(messageView);
            MessageWindowView.BringSubviewToFront(messageView);

            _messageBarQueue.Enqueue(messageView);

            if (!_messageVisible)
            {
                ShowNextMessage();
            }
        }
        public virtual View Render(Activity activity, ToastNotificationType type, string title, string description, object context)
        {
            var view = activity.LayoutInflater.Inflate(Resource.Layout.crouton, null);

            var titleTv = view.FindViewById <TextView>(Resource.Id.title);
            var descTv  = view.FindViewById <TextView>(Resource.Id.desc);
            var image   = view.FindViewById <ImageView>(Resource.Id.image);

            titleTv.Text = title;
            descTv.Text  = description;

            switch (type)
            {
            case ToastNotificationType.Info:
                image.SetImageResource(Resource.Drawable.info);
                view.SetBackgroundColor(new Color(42, 112, 153));
                break;

            case ToastNotificationType.Success:
                image.SetImageResource(Resource.Drawable.success);
                view.SetBackgroundColor(new Color(69, 145, 34));
                break;

            case ToastNotificationType.Warning:
                image.SetImageResource(Resource.Drawable.warning);
                view.SetBackgroundColor(new Color(180, 125, 1));
                break;

            case ToastNotificationType.Error:
                image.SetImageResource(Resource.Drawable.error);
                view.SetBackgroundColor(new Color(206, 24, 24));
                break;

            case ToastNotificationType.Custom:
                _imageSetterForCustomType(context, image);
                view.SetBackgroundColor(_backgroundColorForCustomTypeResolver(context));
                break;

            default:
                throw new ArgumentOutOfRangeException("type");
            }

            return(view);
        }
        public Task<bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context, bool clickable = true)
        {
            var taskCompletionSource = new TaskCompletionSource<bool>();

            Brush brush;
            var element = _customRenderer.Render(type, title, description, context, out brush);

            ToastPromptsHostControl.EnqueueItem(element, b =>
                {
                    if (clickable)
                    {
                        taskCompletionSource.TrySetResult(b);
                    }
                }, brush, 
                tappable: _customRenderer.IsTappable, 
                timeout: duration, 
                showCloseButton: _customRenderer.HasCloseButton);
            return taskCompletionSource.Task;
        }
Example #25
0
		public Task<bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null)
		{
			MessageType msgType = MessageType.Info;

			switch(type)
			{
				case ToastNotificationType.Error:
				case ToastNotificationType.Warning:
					msgType = MessageType.Error;
					break;

				case ToastNotificationType.Success:
					msgType = MessageType.Success;
					break;
			}

			var taskCompletionSource = new TaskCompletionSource<bool>();
			MessageBarManager.SharedInstance.ShowMessage(title, description, msgType, b => taskCompletionSource.TrySetResult(b));
			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>();

            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 =>
                {
                    if (clickable)
                    {
                        taskCompletionSource.TrySetResult(b);
                    }
                }, context);
            crouton.Show();
            return taskCompletionSource.Task;
        }
        public void DisplayToastNotification(ToastNotificationType type, string title, string text, int timeOut = 4000)
        {
            m_htmlToast.Close();

            int offset = 15;

            string cssClass = "w3-success";

            switch (type)
            {
            case ToastNotificationType.Success:
                cssClass = "w3-success";
                break;

            case ToastNotificationType.Warning:
                cssClass = "w3-warning";
                break;

            case ToastNotificationType.Error:
                cssClass = "w3-error ";
                break;
            }

            string html = GenerateHTMLToast(title, text, cssClass);

            int imgHeight = m_htmlToast.GetHTMLHeight(html) + 5;
            int imgWidth  = this.Width - 25;

            m_htmlToast.SetImgSize(imgWidth, imgHeight);
            m_htmlToast.SetHTML(html);



            Rectangle rect           = this.Bounds;
            Point     px             = new Point(rect.Left, rect.Bottom);
            Point     screenLocation = PointToScreen(px);

            m_htmlToast.SetImgLocation(px.X + offset, px.Y - imgHeight - offset);

            m_htmlToast.Show(timeOut);
        }
Example #28
0
        public Task <bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null)
        {
            MessageType msgType = MessageType.Info;

            switch (type)
            {
            case ToastNotificationType.Error:
            case ToastNotificationType.Warning:
                msgType = MessageType.Error;
                break;

            case ToastNotificationType.Success:
                msgType = MessageType.Success;
                break;
            }

            var taskCompletionSource = new TaskCompletionSource <bool>();

            MessageBarManager.SharedInstance.ShowMessage(title, description, msgType, b => taskCompletionSource.TrySetResult(b));
            return(taskCompletionSource.Task);
        }
        /// <summary>
        /// Provides the background colour for message type
        /// </summary>
        /// <returns>The background colour for message type.</returns>
        /// <param name="type">Message type</param>
        public virtual UIColor BackgroundColorForMessageType(ToastNotificationType type)
        {
            UIColor backgroundColor = null;
            switch (type)
            {
                case ToastNotificationType.Error:
                    backgroundColor = _errorBackgroundColor;
                    break;
                case ToastNotificationType.Success:
                    backgroundColor = _successBackgroundColor;
                    break;
                case ToastNotificationType.Info:
                    backgroundColor = _infoBackgroundColor;
                    break;
                case ToastNotificationType.Warning:
                    backgroundColor = _warningBackgroundColor;
                    break;
            }

            return backgroundColor;
        }
Example #30
0
        public Task <bool> Notify(ToastNotificationType type, string title, string description, int millisecondsDelay = 500)
        {
            var taskCompletionSource = new TaskCompletionSource <bool>();
            var toast = Toast.MakeText(Forms.Context, description, ToastLength.Short);

            toast.Show();

            if (millisecondsDelay > 0)
            {
                Task.Delay(millisecondsDelay).ContinueWith(t =>
                {
                    try
                    {
                        toast.Cancel();
                    }
                    catch { }
                }).ConfigureAwait(false);
            }

            return(taskCompletionSource.Task);
        }
        public virtual View Render(Activity activity, ToastNotificationType type, string title, string description, object context)
        {
            var view = activity.LayoutInflater.Inflate(Resource.Layout.crouton, null);

            var titleTv = view.FindViewById<TextView>(Resource.Id.title);
            var descTv = view.FindViewById<TextView>(Resource.Id.desc);
            var image = view.FindViewById<ImageView>(Resource.Id.image);

            titleTv.Text = title;
            descTv.Text = description;

            switch (type)
            {
                case ToastNotificationType.Info:
                    image.SetImageResource(Resource.Drawable.info);
                    view.SetBackgroundColor(new Color(42, 112, 153));
                    break;
                case ToastNotificationType.Success:
                    image.SetImageResource(Resource.Drawable.success);
                    view.SetBackgroundColor(new Color(69, 145, 34));
                    break;
                case ToastNotificationType.Warning:
                    image.SetImageResource(Resource.Drawable.warning);
                    view.SetBackgroundColor(new Color(180, 125, 1));
                    break;
                case ToastNotificationType.Error:
                    image.SetImageResource(Resource.Drawable.error);
                    view.SetBackgroundColor(new Color(206, 24, 24));
                    break;
                case ToastNotificationType.Custom:
                    _imageSetterForCustomType(context, image);
                    view.SetBackgroundColor(_backgroundColorForCustomTypeResolver(context));
                    break;
                default:
                    throw new ArgumentOutOfRangeException("type");
            }

            return view;
        }
Example #32
0
        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);
        }
Example #33
0
        public void ShowToastMessage(string title, string message, ToastNotificationType toastNotificationType)
        {
            try
            {
                Color toastbackgroundColor;
                switch (toastNotificationType)
                {
                case ToastNotificationType.Success:
                    toastbackgroundColor = Color.Green;
                    break;

                case ToastNotificationType.Error:
                    toastbackgroundColor = Color.Red;
                    break;

                case ToastNotificationType.Warning:
                    toastbackgroundColor = Color.Orange;
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(toastNotificationType), toastNotificationType, null);
                }

                _userDialogs.Toast(new ToastConfig(title)
                {
                    Action           = null,
                    BackgroundColor  = toastbackgroundColor,
                    Duration         = TimeSpan.FromSeconds(3),
                    Message          = message,
                    MessageTextColor = Color.White
                });
            }
            catch (Exception exception)
            {
                _loggingService.Error(exception);
            }
        }
        public static void CreateToast(ToastNotificationType toastType, string text)
        {
            try
            {
                string toastTitile;
                switch (toastType)
                {
                case ToastNotificationType.Error:
                    toastTitile = ResX.TextResource.Error;
                    break;

                case ToastNotificationType.Success:
                    toastTitile = ResX.TextResource.Success;
                    break;

                case ToastNotificationType.Warning:
                    toastTitile = ResX.TextResource.Warning;
                    break;

                case ToastNotificationType.Info:
                    toastTitile = ResX.TextResource.Info;
                    break;

                default:
                    toastTitile = ResX.TextResource.Info;
                    break;
                }

                Device.BeginInvokeOnMainThread(
                    () => { Notificator.Notify(toastType, toastTitile, text, TimeSpan.FromSeconds(2.0d)); });
            }
            catch (Exception e)
            {
                // ignored
            }
        }
Example #35
0
 private async void ShowToast(ToastNotificationType type)
 {
     var  notificator = DependencyService.Get <IToastNotificator>();
     bool tapped      = await notificator.Notify(type, "Some " + type.ToString().ToLower(), "Some description", TimeSpan.FromSeconds(2));
 }
 public Task NotifySticky(ToastNotificationType type, string title, string description, object context = null,
                          bool clickable = true, CancellationToken cancellationToken = default(CancellationToken), bool modal = false)
 {
     throw new NotImplementedException("yet");
 }
        /// <summary>
        /// Provides the stroke colour for message type
        /// </summary>
        /// <returns>The stroke colour for message type.</returns>
        /// <param name="type">Message type</param>
        public virtual UIColor StrokeColorForMessageType(ToastNotificationType type)
        {
            UIColor strokeColor = null;
            switch (type)
            {
                case ToastNotificationType.Error:
                    strokeColor = _errorStrokeColor;
                    break;
                case ToastNotificationType.Success:
                    strokeColor = _successStrokeColor;
                    break;
                case ToastNotificationType.Info:
                    strokeColor = _infoStrokeColor;
                    break;
                case ToastNotificationType.Warning:
                    strokeColor = _warningStrokeColor;
                    break;
            }

            return strokeColor;
        }
Example #38
0
 internal MessageView(string title, string description, ToastNotificationType type, Action <bool> onDismiss, TimeSpan duration)
     : this((NSString)title, (NSString)description, type)
 {
     OnDismiss    = onDismiss;
     DisplayDelay = duration.TotalSeconds;
 }
		public Task ShowToastMessage (ToastNotificationType type, string title, string content)
		{
			return _notificator.Notify (type, title, content, TimeSpan.FromSeconds (2));
		}
Example #40
0
		private async void ShowRequiredToast(ToastNotificationType type, string message)
		{
			try
			{
				var notificator = DependencyService.Get<IToastNotificator>();
				bool tapped = await notificator.Notify(type, "Fill Your Detalis", "Fill your " + message, TimeSpan.FromSeconds(2));
			}
			catch (Exception ex)
			{
				Console.WriteLine("TOAST Error:", ex);
			}

		}
Example #41
0
		public static void ShowNotification (ToastNotificationType infoType, string title, string message)
		{
			Device.BeginInvokeOnMainThread (() => {
				Notificator.Notify (infoType, title, message, TimeSpan.FromSeconds (2));
				DoVibrate ();
			});
		}
Example #42
0
 protected Task <bool> ShowToast(ToastNotificationType type, string title, string description)
 {
     return(_notificator.Notify(type, title, description, TimeSpan.FromSeconds(2)));
 }
 internal MessageView(string title, string description, ToastNotificationType type, Action<bool> onDismiss, TimeSpan duration)
     : this((NSString)title, (NSString)description, type)
 {
     OnDismiss = onDismiss;
     DisplayDelay = duration.TotalSeconds;
 }
        public void notify(string title, string message,
			ToastNotificationType Type = ToastNotificationType.Success,
			int seconds=1)
        {
            Debug.WriteLine(string.Format("{0}:{1}", title, message));
            if(ClockKingOptions.TracingEnabled)
                iiToastNotifier.Notify (Type, title, message, TimeSpan.FromSeconds (seconds), null, false);
        }
Example #45
0
 private async void ShowToast(ToastNotificationType type, string titulo, string descripcion, int tiempo)
 {
     var  notificator = DependencyService.Get <IToastNotificator>();
     bool tapped      = await notificator.Notify(type, titulo, descripcion, TimeSpan.FromSeconds(tiempo));
 }
        public virtual UIElement Render(ToastNotificationType type, string title, string description, object context, out Brush brush)
        {
            BitmapImage iconImage = null;

            switch (type)
            {
                case ToastNotificationType.Success:
                    brush = new SolidColorBrush(Color.FromArgb(255, 69, 145, 34));
                    iconImage = LoadBitmapImage("success.png");
                    break;
                case ToastNotificationType.Warning:
                    brush = new SolidColorBrush(Color.FromArgb(255, 180, 125, 1));
                    iconImage = LoadBitmapImage("warning.png");
                    break;
                case ToastNotificationType.Error:
                    brush = new SolidColorBrush(Color.FromArgb(255, 206, 24, 24));
                    iconImage = LoadBitmapImage("error.png");
                    break;
                case ToastNotificationType.Info: //info by default
                    brush = new SolidColorBrush(Color.FromArgb(255, 42, 112, 153));
                    iconImage = LoadBitmapImage("info.png");
                    break;
                case ToastNotificationType.Custom:
                    brush = _backgroundForCustomTypeResolver(context);
                    iconImage = _iconForCustomTypeResolver(context);
                    break;
                default:
                    throw new ArgumentException(type.ToString());
            }

            //this actually could be done in XAML, but I decided not to waste performance on XAML parsing
            //since UI is simple and if you want - you can override it by implementing IToastLayoutCustomRenderer

            var titleTb = new TextBlock
            {
                Text = title,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(12, 6, 0, 0),
                TextTrimming = TextTrimming.None,
                TextWrapping = TextWrapping.NoWrap,
                Foreground = new SolidColorBrush(Colors.White),
                FontSize = 22,
                FontWeight = FontWeights.Bold
            };
            Grid.SetColumn(titleTb, 1);
            Grid.SetRow(titleTb, 0);

            var descTb = new TextBlock
            {
                Text = description,
                VerticalAlignment = VerticalAlignment.Center,
                Margin = new Thickness(12, -4, 0, 0),
                TextTrimming = TextTrimming.WordEllipsis,
                TextWrapping = TextWrapping.NoWrap,
                Foreground = new SolidColorBrush(Colors.White),
                FontSize = 18
            };
            Grid.SetColumn(descTb, 1);
            Grid.SetRow(descTb, 1);

            Grid layout = new Grid();
            layout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Auto) });
            layout.ColumnDefinitions.Add(new ColumnDefinition());
            layout.RowDefinitions.Add(new RowDefinition());
            layout.RowDefinitions.Add(new RowDefinition());

            layout.Children.Add(titleTb);
            layout.Children.Add(descTb);

            if (iconImage != null) //do not add image if iconImage is empty
            {
                Image image = new Image
                {
                    Width = 42,
                    Height = 42,
                    Margin = new Thickness(10, 0, 0, 0),
                    VerticalAlignment = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Source = iconImage
                };
                Grid.SetRowSpan(image, 2);
                layout.Children.Add(image);
            }
            
            return layout;
        }
Example #47
0
 private async void ShowToast(ToastNotificationType type)
 {
     var notificator = DependencyService.Get<IToastNotificator>();
     bool tapped = await notificator.Notify(type, "Some " + type.ToString().ToLower(), "Some description", TimeSpan.FromSeconds(2));
 }
Example #48
0
 /// <summary>
 /// Shows a notification near the tray icon.
 /// </summary>
 /// <param name="tipText"></param>
 /// <param name="tipTitle"></param>
 /// <param name="timeout"></param>
 /// <param name="type"></param>
 public void TrayNotification(string tipText, string tipTitle = "",
                              ToastNotificationType type      = ToastNotificationType.None, int timeout = int.MaxValue)
 => Application.Current.Dispatcher.Invoke(() => _tray.Notification(tipText, tipTitle, type, timeout));
 public Task NotifySticky(ToastNotificationType type, string title, string description, object context = null,
     bool clickable = true, CancellationToken cancellationToken = default (CancellationToken), bool modal = false)
 {
     throw new NotImplementedException("yet");
 }
Example #50
0
		public Task<bool> Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context = null)
		{
			var taskCompletionSource = new TaskCompletionSource<bool>();
			Toast.MakeText(Forms.Context, description, ToastLength.Short).Show();
			return taskCompletionSource.Task;
		}
        /// <summary>
        /// Provides the icon for message type
        /// </summary>
        /// <returns>The icon for message type.</returns>
        /// <param name="type">Message type</param>
        public virtual UIImage IconImageForMessageType(ToastNotificationType type)
        {
            UIImage iconImage = null;
            switch (type)
            {
                case ToastNotificationType.Error:
                    iconImage = UIImage.FromBundle(ErrorIcon);
                    break;
                case ToastNotificationType.Success:
                    iconImage = UIImage.FromBundle(SuccessIcon);
                    break;
                case ToastNotificationType.Info:
                    iconImage = UIImage.FromBundle(InfoIcon);
                    break;
                case ToastNotificationType.Warning:
                    iconImage = UIImage.FromBundle(WarningIcon);
                    break;
            }

            return iconImage;
        }
 Task<bool> IToastNotificator.Notify(ToastNotificationType type, string title, string description, TimeSpan duration, object context)
 {
     var taskCompletionSource = new TaskCompletionSource<bool>();
     taskCompletionSource.TrySetResult(true);
     return taskCompletionSource.Task;
 }