Просмотр исходного кода

Fixes peek and pop viewController on iOS - #4216

yogevbd 6 лет назад
Родитель
Сommit
d7e540015d
3 измененных файлов: 18 добавлений и 13 удалений
  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 Просмотреть файл

@@ -99,7 +99,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
99 99
 	UIViewController<RNNLayoutProtocol> *newVc = [_controllerFactory createLayout:layout saveToStore:_store];
100 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 103
 		UIViewController* vc = [_store findComponentForId:componentId];
104 104
 		
105 105
 		if([vc isKindOfClass:[RNNRootViewController class]]) {
@@ -109,7 +109,7 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
109 109
       		rootVc.previewCallback = ^(UIViewController *vcc) {
110 110
 				RNNRootViewController* rvc  = (RNNRootViewController*)vcc;
111 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 113
 					[CATransaction begin];
114 114
 					[CATransaction setCompletionBlock:^{
115 115
 						[self->_eventEmitter sendOnNavigationCommandCompletion:push params:@{@"componentId": componentId}];
@@ -122,20 +122,20 @@ static NSString* const setDefaultOptions	= @"setDefaultOptions";
122 122
 			
123 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 134
 				newVc.preferredContentSize = size;
135 135
 			}
136 136
       
137 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 139
 				[rootVc registerForPreviewingWithDelegate:(id)rootVc sourceView:view];
140 140
 			});
141 141
 		}

+ 4
- 4
lib/ios/RNNPreviewOptions.h Просмотреть файл

@@ -2,10 +2,10 @@
2 2
 
3 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 9
 @property (nonatomic, strong) NSArray* actions;
10 10
 
11 11
 @end

+ 6
- 1
lib/ios/RNNPreviewOptions.m Просмотреть файл

@@ -3,9 +3,14 @@
3 3
 @implementation RNNPreviewOptions
4 4
 
5 5
 - (instancetype)initWithDict:(NSDictionary *)dict {
6
-
7 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 14
 	return self;
10 15
 }
11 16