예제 #1
0
        /// <summary>
        /// Switch the page
        /// </summary>
        /// <param name="index"><see cref="int"/> with the index of the page to switch to. Zero indexed.</param>
        /// <param name="animated"><see cref="bool"/> describing whether to animate the scroll to the page.
        /// Will also enable a parallax effect on the Tab Indicator itself.</param>
        public void SwitchPage(int index, bool animated)
        {
            if (ContentScrollView == null)
            {
                return;
            }
            if (TitleScrollView == null)
            {
                return;
            }

            var frame = new CGRect(ContentScrollView.Frame.Size.Width * index, 0,
                                   ContentScrollView.Frame.Size.Width, ContentScrollView.Frame.Size.Height);

            if (frame.X >= ContentScrollView.ContentSize.Width)
            {
                return;
            }

            _enableParallax = !animated;

            var point = _tabButtons[index].Frame;

            point.X -= (TitleScrollView.Bounds.Size.Width - _tabButtons[index].Frame.Size.Width) / 2f;
            TitleScrollView.SetContentOffset(new CGPoint(point.X, point.Y), animated);
            ContentScrollView.ScrollRectToVisible(frame, animated);
        }
예제 #2
0
        public void ReloadData()
        {
            foreach (var viewController in _viewControllers)
            {
                viewController.WillMoveToParentViewController(null);
                viewController.View.RemoveFromSuperview();
                viewController.RemoveFromParentViewController();
            }
            _viewControllers.Clear();

            if (Datasource != null)
            {
                _viewControllerCount = Datasource.NumberOfViewControllers;
                for (var i = 0; i < _viewControllerCount; i++)
                {
                    var viewController = Datasource.GetViewController(i);

                    AddChildViewController(viewController);
                    var size = ContentScrollView.Frame.Size;
                    viewController.View.Frame = new CGRect(size.Width * i, 0, size.Width, size.Height);
                    ContentScrollView.AddSubview(viewController.View);
                    viewController.DidMoveToParentViewController(this);
                    _viewControllers.Add(viewController);
                }

                GenerateTabs();
                Layout();

                _selectedIndex = Math.Min(_viewControllerCount - 1, _selectedIndex);
                if (_selectedIndex > 0)
                {
                    SwitchPage(_selectedIndex, false);
                }
            }
        }
        public override void LayoutSubviews()
        {
            base.LayoutSubviews();

            ContentScrollView.ContentInset = new UIEdgeInsets(0.0f, LeftAvailable ? LeftButton.Frame.Width : 0.0f, 0.0f, LockRight ? 0.0f : RightButton.Frame.Width);
            ContentScrollView.SetContentOffset(CGPoint.Empty, true);

            LeftButton.Hidden = !LeftAvailable;
        }
예제 #4
0
        private void ViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName != nameof(SettingsWindowViewModel.SelectedViewModel))
            {
                return;
            }

            ContentScrollView.ScrollToTop();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.AddDefaultNavigationTitle();

            UITapGestureRecognizer tapRecognizer = new UITapGestureRecognizer(OnTapGesture);

            ContentScrollView.AddGestureRecognizer(tapRecognizer);

            ItemPriceTextField.Text                    = DefaultPriceText;
            ItemPriceTextField.EditingDidEnd          += ItemPriceTextFieldEditingDidEnd;
            ItemPriceTextField.ShouldChangeCharacters += ItemPriceTextFieldShouldChangeCharacters;

            PhotoAddedContainerView.Hidden   = true;
            AddPhotoButton.TouchUpInside    += OnAddPhotoButtonTapped;
            RemovePhotoButton.TouchUpInside += OnRemovePhotoButtonTapped;
            AddItemButton.TouchUpInside     += OnAddItemButtonTapped;
        }
예제 #6
0
        void ReleaseDesignerOutlets()
        {
            if (ContainerViewMain != null)
            {
                ContainerViewMain.Dispose();
                ContainerViewMain = null;
            }

            if (LeftButton != null)
            {
                LeftButton.Dispose();
                LeftButton = null;
            }

            if (RightButton != null)
            {
                RightButton.Dispose();
                RightButton = null;
            }

            if (ContentScrollView != null)
            {
                ContentScrollView.Dispose();
                ContentScrollView = null;
            }

            if (ContainerViewSlider != null)
            {
                ContainerViewSlider.Dispose();
                ContainerViewSlider = null;
            }

            if (SliderTitleLabel != null)
            {
                SliderTitleLabel.Dispose();
                SliderTitleLabel = null;
            }
        }
