private void OnKeyboardDidShowNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }
            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

            MainScrollBottomConstraint.Constant = keyboardFrame.Height;
            View.UpdateConstraints();
        }
Ejemplo n.º 2
0
        protected virtual void OnKeyboardShow(NSNotification notification)
        {
            if (!IsViewLoaded || _isKeyboardShown)
            {
                return;
            }
            _isKeyboardShown = true;
            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

            ShiftPageUp(keyboardFrame.Height);
        }
        protected virtual void OnKeyboardShow(NSNotification notification)
        {
            if (!IsViewLoaded || _isKeyboardShown)
            {
                return;
            }

            _isKeyboardShown = true;
            var activeView = View.FindFirstResponder();

            var viewType            = activeView.GetType();
            var superView           = activeView.Superview.GetType();
            var superDuperView      = activeView.Superview.Superview.GetType();
            var superDuperSuperView = activeView.Superview.Superview.Superview.GetType();

            Console.WriteLine($"************* viewType: {viewType.FullName}");
            Console.WriteLine($"************* superView: {superView.FullName}");
            Console.WriteLine($"************* superDuperView: {superDuperView.FullName}");
            Console.WriteLine($"************* superDuperSuperView: {superDuperSuperView.FullName}");

            if (activeView == null)
            {
                return;
            }

            if (superDuperView.BaseType == typeof(UIWebView))
            {
                return;
            }


            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);
            var isOverlapping = activeView.IsKeyboardOverlapping(View, keyboardFrame);

            if (!isOverlapping)
            {
                return;
            }

            if (isOverlapping)
            {
                if (viewType == typeof(UIWebView))
                {
                    Console.WriteLine("Found WebView");
                }
                else
                {
                    _lastActiveView     = activeView;
                    _activeViewBottom   = activeView.GetViewRelativeBottom(View);
                    _lastKeyboardHeight = keyboardFrame.Height;
                    ShiftPageUp(_lastKeyboardHeight, _activeViewBottom);
                }
            }
        }
Ejemplo n.º 4
0
        protected virtual void OnKeyboardShow(NSNotification notification)
        {
            if (isKeyboardShown)
            {
                return;
            }

            var rect = UIKeyboard.FrameEndFromNotification(notification);

            KeyboardWillShow?.Invoke(this, rect.Height);
        }
Ejemplo n.º 5
0
        private void OnKeyboardNotification(NSNotification notification)
        {
            var visible       = notification.Name == UIKeyboard.WillShowNotification;
            var keyboardFrame = visible
                ? UIKeyboard.FrameEndFromNotification(notification)
                : UIKeyboard.FrameBeginFromNotification(notification);

            if (KeyboardChanged != null)
            {
                KeyboardChanged(this, new KeyboardHelperEventArgs(visible, (float)keyboardFrame.Height));
            }
        }
        private void OnKeyboardNotification(NSNotification notification)
        {
            NSNumber duration = (NSNumber)notification.UserInfo[UIKeyboard.AnimationDurationUserInfoKey];

            int animationDuration = (int)(duration.FloatValue * 1000);

            var visible       = notification.Name == UIKeyboard.WillShowNotification;
            var keyboardFrame = visible
                ? UIKeyboard.FrameEndFromNotification(notification)
                : UIKeyboard.FrameBeginFromNotification(notification);

            KeyboardVisibilityChanged?.Invoke(this, new KeyboardVisibilityEventArgs(visible, (float)keyboardFrame.Height, animationDuration));
        }
        private void OnKeyboardNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            var visible = notification.Name == UIKeyboard.WillShowNotification;

            var keyboardFrame = visible ? UIKeyboard.FrameEndFromNotification(notification) : UIKeyboard.FrameBeginFromNotification(notification);

            OnKeyboardChanged(visible, keyboardFrame.Height);
        }
