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;
                    if (action != null)
                    {
                        action(clicked);
                    }

                    if (_messageBarQueue.Count > 0)
                    {
                        ShowNextMessage();
                    }
                });
            }
        }
        /// <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();
            }
        }
        /// <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();
            }
        }
        /// <summary>
        /// Hides all messages
        /// </summary>
        public void HideAll()
        {
            MessageView currentMessageView = null;
            var         subviews           = MessageWindowView.Subviews;

            foreach (UIView subview in subviews)
            {
                var view = subview as MessageView;
                if (view != null)
                {
                    currentMessageView = view;
                    currentMessageView.RemoveFromSuperview();
                }
            }

            _messageVisible = false;
            _messageBarQueue.Clear();
            CancelPreviousPerformRequest(this);
        }
        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 dismiss = new Timer(DismissMessage, messageView, TimeSpan.FromSeconds(messageView.DisplayDelay), TimeSpan.FromMilliseconds(-1));
            }
        }
        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;
                        if (action != null)
                            action(clicked);

                        if (_messageBarQueue.Count > 0)
                            ShowNextMessage();
                    });
            }
        }