Browse Source

Fixes peek and pop viewController on iOS - #4216

yogevbd 6 years ago
parent
commit
d7e540015d
3 changed files with 18 additions and 13 deletions
  1. 8
    8
      lib/ios/RNNCommandsHandler.m
  2. 4
    4
      lib/ios/RNNPreviewOptions.h
  3. 6
    1
      lib/ios/RNNPreviewOptions.m

+ 8
- 8
lib/ios/RNNCommandsHandler.m View File

99
 	UIViewController<RNNLayoutProtocol> *newVc = [_controllerFactory createLayout:layout saveToStore:_store];
99
 	UIViewController<RNNLayoutProtocol> *newVc = [_controllerFactory createLayout:layout saveToStore:_store];
100
 	UIViewController *fromVC = [_store findComponentForId:componentId];
100
 	UIViewController *fromVC = [_store findComponentForId:componentId];
101
 	
101
 	
102
-	if ([newVc.options.preview.reactTag floatValue] > 0) {
102
+	if ([[newVc.options.preview.reactTag getWithDefaultValue:@(0)] floatValue] > 0) {
103
 		UIViewController* vc = [_store findComponentForId:componentId];
103
 		UIViewController* vc = [_store findComponentForId:componentId];
104
 		
104
 		
105
 		if([vc isKindOfClass:[RNNRootViewController class]]) {
105
 		if([vc isKindOfClass:[RNNRootViewController class]]) {
109
       		rootVc.previewCallback = ^(UIViewController *vcc) {
109
       		rootVc.previewCallback = ^(UIViewController *vcc) {
110
 				RNNRootViewController* rvc  = (RNNRootViewController*)vcc;
110
 				RNNRootViewController* rvc  = (RNNRootViewController*)vcc;
111
 				[self->_eventEmitter sendOnPreviewCompleted:componentId previewComponentId:newVc.layoutInfo.componentId];
111
 				[self->_eventEmitter sendOnPreviewCompleted:componentId previewComponentId:newVc.layoutInfo.componentId];
112
-				if ([newVc.options.preview.commit floatValue] > 0) {
112
+				if ([newVc.options.preview.commit getWithDefaultValue:NO]) {
113
 					[CATransaction begin];
113
 					[CATransaction begin];
114
 					[CATransaction setCompletionBlock:^{
114
 					[CATransaction setCompletionBlock:^{
115
 						[self->_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
115
 						[self->_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
122
 			
122
 			
123
 			CGSize size = CGSizeMake(rootVc.view.frame.size.width, rootVc.view.frame.size.height);
123
 			CGSize size = CGSizeMake(rootVc.view.frame.size.width, rootVc.view.frame.size.height);
124
 			
124
 			
125
-			if (newVc.options.preview.width) {
126
-				size.width = [newVc.options.preview.width floatValue];
125
+			if (newVc.options.preview.width.hasValue) {
126
+				size.width = [newVc.options.preview.width.get floatValue];
127
 			}
127
 			}
128
 			
128
 			
129
-			if (newVc.options.preview.height) {
130
-				size.height = [newVc.options.preview.height floatValue];
129
+			if (newVc.options.preview.height.hasValue) {
130
+				size.height = [newVc.options.preview.height.get floatValue];
131
 			}
131
 			}
132
 			
132
 			
133
-			if (newVc.options.preview.width || newVc.options.preview.height) {
133
+			if (newVc.options.preview.width.hasValue || newVc.options.preview.height.hasValue) {
134
 				newVc.preferredContentSize = size;
134
 				newVc.preferredContentSize = size;
135
 			}
135
 			}
136
       
136
       
137
 			RCTExecuteOnMainQueue(^{
137
 			RCTExecuteOnMainQueue(^{
138
-				UIView *view = [[ReactNativeNavigation getBridge].uiManager viewForReactTag:newVc.options.preview.reactTag];
138
+				UIView *view = [[ReactNativeNavigation getBridge].uiManager viewForReactTag:newVc.options.preview.reactTag.get];
139
 				[rootVc registerForPreviewingWithDelegate:(id)rootVc sourceView:view];
139
 				[rootVc registerForPreviewingWithDelegate:(id)rootVc sourceView:view];
140
 			});
140
 			});
141
 		}
141
 		}

+ 4
- 4
lib/ios/RNNPreviewOptions.h View File

2
 
2
 
3
 @interface RNNPreviewOptions : RNNOptions
3
 @interface RNNPreviewOptions : RNNOptions
4
 
4
 
5
-@property (nonatomic, strong) NSNumber* reactTag;
6
-@property (nonatomic, strong) NSNumber* width;
7
-@property (nonatomic, strong) NSNumber* height;
8
-@property (nonatomic, strong) NSNumber* commit;
5
+@property (nonatomic, strong) Number* reactTag;
6
+@property (nonatomic, strong) Number* width;
7
+@property (nonatomic, strong) Number* height;
8
+@property (nonatomic, strong) Bool* commit;
9
 @property (nonatomic, strong) NSArray* actions;
9
 @property (nonatomic, strong) NSArray* actions;
10
 
10
 
11
 @end
11
 @end

+ 6
- 1
lib/ios/RNNPreviewOptions.m View File

3
 @implementation RNNPreviewOptions
3
 @implementation RNNPreviewOptions
4
 
4
 
5
 - (instancetype)initWithDict:(NSDictionary *)dict {
5
 - (instancetype)initWithDict:(NSDictionary *)dict {
6
-
7
 	self = [super initWithDict:dict];
6
 	self = [super initWithDict:dict];
8
 
7
 
8
+	self.reactTag = [NumberParser parse:dict key:@"reactTag"];
9
+	self.height = [NumberParser parse:dict key:@"height"];
10
+	self.width = [NumberParser parse:dict key:@"width"];
11
+	self.commit = [BoolParser parse:dict key:@"commit"];
12
+	self.actions = dict[@"actions"];
13
+	
9
 	return self;
14
 	return self;
10
 }
15
 }
11
 
16