Browse Source

Fix bottom tabs attach mode (#5757)

Improved attach mode together unit test
Yogev Ben David 5 years ago
parent
commit
e236cb9f5a

+ 2
- 2
lib/ios/BottomTabsAttachMode.h View File

1
-#import "Text.h"
1
+#import "Enum.h"
2
 
2
 
3
 typedef NS_ENUM(NSInteger, AttachMode) {
3
 typedef NS_ENUM(NSInteger, AttachMode) {
4
     BottomTabsAttachModeTogether = 0,
4
     BottomTabsAttachModeTogether = 0,
6
     BottomTabsAttachModeOnSwitchToTab
6
     BottomTabsAttachModeOnSwitchToTab
7
 };
7
 };
8
 
8
 
9
-@interface BottomTabsAttachMode : Text
9
+@interface BottomTabsAttachMode : Enum
10
 
10
 
11
 - (AttachMode)get;
11
 - (AttachMode)get;
12
 
12
 

+ 2
- 6
lib/ios/BottomTabsAttachMode.m View File

3
 
3
 
4
 @implementation BottomTabsAttachMode
4
 @implementation BottomTabsAttachMode
5
 
5
 
6
-- (AttachMode)get {
7
-    return [self.class AttachMode:[super get]];
8
-}
9
-
10
-- (AttachMode)getWithDefaultValue:(id)defaultValue {
11
-    return [self.class AttachMode:[super getWithDefaultValue:defaultValue]];
6
+- (AttachMode)convertString:(NSString *)string {
7
+    return [self.class AttachMode:string];
12
 }
8
 }
13
 
9
 
14
 RCT_ENUM_CONVERTER(AttachMode,
10
 RCT_ENUM_CONVERTER(AttachMode,

+ 12
- 0
lib/ios/Enum.h View File

1
+#import <Foundation/Foundation.h>
2
+#import "Param.h"
3
+
4
+@interface Enum : Param
5
+
6
+- (int)get;
7
+
8
+- (int)getWithDefaultValue:(int)defaultValue;
9
+
10
+- (int)convertString:(NSString *)string;
11
+
12
+@end

+ 22
- 0
lib/ios/Enum.m View File

1
+#import "Enum.h"
2
+
3
+@implementation Enum
4
+
5
+- (int)get {
6
+    return [self convertString:super.get];
7
+}
8
+
9
+- (int)getWithDefaultValue:(int)defaultValue {
10
+    NSString* value = [super getWithDefaultValue:nil];
11
+	if (value) {
12
+        return [self convertString:value];
13
+    } else {
14
+        return defaultValue;
15
+    }
16
+}
17
+
18
+- (int)convertString:(NSString *)string {
19
+    return 0;
20
+}
21
+
22
+@end

+ 8
- 0
lib/ios/EnumParser.h View File

1
+#import <Foundation/Foundation.h>
2
+#import "Enum.h"
3
+
4
+@interface EnumParser : NSObject
5
+
6
++ (Enum *)parse:(NSDictionary *)json key:(NSString *)key ofClass:(Class)class;
7
+
8
+@end

+ 13
- 0
lib/ios/EnumParser.m View File

1
+#import "EnumParser.h"
2
+#import "NullEnum.h"
3
+
4
+@implementation EnumParser
5
+
6
++ (Enum *)parse:(NSDictionary *)json key:(NSString *)key ofClass:(Class)class {
7
+	if (json[key]) {
8
+		return [json[key] isKindOfClass:[NSString class]] ? [[class alloc] initWithValue:json[key]] : [NullEnum new];
9
+	}
10
+	return [NullEnum new];
11
+}
12
+
13
+@end

+ 5
- 0
lib/ios/NullEnum.h View File

1
+#import "Enum.h"
2
+
3
+@interface NullEnum : Enum
4
+
5
+@end

+ 10
- 0
lib/ios/NullEnum.m View File

1
+#import "NullEnum.h"
2
+
3
+@implementation NullEnum
4
+
5
+- (instancetype)init {
6
+	self = [super initWithValue:nil];
7
+	return self;
8
+}
9
+
10
+@end

+ 1
- 1
lib/ios/RNNBottomTabsOptions.m View File

20
 	self.barStyle = [TextParser parse:dict key:@"barStyle"];
20
 	self.barStyle = [TextParser parse:dict key:@"barStyle"];
21
 	self.fontFamily = [TextParser parse:dict key:@"fontFamily"];
21
 	self.fontFamily = [TextParser parse:dict key:@"fontFamily"];
22
 	self.titleDisplayMode = [TextParser parse:dict key:@"titleDisplayMode"];
22
 	self.titleDisplayMode = [TextParser parse:dict key:@"titleDisplayMode"];
23
-    self.tabsAttachMode = [TextParser parse:dict key:@"tabsAttachMode"];
23
+    self.tabsAttachMode = (BottomTabsAttachMode *)[EnumParser parse:dict key:@"tabsAttachMode" ofClass:BottomTabsAttachMode.class];
24
 	
24
 	
25
 	return self;
25
 	return self;
26
 }
26
 }

+ 2
- 2
lib/ios/RNNComponentViewController.m View File

52
 - (void)render {
52
 - (void)render {
53
     if (!self.waitForRender)
53
     if (!self.waitForRender)
54
         [self readyForPresentation];
54
         [self readyForPresentation];
55
-    else
56
-        [self renderReactViewIfNeeded];
55
+
56
+    [self renderReactViewIfNeeded];
57
 }
57
 }
58
 
58
 
59
 - (void)renderReactViewIfNeeded {
59
 - (void)renderReactViewIfNeeded {

+ 1
- 0
lib/ios/RNNOptions.h View File

8
 #import "ImageParser.h"
8
 #import "ImageParser.h"
9
 #import "IntNumberParser.h"
9
 #import "IntNumberParser.h"
10
 #import "DoubleParser.h"
10
 #import "DoubleParser.h"
11
+#import "EnumParser.h"
11
 
12
 
12
 @interface RNNOptions : NSObject
13
 @interface RNNOptions : NSObject
13
 
14
 

+ 24
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj View File

215
 		50887CA920F26BFE00D06111 /* RNNOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */; };
215
 		50887CA920F26BFE00D06111 /* RNNOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */; };
216
 		50887CAA20F26BFE00D06111 /* RNNOverlayWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 50887CA820F26BFE00D06111 /* RNNOverlayWindow.h */; };
