Browse Source

fix sidemenu rotation (#5243)

lionerez1 5 years ago
parent
commit
a591fe4476

+ 6
- 0
e2e/SideMenu.test.js View File

36
     await elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN).tap();
36
     await elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN).tap();
37
     await expect(elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN)).toBeNotVisible();
37
     await expect(elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN)).toBeNotVisible();
38
   });
38
   });
39
+
40
+  it('should rotate', async () => {
41
+    await elementById(TestIDs.OPEN_LEFT_SIDE_MENU_BTN).tap();
42
+    await device.setOrientation('landscape');
43
+    await expect(elementById(TestIDs.LEFT_SIDE_MENU_PUSH_BTN)).toBeVisible();
44
+  });
39
 });
45
 });

+ 7
- 15
lib/ios/RNNSideMenu/MMDrawerController/MMDrawerController.m View File

811
 
811
 
812
 #pragma mark Rotation
812
 #pragma mark Rotation
813
 
813
 
814
--(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
814
+-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
815
     [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
815
     [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
816
     //If a rotation begins, we are going to cancel the current gesture and reset transform and anchor points so everything works correctly
816
     //If a rotation begins, we are going to cancel the current gesture and reset transform and anchor points so everything works correctly
817
     BOOL gestureInProgress = NO;
817
     BOOL gestureInProgress = NO;
818
-    for(UIGestureRecognizer * gesture in self.view.gestureRecognizers){
819
-        if(gesture.state == UIGestureRecognizerStateChanged){
818
+    for(UIGestureRecognizer * gesture in self.view.gestureRecognizers) {
819
+        if(gesture.state == UIGestureRecognizerStateChanged) {
820
             [gesture setEnabled:NO];
820
             [gesture setEnabled:NO];
821
             [gesture setEnabled:YES];
821
             [gesture setEnabled:YES];
822
             gestureInProgress = YES;
822
             gestureInProgress = YES;
825
             [self resetDrawerVisualStateForDrawerSide:self.openSide];
825
             [self resetDrawerVisualStateForDrawerSide:self.openSide];
826
         }
826
         }
827
     }
827
     }
828
+	
828
     if ([self needsManualForwardingOfRotationEvents]){
829
     if ([self needsManualForwardingOfRotationEvents]){
829
         for(UIViewController * childViewController in self.childViewControllers){
830
         for(UIViewController * childViewController in self.childViewControllers){
830
             [childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
831
             [childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
867
     return YES;
868
     return YES;
868
 }
869
 }
869
 
870
 
870
--(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
871
+-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
871
     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
872
     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
873
+	
872
     if ([self needsManualForwardingOfRotationEvents]){
874
     if ([self needsManualForwardingOfRotationEvents]){
873
-        for(UIViewController * childViewController in self.childViewControllers){
875
+        for(UIViewController * childViewController in self.childViewControllers) {
874
             [childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
876
             [childViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
875
         }
877
         }
876
     }
878
     }
877
-	if (self.rightDrawerViewController != nil) {
878
-		for (UIView * subview in self.rightDrawerViewController.view.subviews) {
879
-			subview.frame = self.view.bounds;
880
-		}
881
-	}
882
-	if (self.leftDrawerViewController != nil) {
883
-		for (UIView * subview in self.leftDrawerViewController.view.subviews) {
884
-			subview.frame = self.view.bounds;
885
-		}
886
-	}
887
 }
879
 }
888
 
880
 
889
 -(bool)hasPan
881
 -(bool)hasPan

+ 7
- 0
playground/src/screens/SideMenuLeftScreen.js View File

11
 } = require('../testIDs');
11
 } = require('../testIDs');
12
 
12
 
13
 class SideMenuLeftScreen extends React.Component {
13
 class SideMenuLeftScreen extends React.Component {
14
+  static options() {
15
+    return {
16
+      layout: {
17
+        orientation: ['portrait', 'landscape']
18
+      }
19
+    };
20
+  }
14
   render() {
21
   render() {
15
     return (
22
     return (
16
       <Root componentId={this.props.componentId} style={{ backgroundColor: Colors.background }}>
23
       <Root componentId={this.props.componentId} style={{ backgroundColor: Colors.background }}>