Ejemplo n.º 8
0
        void OnKeyboardNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            var frameBegin = UIKeyboard.FrameBeginFromNotification(notification);
            var frameEnd   = UIKeyboard.FrameEndFromNotification(notification);
            var bounds     = Element.Bounds;
            var newBounds  = new Rectangle(bounds.Left, bounds.Top, bounds.Width, bounds.Height - frameBegin.Top + frameEnd.Top);

            Element.Layout(newBounds);
        }
Ejemplo n.º 9
0
 private void OnKeyboardNotification(NSNotification notification)
 {
     if (IsViewLoaded)
     {
         //Check if the keyboard is becoming visible
         bool visible = notification.Name == UIKeyboard.WillShowNotification;
         UIView.Animate(UIKeyboard.AnimationDurationFromNotification(notification), () => {
             UIView.SetAnimationCurve((UIViewAnimationCurve)UIKeyboard.AnimationCurveFromNotification(notification));
             var frame      = UIKeyboard.FrameEndFromNotification(notification);
             keyboardOffset = visible ? frame.Height : 0;
             ViewDidLayoutSubviews();
         });
     }
 }
Ejemplo n.º 10
0
        private void OnKeyboardHide(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

            if (_pageWasShiftedUp)
            {
                ShiftPageDown(keyboardFrame.Height, _activeViewBottom);
            }
        }
Ejemplo n.º 11
0
        private void OnKeyboardWillHide(object sender, UIKeyboardEventArgs e)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            _isKeyboardShown = false;
            var keyboardFrame = UIKeyboard.FrameEndFromNotification(e.Notification);

            if (_pageWasShiftedUp)
            {
                ShiftPageDown(keyboardFrame.Height, _activeViewBottom);
            }
        }
Ejemplo n.º 12
0
        private void OnKeyboardHide(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            _isKeyboardShown = false;
            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

            if (_pageWasShiftedUp)
            {
                ResetPagePositon(keyboardFrame.Height);
            }
        }
Ejemplo n.º 13
0
        void OnKeyboardNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }
            var frameBegin = UIKeyboard.FrameBeginFromNotification(notification);
            var frameEnd   = UIKeyboard.FrameEndFromNotification(notification);
            var bounds     = Element.Bounds;
            var newBounds  = new Xamarin.Forms.Rectangle(bounds.Left, bounds.Top, bounds.Width, bounds.Height - frameBegin.Top + frameEnd.Top);

            Element.Layout(newBounds);

            this.replaceKeyboardInputAccessoryView();
        }
Ejemplo n.º 14
0
        private void OnKeyboardNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            //Check if the keyboard is becoming visible
            var visible = notification.Name == UIKeyboard.WillShowNotification;

            //Pass the notification, calculating keyboard height, etc.
            var keyboardFrame = visible ? UIKeyboard.FrameEndFromNotification(notification) : UIKeyboard.FrameBeginFromNotification(notification);

            OnKeyboardChanged(visible, ((float)keyboardFrame.Height));
        }
Ejemplo n.º 15
0
        protected virtual void OnKeyboardShow(NSNotification notification)
        {
            if (!IsViewLoaded || _isKeyboardShown)
            {
                return;
            }

            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

            if (keyboardFrame.Height == 0)
            {
                // Happens when rotating the device, this is called multiple times and eventually
                // the frame is correct (height > 0)
                return;
            }

            _isKeyboardShown = true;
            var activeView = FindFirstResponder(View);

            if (activeView == null)
            {
                return;
            }

            double offset = 0;

            if (activeView.Superview is IVisualElementRenderer renderer)
            {
                if (renderer.Element is View view)
                {
                    // Honors the Xamarin.Forms element margin
                    offset = view.Margin.Bottom;
                }
            }

            var isOverlapping = IsKeyboardOverlapping(activeView, keyboardFrame, offset);

            if (!isOverlapping)
            {
                return;
            }

            if (isOverlapping)
            {
                _activeViewBottom = GetViewRelativeBottom(activeView, offset);
                ShiftPageUp(keyboardFrame, _activeViewBottom);
            }
        }
        private void OnKeyboardNotification(NSNotification notification)
        {
            var visible       = notification.Name == UIKeyboard.WillShowNotification;
            var keyboardFrame = visible
                ? UIKeyboard.FrameEndFromNotification(notification)
                : UIKeyboard.FrameBeginFromNotification(notification);

            if (visible)
            {
                this.SetContentOffset(new CGPoint(this.Frame.Left, (this.Frame.Height - keyboardFrame.Height) / 2), false);
            }
            else
            {
                this.SetContentOffset(new CGPoint(this.Frame.Left, this.Frame.Top), false);
            }
        }
