Browse Source

fix sidemenu rotation (#5243)

lionerez1 4 years ago
parent
commit
a591fe4476

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

@@ -36,4 +36,10 @@ describe('SideMenu', () => {
36 36
     await elementById(TestIDs.CLOSE_RIGHT_SIDE_MENU_BTN).tap();
37 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,12 +811,12 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
811 811
 
812 812
 #pragma mark Rotation
813 813
 
814
--(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
814
+-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
815 815
     [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
816 816
     //If a rotation begins, we are going to cancel the current gesture and reset transform and anchor points so everything works correctly
817 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 820
             [gesture setEnabled:NO];
821 821
             [gesture setEnabled:YES];
822 822
             gestureInProgress = YES;
@@ -825,6 +825,7 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
825 825
             [self resetDrawerVisualStateForDrawerSide:self.openSide];
826 826
         }
827 827
     }
828
+	
828 829
     if ([self needsManualForwardingOfRotationEvents]){
829 830
         for(UIViewController * childViewController in self.childViewControllers){
830 831
             [childViewController willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
@@ -867,23 +868,14 @@ static NSString *MMDrawerOpenSideKey = @"MMDrawerOpenSide";
867 868
     return YES;
868 869
 }
869 870
 
870
--(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
871
+-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
871 872
     [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
873
+	
872 874
     if ([self needsManualForwardingOfRotationEvents]){
873
-        for(UIViewController * childViewController in self.childViewControllers){
875
+        for(UIViewController * childViewController in self.childViewControllers) {
874 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 881
 -(bool)hasPan

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

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