216
 		50887CAA20F26BFE00D06111 /* RNNOverlayWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 50887CA820F26BFE00D06111 /* RNNOverlayWindow.h */; };
217
 		508EBDBD2278746400BEC144 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 508EBDBA2278742700BEC144 /* JavaScriptCore.framework */; };
217
 		508EBDBD2278746400BEC144 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 508EBDBA2278742700BEC144 /* JavaScriptCore.framework */; };
218
+		509416A323A11C340036092C /* Enum.h in Headers */ = {isa = PBXBuildFile; fileRef = 509416A123A11C340036092C /* Enum.h */; };
219
+		509416A423A11C340036092C /* Enum.m in Sources */ = {isa = PBXBuildFile; fileRef = 509416A223A11C340036092C /* Enum.m */; };
220
+		509416A723A11C630036092C /* EnumParser.h in Headers */ = {isa = PBXBuildFile; fileRef = 509416A523A11C630036092C /* EnumParser.h */; };
221
+		509416A823A11C630036092C /* EnumParser.m in Sources */ = {isa = PBXBuildFile; fileRef = 509416A623A11C630036092C /* EnumParser.m */; };
222
+		509416AB23A11CB20036092C /* NullEnum.h in Headers */ = {isa = PBXBuildFile; fileRef = 509416A923A11CB20036092C /* NullEnum.h */; };
223
+		509416AC23A11CB20036092C /* NullEnum.m in Sources */ = {isa = PBXBuildFile; fileRef = 509416AA23A11CB20036092C /* NullEnum.m */; };
218
 		50967F5B232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 50967F5A232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m */; };
224
 		50967F5B232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 50967F5A232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m */; };
219
 		509B2480217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 509B247F217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m */; };
225
 		509B2480217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 509B247F217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m */; };