Ejemplo n.º 17
0
        private void OnKeyboardWillShowNotification(NSNotification notification)
        {
            if (!IsViewLoaded || View.Window == null)
            {
                return;
            }


            double duration = UIKeyboard.AnimationDurationFromNotification(notification);

            //Pass the notification, calculating keyboard height, etc.
            var    keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);
            nfloat newConstant   = keyboardFrame.Height;

            UIView.Animate(duration, () => bottomContraint.Constant = newConstant, null);
        }
Ejemplo n.º 18
0
        public static void KeyboardWillShow(this NSNotification notification, ref bool keyboardIsShown, UIScrollView containerView)
        {
            if (keyboardIsShown)
            {
                return;
            }

            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

            Action animation = () => {
                containerView.SetContentOffset(new CGPoint(containerView.ContentOffset.X, containerView.ContentOffset.Y + keyboardFrame.Height - 30), true);
            };

            UIScrollView.Animate(200d, 0d, UIViewAnimationOptions.CurveLinear, animation, null);

            keyboardIsShown = true;
        }
        private void OnKeyboardNotification(NSNotification notification)
        {
            var visible = notification.Name == UIKeyboard.WillShowNotification;

            keyboardHeight = visible
                ? UIKeyboard.FrameEndFromNotification(notification).Height
                : 0.0;

            if (finishedPresenting && ContainerView != null && PresentedViewController.PresentedViewController == null)
            {
                var animationDuration = UIKeyboard.AnimationDurationFromNotification(notification);
                AnimationExtensions.Animate(animationDuration, Animation.Curves.StandardEase, ContainerViewWillLayoutSubviews);
            }
            else if (PresentingViewController == null)
            {
                ContainerView?.SetNeedsLayout();
            }
        }
Ejemplo n.º 20
0
        void OnHideNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }
            MainTabbedPage.theModelEntryPage.KeyboardIsDown();
            var frameBegin = UIKeyboard.FrameBeginFromNotification(notification);
            var frameEnd   = UIKeyboard.FrameEndFromNotification(notification);
            var bounds     = Element.Bounds;
            // var cover = 2 * MainTabbedPage.buttonHeightRequest + 20; // Height of the two bottom bars plus some random spacing
            var newBounds = new Rectangle(bounds.Left, bounds.Top, bounds.Width,
                                          bounds.Height - frameBegin.Top + frameEnd.Top
                                          // - cover // This causes random loss of the bottom toolbar
                                          );

            Element.Layout(newBounds);
        }
Ejemplo n.º 21
0
        void OnKeyboardNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            var frameBegin = UIKeyboard.FrameBeginFromNotification(notification);
            var frameEnd   = UIKeyboard.FrameEndFromNotification(notification);

            var page = Element as ContentPage;

            if (page != null && !(page.Content is ScrollView))
            {
                var padding = page.Padding;
                page.Padding = new Thickness(padding.Left, padding.Top, padding.Right, padding.Bottom + frameBegin.Top - frameEnd.Top);
            }
        }
        private void OnKeyboardHide(NSNotification notification)
        {
            if (contentScrollView == null)
            {
                if (!IsViewLoaded)
                {
                    return;
                }

                _isKeyboardShown = false;
                var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

                if (_pageWasShiftedUp)
                {
                    ShiftPageDown(keyboardFrame.Height, _activeViewBottom);
                }
            }
        }
        protected virtual void OnKeyboardShow(NSNotification notification)
        {
            if (!IsViewLoaded || _isKeyboardShown)
            {
                return;
            }

            _isKeyboardShown = true;
            var activeView = View.FindFirstResponder();

            if (activeView == null)
            {
                return;
            }

            var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);

            ((MainPage)Element).ShiftEntryUp(keyboardFrame.Height);
        }
