void UpdateButtomLayoutConstraint(UIKeyboardEventArgs e)
        {
            UIViewAnimationCurve curve = e.AnimationCurve;

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                UIView.Animate(e.AnimationDuration, 0, ConvertToAnimationOptions(e.AnimationCurve), () =>
                {
                    nfloat offsetFromBottom = toolbar.Frame.GetMaxY() - e.FrameEnd.GetMinY();
                    offsetFromBottom        = NMath.Max(0, offsetFromBottom);
                    if (++notifCount >= 2)
                    {
                        SetToolbarContstraint(-offsetFromBottom);
                    }
                }, null);
            }
            else
            {
                UIView.Animate(e.AnimationDuration, 0, ConvertToAnimationOptions(e.AnimationCurve), () =>
                {
                    nfloat offsetFromBottom = tableView.Frame.GetMaxY() - e.FrameEnd.GetMinY();
                    offsetFromBottom        = NMath.Max(0, offsetFromBottom);
                    SetToolbarContstraint(offsetFromBottom);
                }, null);
            }
        }
 UIViewAnimationOptions ConvertToAnimationOptions(UIViewAnimationCurve curve)
 {
     // Looks like a hack. But it is correct.
     // UIViewAnimationCurve and UIViewAnimationOptions are shifted by 16 bits
     // http://stackoverflow.com/questions/18870447/how-to-use-the-default-ios7-uianimation-curve/18873820#18873820
     return((UIViewAnimationOptions)((int)curve << 16));
 }
Example #3
0
        public static UIViewAnimationOptions GetAnimationOptions(this UIKeyboardEventArgs args)
        {
            UIViewAnimationCurve curve = args.AnimationCurve;

            // UIViewAnimationCurve and UIViewAnimationOptions are shifted by 16 bits
            // http://stackoverflow.com/questions/18870447/how-to-use-the-default-ios7-uianimation-curve/18873820#18873820
            return((UIViewAnimationOptions)((int)curve << 16));
        }
        void KeyboardWillHide(object sender, UIKeyboardEventArgs e)
        {
            double animationDuration            = e.AnimationDuration;
            UIViewAnimationCurve animationCurve = e.AnimationCurve;

            connectBoxCenterYConstraint.Constant = 0;
            new UIViewPropertyAnimator(animationDuration, animationCurve, View.LayoutIfNeeded).StartAnimation();
        }
Example #5
0
        public static UIViewAnimationOptions ToAnimationOptions(this UIViewAnimationCurve curve)
        {
            var val = (int)curve;

            val = val << 16;

            return((UIViewAnimationOptions)val);
        }
        void KeyboardWillShow(object sender, UIKeyboardEventArgs e)
        {
            double animationDuration            = e.AnimationDuration;
            UIViewAnimationCurve animationCurve = e.AnimationCurve;
            CGRect frameEnd = e.FrameEnd;

            buttonBottomConstraint.Constant = frameEnd.Size.Height + buttonBottomConstraintConstant;
            new UIViewPropertyAnimator(animationDuration, animationCurve, View.LayoutIfNeeded).StartAnimation();
        }
        void UpdateButtomLayoutConstraint(UIKeyboardEventArgs e)
        {
            UIViewAnimationCurve curve = e.AnimationCurve;

            UIView.Animate(e.AnimationDuration, 0, ConvertToAnimationOptions(e.AnimationCurve), () => {
                nfloat offsetFromBottom = tableView.Frame.GetMaxY() - e.FrameEnd.GetMinY();
                offsetFromBottom        = NMath.Max(0, offsetFromBottom);
                SetToolbarContstraint(offsetFromBottom);
            }, null);
        }
        void KeyboardWillShow(object sender, UIKeyboardEventArgs e)
        {
            double animationDuration            = e.AnimationDuration;
            UIViewAnimationCurve animationCurve = e.AnimationCurve;
            CGRect frameEnd = e.FrameEnd;
            nfloat yDelta   = frameEnd.Size.Height / 2;

            connectBoxCenterYConstraint.Constant = -yDelta;
            new UIViewPropertyAnimator(animationDuration, animationCurve, View.LayoutIfNeeded).StartAnimation();
        }
