示例#1
0
        /// <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)
            {
                stylesheetProvider = styleSheet,
                Hidden             = true
            };

            messageWindowView.AddSubview(messageView);
            messageWindowView.BringSubviewToFront(messageView);

            messageBarQueue.Enqueue(messageView);

            if (!messageVisible)
            {
                showNextMessage();
            }
        }
示例#2
0
        private void showNextMessage()
        {
            if (messageBarQueue.Count > 0)
            {
                messageVisible = true;
                MessageView messageView = messageBarQueue.Dequeue();
                messageView.Frame  = new RectangleF(0, -messageView.Height, messageView.Width, messageView.Height);
                messageView.Hidden = false;
                messageView.SetNeedsDisplay();

                var gest = new UITapGestureRecognizer(messageTapped);
                messageView.AddGestureRecognizer(gest);

                UIView.Animate(DismissAnimationDuration, () => messageView.Frame = new RectangleF((float)messageView.Frame.X,
                                                                                                  (float)(messageBarOffset + messageView.Frame.Y + messageView.Height), messageView.Width, messageView.Height));

                //Need a better way of dissmissing the method
                var timer = new System.Threading.Timer(dismissMessage, messageView, TimeSpan.FromSeconds(messageView.DisplayDelay), TimeSpan.FromMilliseconds(-1));
            }
        }
示例#3
0
        private void dismissMessage(MessageView messageView, bool clicked)
        {
            if (messageView != null && !messageView.Hit)
            {
                messageView.Hit = true;
                UIView.Animate(DismissAnimationDuration, () => messageView.Frame =
                                   new RectangleF((float)messageView.Frame.X, (float)-(messageView.Frame.Height - messageBarOffset), (float)messageView.Frame.Width, (float)messageView.Frame.Height),
                               () =>
                {
                    messageVisible = false;
                    messageView.RemoveFromSuperview();

                    var action = messageView.OnDismiss;
                    action?.Invoke(clicked);

                    if (messageBarQueue.Count > 0)
                    {
                        showNextMessage();
                    }
                });
            }
        }