Ejemplo n.º 24
0
        private void TecladoArriba(NSNotification notif)
        {
            if (txtNotas.IsFirstResponder || txtPorcentaje.IsFirstResponder)
            {
                if (txtPorcentaje.IsFirstResponder)
                {
                    ajuste = 50;
                }
                else
                {
                    ajuste = 7;
                }

                var r = UIKeyboard.FrameBeginFromNotification(notif);

                var keyboardHeight = r.Height;
                if (!blntecladoarriba)
                {
                    var    desface = (View.Frame.Y - keyboardHeight) + ajuste;
                    CGRect newrect = new CGRect(View.Frame.X,
                                                desface,
                                                View.Frame.Width,
                                                View.Frame.Height);

                    View.Frame       = newrect;
                    blntecladoarriba = true;
                }
                else
                {
                    var    rr      = UIKeyboard.FrameEndFromNotification(notif);
                    var    hact    = View.Frame.Y * -1;
                    var    hnew    = rr.Height;
                    var    dif     = hact - hnew;
                    var    desface = (View.Frame.Y + dif) + ajuste;
                    CGRect newrect = new CGRect(View.Frame.X,
                                                desface,
                                                View.Frame.Width,
                                                View.Frame.Height);

                    View.Frame = newrect;
                }
            }
        }
