public void CloseDrawer() { TapGestureRecognizer.Enabled = false; UIView.AnimateNotify(0.2, () => { TopView.Frame = TopViewFrame; }, (finished) => { DrawerTransitioning?.Invoke(this, new DrawerTransitioningEventArgs(DrawerTransitioningState.Closed)); updateStatusBarAppearance(); }); }
public async Task <bool> CloseDrawerAsync() { TapGestureRecognizer.Enabled = false; var finished = await UIView.AnimateNotifyAsync(0.2, () => { TopView.Frame = TopViewFrame; }); DrawerTransitioning?.Invoke(this, new DrawerTransitioningEventArgs(DrawerTransitioningState.Closed)); updateStatusBarAppearance(); return(finished); }
void handleLtrPanGesture(UIPanGestureRecognizer pan) { switch (pan.State) { case UIGestureRecognizerState.Began: pendingStatusBarAppearanceUpdate = true; break; case UIGestureRecognizerState.Changed: var ltrCurrentTranslation = pan.TranslationInView(pan.View); // if panning right-to-left ltrCurrentTranslation.X will be negative // setting pan.Enabled to false causes this method to be called again with // pan.State == Cancelled, so we'll reenable the gesture in Cancelled: case if (ltrCurrentTranslation.X < 0) { pan.Enabled = false; return; } // if panning up or down more than left-to-right, kill this gesture recognizer // to allow only the TopViewControllers scrollview, tableview, etc. to scroll if (NMath.Abs(ltrCurrentTranslation.Y) > ltrCurrentTranslation.X) { pan.Enabled = false; return; } var frame = TopViewFrame; frame.X += ltrCurrentTranslation.X; TopView.Frame = frame; if (pendingStatusBarAppearanceUpdate) { pendingStatusBarAppearanceUpdate = false; DrawerTransitioning?.Invoke(this, new DrawerTransitioningEventArgs(DrawerTransitioningState.Transitioning)); updateStatusBarAppearance(); } break; case UIGestureRecognizerState.Ended: case UIGestureRecognizerState.Cancelled: pan.Enabled = true; // the TopView's frame was never moved because the pan was the wrong direction // or the pan was a vertical scroll, so no reason to do anything here if (pendingStatusBarAppearanceUpdate) { pendingStatusBarAppearanceUpdate = false; return; } // if the drawer has been opened at least 50%, finish opening, otherwise close var finalFrame = TopView.Frame.X > (DrawerWidth / 2) ? TopViewFrameOpen : TopViewFrame; UIView.AnimateNotify(0.1, () => { TopView.Frame = finalFrame; }, (finished) => { TapGestureRecognizer.Enabled = DrawerOpen; DrawerTransitioning?.Invoke(this, new DrawerTransitioningEventArgs(DrawerOpen ? DrawerTransitioningState.Open : DrawerTransitioningState.Closed)); updateStatusBarAppearance(); }); break; } }
void handleTapGesture(UITapGestureRecognizer tap) { DrawerTransitioning?.Invoke(this, new DrawerTransitioningEventArgs(DrawerTransitioningState.Transitioning)); CloseDrawer(); }