Browse Source

Fixes for dynamically controlling iOS drawer status (#1356)

* Fix iOS drawer status control

* Prevent MMDrawerController disabling UI interaction when accidentally assigning a nil drawer controller and toggling that drawer
Matt Davies 7 years ago
parent
commit
35c61b450f

+ 6
- 5
ios/RCCDrawerController/MMDrawerController/MMDrawerController.m View File

369
         }
369
         }
370
     }
370
     }
371
     else {
371
     else {
372
-        [self setAnimatingDrawer:animated];
373
         UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide];
372
         UIViewController * sideDrawerViewController = [self sideDrawerViewControllerForSide:drawerSide];
374
-        if (self.openSide != drawerSide) {
375
-            [self prepareToPresentDrawer:drawerSide animated:animated];
376
-        }
377
-        
373
+
378
         if(sideDrawerViewController){
374
         if(sideDrawerViewController){
375
+            [self setAnimatingDrawer:animated];
376
+            if (self.openSide != drawerSide) {
377
+                [self prepareToPresentDrawer:drawerSide animated:animated];
378
+            }
379
+            
379
             CGRect newFrame;
380
             CGRect newFrame;
380
             CGRect oldFrame = self.centerContainerView.frame;
381
             CGRect oldFrame = self.centerContainerView.frame;
381
             if(drawerSide == MMDrawerSideLeft){
382
             if(drawerSide == MMDrawerSideLeft){

+ 1
- 3
ios/RCCDrawerController/RCCDrawerController.m View File

30
     UIViewController *centerViewController = [RCCViewController controllerWithLayout:children[0] globalProps:globalProps bridge:bridge];
30
     UIViewController *centerViewController = [RCCViewController controllerWithLayout:children[0] globalProps:globalProps bridge:bridge];
31
     
31
     
32
     // left
32
     // left
33
-    UIViewController *leftViewController = nil;
34
     NSString *componentLeft = props[@"componentLeft"];
33
     NSString *componentLeft = props[@"componentLeft"];
35
     NSDictionary *passPropsLeft = props[@"passPropsLeft"];
34
     NSDictionary *passPropsLeft = props[@"passPropsLeft"];
36
     if (componentLeft) leftViewController = [[RCCViewController alloc] initWithComponent:componentLeft passProps:passPropsLeft navigatorStyle:nil globalProps:globalProps bridge:bridge];
35
     if (componentLeft) leftViewController = [[RCCViewController alloc] initWithComponent:componentLeft passProps:passPropsLeft navigatorStyle:nil globalProps:globalProps bridge:bridge];
37
     
36
     
38
     // right
37
     // right
39
-    UIViewController *rightViewController = nil;
40
     NSString *componentRight = props[@"componentRight"];
38
     NSString *componentRight = props[@"componentRight"];
41
     NSDictionary *passPropsRight = props[@"passPropsRight"];
39
     NSDictionary *passPropsRight = props[@"passPropsRight"];
42
     if (componentRight) rightViewController = [[RCCViewController alloc] initWithComponent:componentRight passProps:passPropsRight navigatorStyle:nil globalProps:globalProps bridge:bridge];
40
     if (componentRight) rightViewController = [[RCCViewController alloc] initWithComponent:componentRight passProps:passPropsRight navigatorStyle:nil globalProps:globalProps bridge:bridge];
133
     {
131
     {
134
         bool enabled = [actionParams[@"enabled"] boolValue];
132
         bool enabled = [actionParams[@"enabled"] boolValue];
135
         if ([actionParams[@"side"] isEqualToString:@"left"]) {
133
         if ([actionParams[@"side"] isEqualToString:@"left"]) {
136
-            [super setLeftDrawerViewController: enabled ? rightViewController : nil];
134
+            [super setLeftDrawerViewController: enabled ? leftViewController : nil];
137
         } else if ([actionParams[@"side"] isEqualToString:@"right"]) {
135
         } else if ([actionParams[@"side"] isEqualToString:@"right"]) {
138
             [super setRightDrawerViewController: enabled ? rightViewController : nil];
136
             [super setRightDrawerViewController: enabled ? rightViewController : nil];
139
         }
137
         }