Example #9
0
        protected override void OnKeyboardWillAppear(nfloat keyboardWidth, nfloat keyboardHeight,
                                                     double animationDuration, UIViewAnimationCurve animationCurve)
        {
            base.OnKeyboardWillAppear(keyboardWidth, keyboardHeight, animationDuration, animationCurve);
            if (ActiveTextView == null)
            {
                return;
            }
            var activeTextFieldFrameInSuperView =
                ActiveTextView.Superview.ConvertRectToView(ActiveTextView.Frame, View);
            var hiddenDeltaY = activeTextFieldFrameInSuperView.Y + activeTextFieldFrameInSuperView.Height -
                               (View.Frame.Height - keyboardHeight);

            if (hiddenDeltaY > 0)
            {
                TranslateRootViewVerticaly(-hiddenDeltaY, animationDuration);
            }
        }
Example #10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // style the text view to look like a text field - why the hell are they different?
            TextView.Layer.BorderColor  = UIColor.Gray.ColorWithAlpha(0.5f).CGColor;
            TextView.Layer.BorderWidth  = 2;
            TextView.Layer.CornerRadius = 5;
            TextView.ClipsToBounds      = true;

            TaskDescriptionLabel.Text = thisTask.Description;

            _notification = UIKeyboard.Notifications.ObserveWillShow((s, e) =>
            {
                _animationDuration = e.AnimationDuration;
                _animationCurve    = e.AnimationCurve;

                CGRect r      = UIKeyboard.FrameBeginFromNotification(e.Notification);
                _scrollAmount = r.Height;
                ScrollTheView(true);
            });

            if (!string.IsNullOrWhiteSpace(thisTask.CompletionData?.JsonData))
            {
                TextView.Text = thisTask.CompletionData.JsonData;
            }
            else
            {
                // Bootstrap for placeholder text. FML
                TextView.Delegate = new TextViewPlaceholderDelegate(TextView, placeholderText);
            }

            UIBarButtonItem customButton = new UIBarButtonItem(
                UIImage.FromBundle("TickIcon"),
                UIBarButtonItemStyle.Plain,
                (s, e) => {
                ReturnText();
            }
                );

            NavigationItem.RightBarButtonItem = customButton;
        }
Example #11
0
        void UpdateButtomLayoutConstraint(UIKeyboardEventArgs e)
        {
            UIViewAnimationCurve curve = e.AnimationCurve;

            UIView.Animate(e.AnimationDuration, 0, ConvertToAnimationOptions(e.AnimationCurve), () => {
//				SetToolbarContstraint(tableView.Frame.GetMaxY () - e.FrameEnd.GetMinY ());
                SetToolbarContstraint(e.FrameEnd.Height);

                // Move content with keyboard

                /*
                 * var oldOverlap = CalcContentOverlap();
                 * UpdateTableInsets ();
                 * var newOverlap = CalcContentOverlap();
                 *
                 * var offset = tableView.ContentOffset;
                 * offset.Y += newOverlap - oldOverlap;
                 * offset.Y = NMath.Max(offset.Y, 0);
                 * tableView.ContentOffset = offset;
                 */
            }, null);
        }
Example #12
0
 protected override void OnKeyboardWillDisappear(nfloat keyboardWidth, nfloat keyboardHeight,
                                                 double animationDuration, UIViewAnimationCurve animationCurve)
 {
     base.OnKeyboardWillDisappear(keyboardWidth, keyboardHeight, animationDuration, animationCurve);
     ResetRootViewPosition(animationDuration);
 }
Example #13
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            btnContents.TouchUpInside += (sender, e) => {
                if (ContentsButtonClicked != null)
                {
                    ContentsButtonClicked(sender, e);
                }
            };

            btnStart.TouchUpInside += (s, e) => {
                // begin our animation block. the name allows us to refer to it later
                UIView.BeginAnimations("ImageMove");

                UIView.SetAnimationDidStopSelector(new Selector("AnimationStopped"));
                UIView.SetAnimationDelegate(this);                  //NOTE: you need this for the selector b.s.

                // animation delay
                UIView.SetAnimationDelay((double)sldrDelay.Value);

                // animation duration
                UIView.SetAnimationDuration((double)sldrDuration.Value);

                // animation curve
                UIViewAnimationCurve curve = UIViewAnimationCurve.EaseInOut;
                switch (sgmtCurves.SelectedSegment)
                {
                case 0:
                    curve = UIViewAnimationCurve.EaseInOut;
                    break;

                case 1:
                    curve = UIViewAnimationCurve.EaseIn;
                    break;

                case 2:
                    curve = UIViewAnimationCurve.EaseOut;
                    break;

                case 3:
                    curve = UIViewAnimationCurve.Linear;
                    break;
                }
                UIView.SetAnimationCurve(curve);

                // repeat count
                UIView.SetAnimationRepeatCount(float.Parse(txtRepeateCount.Text));

                // autorevese when repeating
                UIView.SetAnimationRepeatAutoreverses(swtchAutoReverse.On);

                // move the image one way or the other
                if (imgToAnimate.Frame.Y == 214)
                {
                    imgToAnimate.Frame = new RectangleF(
                        new PointF(imgToAnimate.Frame.X, imgToAnimate.Frame.Y + 400),
                        imgToAnimate.Frame.Size);
                }
                else
                {
                    imgToAnimate.Frame = new RectangleF(
                        new PointF(imgToAnimate.Frame.X, imgToAnimate.Frame.Y - 400),
                        imgToAnimate.Frame.Size);
                }

                // finish our animation block
                UIView.CommitAnimations();
            };
        }
		UIViewAnimationOptions ConvertToAnimationOptions(UIViewAnimationCurve curve)
		{
			// Looks like a hack. But it is correct.
			// UIViewAnimationCurve and UIViewAnimationOptions are shifted by 16 bits
			// http://stackoverflow.com/questions/18870447/how-to-use-the-default-ios7-uianimation-curve/18873820#18873820
			return (UIViewAnimationOptions)((int)curve << 16);
		}