220
 		509B258F2178BE7A00C83C23 /* RNNStackPresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 509B258E2178BE7A00C83C23 /* RNNStackPresenterTest.m */; };
226
 		509B258F2178BE7A00C83C23 /* RNNStackPresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 509B258E2178BE7A00C83C23 /* RNNStackPresenterTest.m */; };
585
 		50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayWindow.m; sourceTree = "<group>"; };
591
 		50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayWindow.m; sourceTree = "<group>"; };
586
 		50887CA820F26BFE00D06111 /* RNNOverlayWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNOverlayWindow.h; sourceTree = "<group>"; };
592
 		50887CA820F26BFE00D06111 /* RNNOverlayWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNOverlayWindow.h; sourceTree = "<group>"; };
587
 		508EBDBA2278742700BEC144 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
593
 		508EBDBA2278742700BEC144 /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
594
+		509416A123A11C340036092C /* Enum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Enum.h; sourceTree = "<group>"; };
595
+		509416A223A11C340036092C /* Enum.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Enum.m; sourceTree = "<group>"; };
596
+		509416A523A11C630036092C /* EnumParser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EnumParser.h; sourceTree = "<group>"; };
597
+		509416A623A11C630036092C /* EnumParser.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EnumParser.m; sourceTree = "<group>"; };
598
+		509416A923A11CB20036092C /* NullEnum.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NullEnum.h; sourceTree = "<group>"; };
599
+		509416AA23A11CB20036092C /* NullEnum.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NullEnum.m; sourceTree = "<group>"; };
588
 		50967F5A232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNFontAttributesCreatorTest.m; sourceTree = "<group>"; };
600
 		50967F5A232FC2C200BEEA92 /* RNNFontAttributesCreatorTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNFontAttributesCreatorTest.m; sourceTree = "<group>"; };
589
 		509B247F217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+RNNOptionsTest.m"; sourceTree = "<group>"; };
601
 		509B247F217873FF00C83C23 /* UINavigationController+RNNOptionsTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UINavigationController+RNNOptionsTest.m"; sourceTree = "<group>"; };
590
 		509B258E2178BE7A00C83C23 /* RNNStackPresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNStackPresenterTest.m; sourceTree = "<group>"; };
602
 		509B258E2178BE7A00C83C23 /* RNNStackPresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNStackPresenterTest.m; sourceTree = "<group>"; };
910
 				5012241521736667000F5F98 /* Color.m */,
922
 				5012241521736667000F5F98 /* Color.m */,
911
 				5012241821736678000F5F98 /* Image.h */,
923
 				5012241821736678000F5F98 /* Image.h */,
912
 				5012241921736678000F5F98 /* Image.m */,
924
 				5012241921736678000F5F98 /* Image.m */,
925
+				509416A123A11C340036092C /* Enum.h */,
926
+				509416A223A11C340036092C /* Enum.m */,
913
 				50E02BD621A6EE0F00A43942 /* SideMenuOpenMode.h */,
927
 				50E02BD621A6EE0F00A43942 /* SideMenuOpenMode.h */,
914
 				50E02BD721A6EE0F00A43942 /* SideMenuOpenMode.m */,
928
 				50E02BD721A6EE0F00A43942 /* SideMenuOpenMode.m */,
915
 				50495940216F5E5D006D2B81 /* NullBool.h */,
929
 				50495940216F5E5D006D2B81 /* NullBool.h */,
916
 				50495941216F5E5D006D2B81 /* NullBool.m */,
930
 				50495941216F5E5D006D2B81 /* NullBool.m */,
931
+				509416A923A11CB20036092C /* NullEnum.h */,
932
+				509416AA23A11CB20036092C /* NullEnum.m */,
917
 				50495948216F5FE6006D2B81 /* NullText.h */,
933
 				50495948216F5FE6006D2B81 /* NullText.h */,
918
 				50495949216F5FE6006D2B81 /* NullText.m */,
934
 				50495949216F5FE6006D2B81 /* NullText.m */,
919
 				50495950216F62BD006D2B81 /* NullNumber.h */,
935
 				50495950216F62BD006D2B81 /* NullNumber.h */,