예제 #7
0
        private void AdjustConstraints()
        {
            View.RemoveConstraints(View.Constraints);

            View.AddConstraints(
                ShowOnBottom ?
                TitleScrollView.AtBottomOf(View) :
                TitleScrollView.AtTopOf(View),

                TitleScrollView.AtLeftOf(View),
                TitleScrollView.AtRightOf(View),
                TitleScrollView.Height().EqualTo(_tabHeight),

                ContentScrollView.WithSameWidth(TitleScrollView),

                ShowOnBottom ?
                ContentScrollView.Above(TitleScrollView) :
                ContentScrollView.Below(TitleScrollView),

                ShowOnBottom ?
                ContentScrollView.AtTopOf(View) :
                ContentScrollView.AtBottomOf(View)
                );
        }
        private void ScrollViewToShowCurrentResponder(NSNotification notification)
        {
            var    keyboardInfoValue = notification.UserInfo[UIKeyboard.FrameEndUserInfoKey] as NSValue;
            CGRect rawFrame          = keyboardInfoValue.CGRectValue;
            CGRect keyboardFrame     = View.ConvertRectFromView(rawFrame, null);
            nfloat keyboardHeight    = keyboardFrame.Height;

            UIEdgeInsets contentInsets = new UIEdgeInsets(0, 0, keyboardHeight, 0);

            ContentScrollView.ContentInset          = contentInsets;
            ContentScrollView.ScrollIndicatorInsets = contentInsets;

            CGRect aRect = View.Frame;

            aRect.Size = new CGSize(aRect.Size.Width, keyboardHeight);

            var responder = View.GetFirstResponder();

            if (!aRect.Contains(responder.Frame))
            {
                PointF scrollPoint = new PointF(0.0f, (float)responder.Frame.Y - (float)keyboardHeight);
                ContentScrollView.SetContentOffset(scrollPoint, true);
            }
        }
예제 #9
0
        void ReleaseDesignerOutlets()
        {
            if (AddItemButton != null)
            {
                AddItemButton.Dispose();
                AddItemButton = null;
            }

            if (AddPhotoButton != null)
            {
                AddPhotoButton.Dispose();
                AddPhotoButton = null;
            }

            if (AddPhotoContainerView != null)
            {
                AddPhotoContainerView.Dispose();
                AddPhotoContainerView = null;
            }

            if (ContentScrollView != null)
            {
                ContentScrollView.Dispose();
                ContentScrollView = null;
            }

            if (ItemDescriptionLabel != null)
            {
                ItemDescriptionLabel.Dispose();
                ItemDescriptionLabel = null;
            }

            if (ItemDescriptionLineView != null)
            {
                ItemDescriptionLineView.Dispose();
                ItemDescriptionLineView = null;
            }

            if (ItemDescriptionTextView != null)
            {
                ItemDescriptionTextView.Dispose();
                ItemDescriptionTextView = null;
            }

            if (ItemNameLabel != null)
            {
                ItemNameLabel.Dispose();
                ItemNameLabel = null;
            }

            if (ItemNameLineView != null)
            {
                ItemNameLineView.Dispose();
                ItemNameLineView = null;
            }

            if (ItemNameTextField != null)
            {
                ItemNameTextField.Dispose();
                ItemNameTextField = null;
            }

            if (ItemPhotoView != null)
            {
                ItemPhotoView.Dispose();
                ItemPhotoView = null;
            }

            if (ItemPriceLabel != null)
            {
                ItemPriceLabel.Dispose();
                ItemPriceLabel = null;
            }

            if (ItemPriceTextField != null)
            {
                ItemPriceTextField.Dispose();
                ItemPriceTextField = null;
            }

            if (PhotoAddedContainerView != null)
            {
                PhotoAddedContainerView.Dispose();
                PhotoAddedContainerView = null;
            }

            if (RemovePhotoButton != null)
            {
                RemovePhotoButton.Dispose();
                RemovePhotoButton = null;
            }
        }
 public void CloseSlideButtons()
 {
     ContentScrollView.SetContentOffset(CGPoint.Empty, true);
 }