Example #15
0
 UIViewAnimationOptions ConvertToAnimationOptions(UIViewAnimationCurve curve)
 {
     return((UIViewAnimationOptions)((int)curve << 16));
 }
Example #16
0
 protected virtual void OnKeyboardWillDisappear(nfloat keyboardWidth, nfloat keyboardHeight,
                                                double animationDuration, UIViewAnimationCurve animationCurve)
 {
     IsKeyboardShown = false;
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            btnStart.TouchUpInside += (s, e) => {
//				double duration = (double)sldrDuration.Value;
//				double delay = (double)sldrDelay.Value;
//				UIViewAnimationOptions animationOptions = UIViewAnimationOptions.CurveEaseIn | UIViewAnimationOptions.Repeat;
//				UIView.Animate(duration, delay, animationOptions, () => {
//					// move the image one way or the other
//					if(imgToAnimate.Frame.Y == 190)
//					{
//						imgToAnimate.Frame = new System.Drawing.RectangleF(
//							imgToAnimate.Frame.X, imgToAnimate.Frame.Y + 400,
//							imgToAnimate.Frame.Size.Width, imgToAnimate.Frame.Size.Height);
//					}
//					else
//					{
//						imgToAnimate.Frame = new System.Drawing.RectangleF(
//							imgToAnimate.Frame.X, imgToAnimate.Frame.Y - 400,
//							imgToAnimate.Frame.Size.Width, imgToAnimate.Frame.Size.Height);
//					}
//				}, null);

                // begin our animation block. the name allows us to refer to it later
                UIView.BeginAnimations("ImageMove");

                UIView.SetAnimationDidStopSelector(new Selector("AnimationStopped"));
                UIView.SetAnimationDelegate(this);                  //NOTE: you need this for the selector b.s.

                // animation delay
                UIView.SetAnimationDelay((double)sldrDelay.Value);

                // animation duration
                UIView.SetAnimationDuration((double)sldrDuration.Value);

                // animation curve
                UIViewAnimationCurve curve = UIViewAnimationCurve.EaseInOut;
                switch (sgmtCurves.SelectedSegment)
                {
                case 0: curve = UIViewAnimationCurve.EaseInOut; break;

                case 1: curve = UIViewAnimationCurve.EaseIn; break;

                case 2: curve = UIViewAnimationCurve.EaseOut; break;

                case 3: curve = UIViewAnimationCurve.Linear; break;
                }
                UIView.SetAnimationCurve(curve);

                // repeat count
                UIView.SetAnimationRepeatCount(float.Parse(txtRepeateCount.Text));

                // autorevese when repeating
                UIView.SetAnimationRepeatAutoreverses(swtchAutoReverse.On);

                // move the image one way or the other
                if (imgToAnimate.Frame.Y == 190)
                {
                    imgToAnimate.Frame = new System.Drawing.RectangleF(
                        imgToAnimate.Frame.X, imgToAnimate.Frame.Y + 400,
                        imgToAnimate.Frame.Size.Width, imgToAnimate.Frame.Size.Height);
                }
                else
                {
                    imgToAnimate.Frame = new System.Drawing.RectangleF(
                        imgToAnimate.Frame.X, imgToAnimate.Frame.Y - 400,
                        imgToAnimate.Frame.Size.Width, imgToAnimate.Frame.Size.Height);
                }

                // finish our animation block
                UIView.CommitAnimations();
            };
        }