959
 				5039559A2174867000B0A663 /* DoubleParser.m */,
975
 				5039559A2174867000B0A663 /* DoubleParser.m */,
960
 				309874E37C7E9764C7B694E5 /* DotIndicatorParser.m */,
976
 				309874E37C7E9764C7B694E5 /* DotIndicatorParser.m */,
961
 				309871FBA64AD937CEF3E191 /* DotIndicatorParser.h */,
977
 				309871FBA64AD937CEF3E191 /* DotIndicatorParser.h */,
978
+				509416A523A11C630036092C /* EnumParser.h */,
979
+				509416A623A11C630036092C /* EnumParser.m */,
962
 			);
980
 			);
963
 			name = Parsers;
981
 			name = Parsers;
964
 			sourceTree = "<group>";
982
 			sourceTree = "<group>";
1337
 				504AFE761FFFF1E00076E904 /* RNNNavigationOptions.h in Headers */,
1355
 				504AFE761FFFF1E00076E904 /* RNNNavigationOptions.h in Headers */,
1338
 				504AFE771FFFF1E20076E904 /* RNNTopBarOptions.h in Headers */,
1356
 				504AFE771FFFF1E20076E904 /* RNNTopBarOptions.h in Headers */,
1339
 				5038A3CE216E35E0009280BC /* Dictionary.h in Headers */,
1357
 				5038A3CE216E35E0009280BC /* Dictionary.h in Headers */,
1358
+				509416A323A11C340036092C /* Enum.h in Headers */,
1340
 				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
1359
 				26916C981E4B9E7700D13680 /* RNNReactRootViewCreator.h in Headers */,
1341
 				5012241A21736678000F5F98 /* Image.h in Headers */,
1360
 				5012241A21736678000F5F98 /* Image.h in Headers */,
1342
 				506A2B1420973DFD00F43A95 /* RNNErrorHandler.h in Headers */,
1361
 				506A2B1420973DFD00F43A95 /* RNNErrorHandler.h in Headers */,
1361
 				50E02BDD21A6EE7900A43942 /* SideMenuOpenGestureModeParser.h in Headers */,
1380
 				50E02BDD21A6EE7900A43942 /* SideMenuOpenGestureModeParser.h in Headers */,
1362
 				5038A3B5216DF602009280BC /* UINavigationController+RNNOptions.h in Headers */,
1381
 				5038A3B5216DF602009280BC /* UINavigationController+RNNOptions.h in Headers */,
1363
 				50E5F78D223F9FAF002AFEAD /* RNNElementTransitionOptions.h in Headers */,
1382
 				50E5F78D223F9FAF002AFEAD /* RNNElementTransitionOptions.h in Headers */,
1383
+				509416AB23A11CB20036092C /* NullEnum.h in Headers */,
1364
 				E5F6C3A422DB4D0F0093C2CE /* UIColor+RNNUtils.h in Headers */,
1384
 				E5F6C3A422DB4D0F0093C2CE /* UIColor+RNNUtils.h in Headers */,
1365
 				5038A3C1216E1E66009280BC /* RNNFontAttributesCreator.h in Headers */,
1385
 				5038A3C1216E1E66009280BC /* RNNFontAttributesCreator.h in Headers */,
1366
 				5016E8EF20209690009D4F7C /* RNNCustomTitleView.h in Headers */,
1386
 				5016E8EF20209690009D4F7C /* RNNCustomTitleView.h in Headers */,
1396
 				7BEF0D181E437684003E96B0 /* RNNComponentViewController.h in Headers */,
1416
 				7BEF0D181E437684003E96B0 /* RNNComponentViewController.h in Headers */,
1397
 				7B1126A61E2D2B6C00F9B03B /* RNNBridgeModule.h in Headers */,
1417
 				7B1126A61E2D2B6C00F9B03B /* RNNBridgeModule.h in Headers */,
1398
 				E8DA24401F97459B00CD552B /* RNNElementFinder.h in Headers */,
1418
 				E8DA24401F97459B00CD552B /* RNNElementFinder.h in Headers */,