Ejemplo n.º 25
0
        protected override void KeyBoardUpNotification(NSNotification notification)
        {
            var shift = -90;

            _tagsHorizontalAlignment.Constant           = shift;
            _peopleHorizontalAlignment.Constant         = shift;
            _tagsNotFoundHorizontalAlignment.Constant   = shift;
            _peopleNotFoundHorizontalAlignment.Constant = shift;
            warningView.Hidden = false;

            if (ScrollAmount == 0)
            {
                var r = UIKeyboard.FrameEndFromNotification(notification);
                ScrollAmount = TabBarController != null ? r.Height - TabBarController.TabBar.Frame.Height : r.Height;
                warningViewToBottomConstraint.Constant = -ScrollAmount + 60;
            }

            ScrollTheView(true);
        }
        void OnKeyboardChangeFrame(NSNotification obj)
        {
            var frame  = View.ConvertRectFromView(UIKeyboard.FrameEndFromNotification(obj), null);
            var curve  = UIKeyboard.AnimationCurveFromNotification(obj);
            var offset = View.Bounds.Height - frame.Y;

            View.LayoutIfNeeded();
            UIView.Animate(
                duration: UIKeyboard.AnimationDurationFromNotification(obj),
                delay: 0,
                options: (UIViewAnimationOptions)(curve << 16),
                animation: () => {
                messageEntryBottom.Constant = offset - BottomLayoutGuide.Length;
                View.LayoutIfNeeded();
                var ci    = TableView.ContentInset;
                ci.Bottom = offset + messageEntry.Frame.Height;
                TableView.ContentInset = ci;
            },
                completion: null
                );
        }
        protected virtual void OnKeyboardShow(NSNotification notification)
        {
            if (contentScrollView == null)
            {
                if (!IsViewLoaded || _isKeyboardShown)
                {
                    return;
                }

                _isKeyboardShown = true;
                var activeView = View.FindFirstResponder();

                if (activeView == null)
                {
                    return;
                }

                var keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);
                var isOverlapping = activeView.IsKeyboardOverlapping(View, keyboardFrame);

                if (!isOverlapping)
                {
                    return;
                }

                if (isOverlapping)
                {
                    _activeViewBottom = activeView.GetViewRelativeBottom(View);
                    ShiftPageUp(keyboardFrame.Height, _activeViewBottom);
                }
            }
            else
            {
                var activeView = View.FindFirstResponder();
                if (activeView != null)
                {
                    contentScrollView.ScrollToAsync(0, 0, false);
                }
            }
        }
        public static void AddTableView(this BaseViewController controller, UITableView tableView)
        {
            NSObject hideNotification = null, showNotification = null;

            tableView.Frame            = controller.View.Bounds;
            tableView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight |
                                         UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin;
            controller.Add(tableView);

            controller.Appearing.Subscribe(_ =>
            {
                hideNotification = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, notification =>
                {
                    tableView.ContentInset          = UIEdgeInsets.Zero;
                    tableView.ScrollIndicatorInsets = UIEdgeInsets.Zero;
                });

                showNotification = NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, notification =>
                {
                    var keyboardFrame               = UIKeyboard.FrameEndFromNotification(notification);
                    var inset                       = new UIEdgeInsets(0, 0, keyboardFrame.Height, 0);
                    tableView.ContentInset          = inset;
                    tableView.ScrollIndicatorInsets = inset;
                });
            });

            controller.Disappearing.Subscribe(_ =>
            {
                controller.View.EndEditing(true);

                if (hideNotification != null)
                {
                    NSNotificationCenter.DefaultCenter.RemoveObserver(hideNotification);
                }
                if (showNotification != null)
                {
                    NSNotificationCenter.DefaultCenter.RemoveObserver(showNotification);
                }
            });
        }
        protected override void KeyBoardUpNotification(NSNotification notification)
        {
            if (_memoTextView.IsFirstResponder)
            {
                base.KeyBoardUpNotification(notification);
            }
            else
            {
                var shift = -90;
                _userLoaderHorizontalAlignment.Constant    = shift;
                _usersNotFoundHorizontalAlignment.Constant = shift;
                warningView.Hidden = false;

                if (_tableScrollAmount == 0)
                {
                    var r = UIKeyboard.FrameEndFromNotification(notification);
                    _tableScrollAmount = DeviceHelper.GetVersion() == DeviceHelper.HardwareVersion.iPhoneX ? r.Height - 34 : r.Height;
                    warningViewToBottomConstraint.Constant = -_tableScrollAmount + 60;
                }
                ScrollTheView(true);
            }
        }
        // Resize the view depending on keyboard
        void OnKeyboardNotification(NSNotification notification)
        {
            if (!IsViewLoaded)
            {
                return;
            }

            // Check if the keyboard is becoming visible
            bool visible = notification.Name == UIKeyboard.WillShowNotification;

            // Start an animation, using values from the keyboard
            UIView.BeginAnimations("AnimateForKeyboard");
            UIView.SetAnimationBeginsFromCurrentState(true);
            UIView.SetAnimationDuration(UIKeyboard.AnimationDurationFromNotification(notification));
            UIView.SetAnimationCurve((UIViewAnimationCurve)UIKeyboard.AnimationCurveFromNotification(notification));

            // Pass the notification, calculating keyboard height, etc.
            if (visible)
            {
                CGRect keyboardFrame = UIKeyboard.FrameEndFromNotification(notification);
                //BtnKeyboardBottom.Constant = -keyboardFrame.Height;
                var navigationFrame = NavigationController.View.Frame;
                var newFrame        = new CGRect(0, 0, navigationFrame.Width, UIScreen.MainScreen.Bounds.Height - keyboardFrame.Height);
                NavigationController.View.Frame = newFrame;
            }
            else
            {
                //BtnKeyboardBottom.Constant = 0;
                var navigationFrame = NavigationController.View.Frame;
                var newFrame        = new CGRect(0, 0, navigationFrame.Width, UIScreen.MainScreen.Bounds.Height);
                NavigationController.View.Frame = newFrame;
            }

            View.LayoutIfNeeded();

            // Commit the animation
            UIView.CommitAnimations();
        }