Пример #1
0
 private void Setup()
 {
     delayDistance               = 0.0f;
     maxDelay                    = 0.0f;
     lastContentOffset           = 0.0f;
     state                       = NavigationBarState.Expanded;
     ShouldScrollWhenContentFits = false;
     ExpandOnActive              = true;
     ScrollingEnabled            = true;
 }
Пример #2
0
 public override void ScrollingNavigationStateChanged(NavigationBarState state)
 {
     Console.WriteLine("Navigation bar state changed: " + state);
 }
		public override void ScrollingNavigationStateChanged (NavigationBarState state)
		{
			Console.WriteLine ("Navigation bar state changed: " + state);
		}
        /// <summary>
        /// Start scrolling
        /// Enables the scrolling by observing a view
        /// </summary>
        /// <param name="scrollableView">The view with the scrolling content that will be observed.</param>
        /// <param name="delay">The delay expressed in points that determines the scrolling resistance. Defaults to `0`.</param>
        /// <param name="scrollSpeedFactor">This factor determines the speed of the scrolling content toward the navigation bar animation.</param>
        /// <param name="followers">An array of `UIView`s that will follow the navbar.</param>
        public void FollowScrollView(UIView scrollableView, double delay, double scrollSpeedFactor, UIView[] followers)
        {
            this.scrollableView = scrollableView;

            var recognizer = new UIPanGestureRecognizer(OnPan);

            recognizer.ShouldRecognizeSimultaneously = delegate {
                // Enables the scrolling of both the content and the navigation bar
                return(true);
            };
            recognizer.ShouldReceiveTouch = delegate {
                // Only scrolls the navigation bar with the content when `scrollingEnabled` is true
                return(ScrollingEnabled);
            };
            recognizer.ShouldBegin = delegate {
                // Begin scrolling only if the direction is vertical (prevents conflicts with horizontal scroll views)
                var velocity = gestureRecognizer.VelocityInView(gestureRecognizer.View);
                return(Math.Abs(velocity.Y) > Math.Abs(velocity.X));
            };
            recognizer.MaximumNumberOfTouches = 1;

            gestureRecognizer = recognizer;
            scrollableView.AddGestureRecognizer(gestureRecognizer);

            willResignActiveObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.WillResignActiveNotification, notification => {
                previousState = state;
            });
            didBecomeActiveObserver = NSNotificationCenter.DefaultCenter.AddObserver(UIApplication.DidBecomeActiveNotification, notification => {
                if (ExpandOnActive)
                {
                    ShowNavbar(false);
                }
                else
                {
                    if (previousState == NavigationBarState.Collapsed)
                    {
                        HideNavbar(false);
                    }
                }
            });
            deviceOrientationDidChange = NSNotificationCenter.DefaultCenter.AddObserver(UIDevice.OrientationDidChangeNotification, notification => {
                ShowNavbar();
            });

            maxDelay               = (nfloat)delay;
            delayDistance          = (nfloat)delay;
            this.scrollSpeedFactor = (nfloat)scrollSpeedFactor;
            ScrollingEnabled       = true;

            // Save TabBar state (the state is changed during the transition and restored on compeltion)
            if (followers == null)
            {
                Followers = new UIView[0];
            }
            else
            {
                var tab = followers.OfType <UITabBar> ().FirstOrDefault();
                if (tab != null)
                {
                    sourceTabBar             = new UITabBar(tab.Frame);
                    sourceTabBar.Translucent = tab.Translucent;
                }
                Followers = followers;
            }
        }
Пример #5
0
 public virtual void ScrollingNavigationStateChanged(NavigationBarState state)
 {
 }
		public virtual void ScrollingNavigationStateChanged (NavigationBarState state)
		{
		}