1419
+				509416A723A11C630036092C /* EnumParser.h in Headers */,
1399
 				50AB0B1C2255F8640039DAED /* UIViewController+LayoutProtocol.h in Headers */,
1420
 				50AB0B1C2255F8640039DAED /* UIViewController+LayoutProtocol.h in Headers */,
1400
 				50D031342005149000386B3D /* RNNOverlayManager.h in Headers */,
1421
 				50D031342005149000386B3D /* RNNOverlayManager.h in Headers */,
1401
 				50E5F7952240EBD6002AFEAD /* RNNAnimationsTransitionDelegate.h in Headers */,
1422
 				50E5F7952240EBD6002AFEAD /* RNNAnimationsTransitionDelegate.h in Headers */,
1606
 			buildActionMask = 2147483647;
1627
 			buildActionMask = 2147483647;
1607
 			files = (
1628
 			files = (
1608
 				50C4A497206BDDBB00DB292E /* RNNSubtitleOptions.m in Sources */,
1629
 				50C4A497206BDDBB00DB292E /* RNNSubtitleOptions.m in Sources */,
1630
+				509416A823A11C630036092C /* EnumParser.m in Sources */,
1609
 				50A409CB238D444900D5FF7D /* UINavigationBar+utils.m in Sources */,
1631
 				50A409CB238D444900D5FF7D /* UINavigationBar+utils.m in Sources */,
1610
 				50AB0B1D2255F8640039DAED /* UIViewController+LayoutProtocol.m in Sources */,
1632
 				50AB0B1D2255F8640039DAED /* UIViewController+LayoutProtocol.m in Sources */,
1611
 				263905B41E4C6F440023D7D3 /* MMDrawerVisualState.m in Sources */,
1633
 				263905B41E4C6F440023D7D3 /* MMDrawerVisualState.m in Sources */,
1623
 				501CD320214A5B6900A6E225 /* RNNLayoutInfo.m in Sources */,
1645
 				501CD320214A5B6900A6E225 /* RNNLayoutInfo.m in Sources */,
1624
 				7BEF0D191E437684003E96B0 /* RNNComponentViewController.m in Sources */,
1646
 				7BEF0D191E437684003E96B0 /* RNNComponentViewController.m in Sources */,
1625
 				50415CBB20553B8E00BB682E /* RNNScreenTransition.m in Sources */,
1647
 				50415CBB20553B8E00BB682E /* RNNScreenTransition.m in Sources */,
1648
+				509416A423A11C340036092C /* Enum.m in Sources */,
1626
 				E8A5CD531F464F0400E89D0D /* RNNAnimator.m in Sources */,
1649
 				E8A5CD531F464F0400E89D0D /* RNNAnimator.m in Sources */,
1627
 				50CB3B6A1FDE911400AA153B /* RNNSideMenuOptions.m in Sources */,
1650
 				50CB3B6A1FDE911400AA153B /* RNNSideMenuOptions.m in Sources */,
1628
 				261F0E6B1E6F028A00989DE2 /* RNNNavigationStackManager.m in Sources */,
1651
 				261F0E6B1E6F028A00989DE2 /* RNNNavigationStackManager.m in Sources */,
1640
 				7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */,
1663
 				7B1126A01E2D263F00F9B03B /* RNNEventEmitter.m in Sources */,
1641
 				A7626BFD1FC2FB2C00492FB8 /* RNNTopBarOptions.m in Sources */,
1664
 				A7626BFD1FC2FB2C00492FB8 /* RNNTopBarOptions.m in Sources */,
1642
 				5050465521F8F4490035497A /* RNNReactComponentRegistry.m in Sources */,
1665
 				5050465521F8F4490035497A /* RNNReactComponentRegistry.m in Sources */,
1666
+				509416AC23A11CB20036092C /* NullEnum.m in Sources */,
1643
 				50570BEB2063E09B006A1B5C /* RNNTitleViewHelper.m in Sources */,
1667
 				50570BEB2063E09B006A1B5C /* RNNTitleViewHelper.m in Sources */,
1644
 				263905E71E4CAC950023D7D3 /* RNNSideMenuChildVC.m in Sources */,
1668
 				263905E71E4CAC950023D7D3 /* RNNSideMenuChildVC.m in Sources */,
1645
 				50495957216F6B3D006D2B81 /* DictionaryParser.m in Sources */,
1669
 				50495957216F6B3D006D2B81 /* DictionaryParser.m in Sources */,

+ 12
- 7
playground/ios/NavigationTests/RNNCommandsHandlerTest.m View File

54
 @property (nonatomic, strong) id controllerFactory;
54
 @property (nonatomic, strong) id controllerFactory;
55
 @property (nonatomic, strong) id overlayManager;
55
 @property (nonatomic, strong) id overlayManager;
56
 @property (nonatomic, strong) id eventEmmiter;
56
 @property (nonatomic, strong) id eventEmmiter;
57
+@property (nonatomic, strong) id creator;
57
 
58
 
58
 @end
59
 @end
59
 
60
 
61
 
62
 
62
 - (void)setUp {
63
 - (void)setUp {
63
 	[super setUp];
64
 	[super setUp];
65
+	self.creator = [OCMockObject partialMockForObject:[RNNTestRootViewCreator new]];
64
 	self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
66
 	self.mainWindow = [OCMockObject partialMockForObject:[UIWindow new]];
65
 	self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
67
 	self.eventEmmiter = [OCMockObject partialMockForObject:[RNNEventEmitter new]];
66
 	self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
68
 	self.overlayManager = [OCMockObject partialMockForObject:[RNNOverlayManager new]];
67
 	self.modalManager = [OCMockObject partialMockForObject:[RNNModalManager new]];
69
 	self.modalManager = [OCMockObject partialMockForObject:[RNNModalManager new]];
68
 	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:nil componentRegistry:nil andBridge:nil bottomTabsAttachModeFactory:[BottomTabsAttachModeFactory new]]];
70
 	self.controllerFactory = [OCMockObject partialMockForObject:[[RNNControllerFactory alloc] initWithRootViewCreator:nil eventEmitter:self.eventEmmiter store:nil componentRegistry:nil andBridge:nil bottomTabsAttachModeFactory:[BottomTabsAttachModeFactory new]]];
69
 	self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:self.modalManager overlayManager:self.overlayManager mainWindow:_mainWindow];
71
 	self.uut = [[RNNCommandsHandler alloc] initWithControllerFactory:self.controllerFactory eventEmitter:self.eventEmmiter stackManager:[RNNNavigationStackManager new] modalManager:self.modalManager overlayManager:self.overlayManager mainWindow:_mainWindow];
70
-	self.vc1 = self.generateComponent;
71
-	self.vc2 = self.generateComponent;
72
-	self.vc3 = self.generateComponent;
72
+	self.vc1 = [self generateComponentWithComponentId:@"1"];
73
+	self.vc2 = [self generateComponentWithComponentId:@"2"];
74
+	self.vc3 = [self generateComponentWithComponentId:@"3"];
73
 	_nvc = [[MockUINavigationController alloc] init];
75
 	_nvc = [[MockUINavigationController alloc] init];
74
 	[_nvc setViewControllers:@[self.vc1, self.vc2, self.vc3]];
76
 	[_nvc setViewControllers:@[self.vc1, self.vc2, self.vc3]];
75
 	OCMStub([self.sharedApplication keyWindow]).andReturn(self.mainWindow);
77
 	OCMStub([self.sharedApplication keyWindow]).andReturn(self.mainWindow);
76
 }
