Bladeren bron

IOS: modal upgrades (#3084)

frankenthumbs 6 jaren geleden
bovenliggende
commit
3be15d2224

+ 12
- 6
lib/ios/RNNModalManager.m Bestand weergeven

@@ -37,7 +37,13 @@
37 37
 	self.toVC = (UIViewController<RNNRootViewProtocol>*)viewController;
38 38
 	_completionBlock = completion;
39 39
 	
40
-	if ([self.toVC isCustomViewController]) {
40
+    if ([self.toVC respondsToSelector:@selector(applyModalOptions)]) {
41
+        [self.toVC applyModalOptions];
42
+    }
43
+    
44
+    if ([self.toVC respondsToSelector:@selector(isCustomViewController)] &&
45
+        [self.toVC isCustomViewController]
46
+    ) {
41 47
 		[self showModalAfterLoad:nil];
42 48
 	} else {
43 49
 		[self waitForContentToAppearAndThen:@selector(showModalAfterLoad:)];
@@ -60,19 +66,19 @@
60 66
 
61 67
 -(void)removePendingNextModalIfOnTop {
62 68
 	NSString *componentId = [[_store pendingModalIdsToDismiss] lastObject];
63
-	
69
+
64 70
 	UIViewController<RNNRootViewProtocol> *modalToDismiss = (UIViewController<RNNRootViewProtocol>*)[_store findComponentForId:componentId];
65
-	
71
+
66 72
 	if(!modalToDismiss) {
67 73
 		return;
68 74
 	}
69
-	
75
+
70 76
 	UIViewController* topPresentedVC = [self topPresentedVC];
71
-	
77
+
72 78
 	if (modalToDismiss.options.animations.showModal) {
73 79
 		modalToDismiss.transitioningDelegate = modalToDismiss;
74 80
 	}
75
-	
81
+
76 82
 	if (modalToDismiss == topPresentedVC || [[topPresentedVC childViewControllers] containsObject:modalToDismiss]) {
77 83
 		[modalToDismiss dismissViewControllerAnimated:modalToDismiss.options.animations.dismissModal.enable completion:^{
78 84
 			[[_store pendingModalIdsToDismiss] removeObject:componentId];

+ 2
- 0
lib/ios/RNNNavigationOptions.h Bestand weergeven

@@ -38,8 +38,10 @@ extern const NSInteger TOP_BAR_TRANSPARENT_TAG;
38 38
 @property (nonatomic, strong) NSDictionary* backgroundImage;
39 39
 @property (nonatomic, strong) NSDictionary* rootBackgroundImage;
40 40
 @property (nonatomic, strong) NSString* modalPresentationStyle;
41
+@property (nonatomic, strong) NSString* modalTransitionStyle;
41 42
 
42 43
 - (UIInterfaceOrientationMask)supportedOrientations;
43 44
 
45
+- (void)applyModalOptions:(UIViewController*)viewController;
44 46
 
45 47
 @end

+ 22
- 4
lib/ios/RNNNavigationOptions.m Bestand weergeven

@@ -27,6 +27,17 @@ RCT_ENUM_CONVERTER(UIModalPresentationStyle,
27 27
 
28 28
 @end
29 29
 
30
+@implementation RCTConvert (UIModalTransitionStyle)
31
+
32
+RCT_ENUM_CONVERTER(UIModalTransitionStyle,
33
+                   (@{@"coverVertical": @(UIModalTransitionStyleCoverVertical),
34
+                      @"flipHorizontal": @(UIModalTransitionStyleFlipHorizontal),
35
+                      @"crossDissolve": @(UIModalTransitionStyleCrossDissolve),
36
+                      @"partialCurl": @(UIModalTransitionStylePartialCurl)
37
+                      }), UIModalTransitionStyleCoverVertical, integerValue)
38
+
39
+@end
40
+
30 41
 @implementation RNNNavigationOptions
31 42
 
32 43
 
@@ -91,10 +102,17 @@ RCT_ENUM_CONVERTER(UIModalPresentationStyle,
91 102
 		backgroundImageView.image = [self.rootBackgroundImage isKindOfClass:[UIImage class]] ? (UIImage*)self.rootBackgroundImage : [RCTConvert UIImage:self.rootBackgroundImage];
92 103
 		[backgroundImageView setContentMode:UIViewContentModeScaleAspectFill];
93 104
 	}
94
-	
95
-	if (self.modalPresentationStyle) {
96
-		viewController.modalPresentationStyle = [RCTConvert UIModalPresentationStyle:self.modalPresentationStyle];
97
-	}
105
+    
106
+    [self applyModalOptions:viewController];
107
+}
108
+
109
+- (void)applyModalOptions:(UIViewController*)viewController {
110
+    if (self.modalPresentationStyle) {
111
+        viewController.modalPresentationStyle = [RCTConvert UIModalPresentationStyle:self.modalPresentationStyle];
112
+    }
113
+    if (self.modalTransitionStyle) {
114
+        viewController.modalTransitionStyle = [RCTConvert UIModalTransitionStyle:self.modalTransitionStyle];
115
+    }
98 116
 }
99 117
 
100 118
 - (UIInterfaceOrientationMask)supportedOrientations {

+ 4
- 0
lib/ios/RNNRootViewController.m Bestand weergeven

@@ -80,6 +80,10 @@
80 80
 	[self setCustomNavigationComponentBackground];
81 81
 }
82 82
 
83
+- (void)applyModalOptions {
84
+    [self.options applyModalOptions:self];
85
+}
86
+
83 87
 - (void)mergeOptions:(NSDictionary *)options {
84 88
 	[self.options mergeIfEmptyWith:options];
85 89
 }

+ 1
- 0
lib/ios/RNNRootViewProtocol.h Bestand weergeven

@@ -7,6 +7,7 @@
7 7
 - (BOOL)isCustomViewController;
8 8
 - (void)performOnRotation:(void (^)(void))block;
9 9
 - (void)optionsUpdated;
10
+- (void)applyModalOptions;
10 11
 
11 12
 @required
12 13
 - (BOOL)isCustomTransitioned;