Beispiel #1
0
 /// <summary>
 /// Toggles the menu open or closed.
 /// </summary>
 public void ToggleMenu()
 {
     if (IsOpen)
     {
         _sidebar.CloseMenu();
     }
     else
     {
         _sidebar.OpenMenu();
     }
 }
Beispiel #2
0
        private void PanEnded(Sidebar sidebar)
        {
            var xDelta   = sidebar.PanGesture.TranslationInView(ContentViewController.View).X;
            var velocity = sidebar.PanGesture.VelocityInView(ContentViewController.View).X;

            if ((sidebar.MenuLocation == MenuLocations.Left && sidebar.IsOpen && xDelta < 0) ||
                (sidebar.MenuLocation == MenuLocations.Right && sidebar.IsOpen && xDelta > 0))
            {
                PanEndedTowardClose(sidebar);
            }
            var flungOpenFromLeft  = (sidebar.MenuLocation == MenuLocations.Left && (velocity > sidebar.FlingVelocity || ContentViewController.View.Frame.X > (sidebar.MenuWidth * sidebar.FlingPercentage)));
            var flungOpenFromRight = (sidebar.MenuLocation == MenuLocations.Right && (velocity < -sidebar.FlingVelocity || ContentViewController.View.Frame.X < -(sidebar.MenuWidth * sidebar.FlingPercentage)));

            if (flungOpenFromLeft || flungOpenFromRight)
            {
                sidebar.OpenMenu();
            }
            else
            {
                UIView.Animate(
                    Sidebar.SlideSpeed,
                    0,
                    UIViewAnimationOptions.CurveEaseInOut,
                    () => { ContentViewController.View.Frame = new RectangleF(0, 0, ContentViewController.View.Frame.Width, ContentViewController.View.Frame.Height); HideDarkOverlay(); },
                    () => {});
            }
        }
		private void PanEnded(Sidebar sidebar) {
			var xDelta = sidebar.PanGesture.TranslationInView(ContentViewController.View).X;
			var velocity = sidebar.PanGesture.VelocityInView(ContentViewController.View).X;
			if ((sidebar.MenuLocation == MenuLocations.Left && sidebar.IsOpen && xDelta < 0) || 
				(sidebar.MenuLocation == MenuLocations.Right && sidebar.IsOpen && xDelta > 0)) 
			{
				PanEndedTowardClose(sidebar);
			} 
			var flungOpenFromLeft = (sidebar.MenuLocation == MenuLocations.Left && (velocity > sidebar.FlingVelocity || ContentViewController.View.Frame.X > (sidebar.MenuWidth * sidebar.FlingPercentage)));
			var flungOpenFromRight = (sidebar.MenuLocation == MenuLocations.Right && (velocity < -sidebar.FlingVelocity || ContentViewController.View.Frame.X < -(sidebar.MenuWidth * sidebar.FlingPercentage)));
			if (flungOpenFromLeft || flungOpenFromRight) {
				sidebar.OpenMenu();
			} else {
				UIView.Animate(
					Sidebar.SlideSpeed, 
					0, 
					UIViewAnimationOptions.CurveEaseInOut,
					() => { ContentViewController.View.Frame = new RectangleF(0, 0, ContentViewController.View.Frame.Width, ContentViewController.View.Frame.Height); },
					() => {});
			}
		}