78
 }
77
 
79
 
78
-- (RNNComponentViewController *)generateComponent {
79
-	return [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:[[RNNTestRootViewCreator alloc] init] eventEmitter:nil presenter:[RNNComponentPresenter new] options:[[RNNNavigationOptions alloc] initWithDict:@{}] defaultOptions:nil];
80
+- (RNNComponentViewController *)generateComponentWithComponentId:(NSString *)componentId {
81
+	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
82
+	layoutInfo.componentId = componentId;
83
+	return [[RNNComponentViewController alloc] initWithLayoutInfo:layoutInfo rootViewCreator:_creator eventEmitter:nil presenter:[RNNComponentPresenter new] options:[[RNNNavigationOptions alloc] initWithDict:@{}] defaultOptions:nil];
80
 }
84
 }
81
 
85
 
82
 - (void)testAssertReadyForEachMethodThrowsExceptoins {
86
 - (void)testAssertReadyForEachMethodThrowsExceptoins {
187
 
191
 
188
 - (void)testShowOverlay_withCreatedLayout {
192
 - (void)testShowOverlay_withCreatedLayout {
189
 	[self.uut setReadyToReceiveCommands:true];
193
 	[self.uut setReadyToReceiveCommands:true];
190
-	UIViewController* layoutVC = self.generateComponent;
194
+	UIViewController* layoutVC = [self generateComponentWithComponentId:nil];
191
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(layoutVC);
195
 	OCMStub([self.controllerFactory createLayout:[OCMArg any]]).andReturn(layoutVC);
192
 	
196
 	
193
 	[[self.overlayManager expect] showOverlayWindow:[OCMArg any]];
197
 	[[self.overlayManager expect] showOverlayWindow:[OCMArg any]];
364
 	[self.uut setReadyToReceiveCommands:true];
368
 	[self.uut setReadyToReceiveCommands:true];
365
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
369
 	RNNNavigationOptions* options = [[RNNNavigationOptions alloc] initEmptyOptions];
366
 	options.bottomTabs.tabsAttachMode = [[BottomTabsAttachMode alloc] initWithValue:@"together"];
370
 	options.bottomTabs.tabsAttachMode = [[BottomTabsAttachMode alloc] initWithValue:@"together"];
367
-	options.animations.setRoot.waitForRender = [[Bool alloc] initWithBOOL:YES];
368
 
371
 
369
 	BottomTabsBaseAttacher* attacher = [[[BottomTabsAttachModeFactory alloc] initWithDefaultOptions:nil] fromOptions:options];
372
 	BottomTabsBaseAttacher* attacher = [[[BottomTabsAttachModeFactory alloc] initWithDefaultOptions:nil] fromOptions:options];
370
 	RNNBottomTabsController* tabBarController = [[RNNBottomTabsController alloc] initWithLayoutInfo:nil creator:nil options:options defaultOptions:[[RNNNavigationOptions alloc] initEmptyOptions] presenter:[RNNBasePresenter new] eventEmitter:_eventEmmiter childViewControllers:@[_vc1, _vc2] bottomTabsAttacher:attacher];
373
 	RNNBottomTabsController* tabBarController = [[RNNBottomTabsController alloc] initWithLayoutInfo:nil creator:nil options:options defaultOptions:[[RNNNavigationOptions alloc] initEmptyOptions] presenter:[RNNBasePresenter new] eventEmitter:_eventEmmiter childViewControllers:@[_vc1, _vc2] bottomTabsAttacher:attacher];
374
 	[self.uut setRoot:@{} commandId:@"" completion:^{}];
377
 	[self.uut setRoot:@{} commandId:@"" completion:^{}];
375
 	XCTAssertTrue(_vc1.isViewLoaded);
378
 	XCTAssertTrue(_vc1.isViewLoaded);
376
 	XCTAssertTrue(_vc2.isViewLoaded);
379
 	XCTAssertTrue(_vc2.isViewLoaded);
380
+	XCTAssertEqual(_vc1.view.tag, 1);
381
+	XCTAssertEqual(_vc2.view.tag, 2);
377
 }
382
 }
378
 
383
 
379
 - (void)testSetRoot_withBottomTabsAttachModeOnSwitchToTab {
384
 - (void)testSetRoot_withBottomTabsAttachModeOnSwitchToTab {

+ 1
- 0
playground/ios/NavigationTests/RNNTestRootViewCreator.m View File

4
 
4
 
5
 - (UIView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
5
 - (UIView*)createRootView:(NSString*)name rootViewId:(NSString*)rootViewId reactViewReadyBlock:(RNNReactViewReadyCompletionBlock)reactViewReadyBlock {
6
 	UIView *view = [[UIView alloc] init];
6
 	UIView *view = [[UIView alloc] init];
7
+	view.tag = [rootViewId intValue];
7
 	return view;
8
 	return view;
8
 }
9
 }
9
 
10