Skip to content

Commit

Permalink
fix sidemenu rotation (#5243)
Browse files Browse the repository at this point in the history
  • Loading branch information
lionerez1 authored and guyca committed Jul 3, 2019
1 parent a27d9ef commit a591fe4
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 6 additions & 0 deletions e2e/SideMenu.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ describe('SideMenu', () => {
await elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN).tap();
await expect(elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN)).toBeNotVisible();
});

it('should rotate', async () => {
await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
await device.setOrientation('landscape');
await expect(elementById(TestIDs.LEFT_SIDE_MENU_PUSH_BTN)).toBeVisible();
});
});
22 changes: 7 additions & 15 deletions lib/ios/RNNSideMenu/MMDrawerController/MMDrawerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -811,12 +811,12 @@ -(void)viewDidDisappear:(BOOL)animated{

#pragma mark Rotation

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
//If a rotation begins, we are going to cancel the current gesture and reset transform and anchor points so everything works correctly
BOOL gestureInProgress = NO;
for(UIGestureRecognizer * gesture in self.view.gestureRecognizers){
if(gesture.state == UIGestureRecognizerStateChanged){
for(UIGestureRecognizer * gesture in self.view.gestureRecognizers) {
if(gesture.state == UIGestureRecognizerStateChanged) {
[gesture setEnabled:NO];
[gesture setEnabled:YES];
gestureInProgress = YES;
Expand All @@ -825,6 +825,7 @@ -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrien
[self resetDrawerVisualStateForDrawerSide:self.openSide];
}
}

if ([self needsManualForwardingOfRotationEvents]){
for(UIViewController * childViewController in self.childViewControllers){
[childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
Expand Down Expand Up @@ -867,23 +868,14 @@ -(BOOL)shouldAutorotate{
return YES;
}

-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];

if ([self needsManualForwardingOfRotationEvents]){
for(UIViewController * childViewController in self.childViewControllers){
for(UIViewController * childViewController in self.childViewControllers) {
[childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
}
if (self.rightDrawerViewController != nil) {
for (UIView * subview in self.rightDrawerViewController.view.subviews) {
subview.frame = self.view.bounds;
}
}
if (self.leftDrawerViewController != nil) {
for (UIView * subview in self.leftDrawerViewController.view.subviews) {
subview.frame = self.view.bounds;
}
}
}

-(bool)hasPan
Expand Down
7 changes: 7 additions & 0 deletions playground/src/screens/SideMenuLeftScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ const {
} = require('../testIDs');

class SideMenuLeftScreen extends React.Component {
static options() {
return {
layout: {
orientation: ['portrait', 'landscape']
}
};
}
render() {
return (
<Root componentId={this.props.componentId} style={{ backgroundColor: Colors.background }}>
Expand Down

0 comments on commit a591fe4

Please sign in to comment.