Bladeren bron

Apply topBar appearance options on current child navigationItem (#5994)

This commit changes how stack child options are applied on iOS 13. Until now, options were applied directly to the navigationItem of the stack which is shared between all children.
This commit applies options on the navigationItem of each child instead. This fixes issues with color transitions when popping and pushing children to the stack.
Yogev Ben David 4 jaren geleden
bovenliggende
commit
52108484cc
No account linked to committer's email address

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

@@ -39,6 +39,8 @@ typedef void (^RNNReactViewReadyCompletionBlock)(void);
39 39
 
40 40
 - (void)componentDidDisappear;
41 41
 
42
+- (UINavigationItem *)currentNavigationItem;
43
+
42 44
 - (UIStatusBarStyle)getStatusBarStyle:(RNNNavigationOptions *)resolvedOptions;
43 45
 
44 46
 - (UIInterfaceOrientationMask)getOrientation:(RNNNavigationOptions *)options;

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

@@ -110,6 +110,10 @@
110 110
     }
111 111
 }
112 112
 
113
+- (UINavigationItem *)currentNavigationItem {
114
+    return self.boundViewController.getCurrentChild.navigationItem;
115
+}
116
+
113 117
 - (UIInterfaceOrientationMask)getOrientation:(RNNNavigationOptions *)options {
114 118
     return [options withDefault:[self defaultOptions]].layout.supportedOrientations;
115 119
 }

+ 3
- 0
lib/ios/RNNComponentViewController.m Bestand weergeven

@@ -8,6 +8,9 @@
8 8
 - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo rootViewCreator:(id<RNNComponentViewCreator>)creator eventEmitter:(RNNEventEmitter *)eventEmitter presenter:(RNNComponentPresenter *)presenter options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions {
9 9
 	self = [super initWithLayoutInfo:layoutInfo creator:creator options:options defaultOptions:defaultOptions presenter:presenter eventEmitter:eventEmitter childViewControllers:nil];
10 10
 	self.extendedLayoutIncludesOpaqueBars = YES;
11
+    if (@available(iOS 13.0, *)) {
12
+        self.navigationItem.standardAppearance = [UINavigationBarAppearance new];
13
+    }
11 14
 	return self;
12 15
 }
13 16
 

+ 24
- 15
lib/ios/TopBarAppearancePresenter.m Bestand weergeven

@@ -1,20 +1,25 @@
1 1
 #import "TopBarAppearancePresenter.h"
2 2
 #import "RNNFontAttributesCreator.h"
3
+#import "UIViewController+LayoutProtocol.h"
3 4
 
4 5
 @interface TopBarAppearancePresenter ()
5 6
 
6 7
 @end
7 8
 
8 9
 
9
-@implementation TopBarAppearancePresenter {
10
-    UINavigationBarAppearance* _appearance;
10
+@implementation TopBarAppearancePresenter
11
+
12
+- (void)applyOptions:(RNNTopBarOptions *)options {
13
+    [self setTranslucent:[options.background.translucent getWithDefaultValue:NO]];
14
+    [self setBackgroundColor:[options.background.color getWithDefaultValue:nil]];
15
+    [self setTitleAttributes:options.title];
16
+    [self setLargeTitleAttributes:options.largeTitle];
17
+    [self showBorder:![options.noBorder getWithDefaultValue:NO]];
18
+    [self setBackButtonOptions:options.backButton];
11 19
 }
12 20
 
13
-- (instancetype)initWithNavigationController:(UINavigationController *)boundNavigationController {
14
-    self = [super initWithNavigationController:boundNavigationController];
15
-    _appearance = boundNavigationController.navigationBar.standardAppearance ?: [UINavigationBarAppearance new];
16
-    boundNavigationController.navigationBar.standardAppearance = _appearance;
17
-    return self;
21
+- (void)applyOptionsBeforePopping:(RNNTopBarOptions *)options {
22
+    [self setBackgroundColor:[options.background.color getWithDefaultValue:nil]];
18 23
 }
19 24
 
20 25
 - (void)setTranslucent:(BOOL)translucent {
@@ -28,23 +33,23 @@
28 33
 
29 34
 - (void)updateBackgroundAppearance {
30 35
     if (self.transparent) {
31
-        [_appearance configureWithTransparentBackground];
36
+        [self.getAppearance configureWithTransparentBackground];
32 37
     } else if (self.backgroundColor) {
33
-        [_appearance setBackgroundColor:self.backgroundColor];
38
+        [self.getAppearance setBackgroundColor:self.backgroundColor];
34 39
     } else if (self.translucent) {
35
-        [_appearance configureWithDefaultBackground];
40
+        [self.getAppearance configureWithDefaultBackground];
36 41
     } else {
37
-        [_appearance configureWithOpaqueBackground];
42
+        [self.getAppearance configureWithOpaqueBackground];
38 43
     }
39 44
 }
40 45
 
41 46
 - (void)showBorder:(BOOL)showBorder {
42 47
     UIColor* shadowColor = showBorder ? [[UINavigationBarAppearance new] shadowColor] : nil;
43
-    _appearance.shadowColor = shadowColor;
48
+    self.getAppearance.shadowColor = shadowColor;
44 49
 }
45 50
 
46 51
 - (void)setBackIndicatorImage:(UIImage *)image withColor:(UIColor *)color {
47
-    [_appearance setBackIndicatorImage:image transitionMaskImage:image];
52
+    [self.getAppearance setBackIndicatorImage:image transitionMaskImage:image];
48 53
 }
49 54
 
50 55
 - (void)setTitleAttributes:(RNNTitleOptions *)titleOptions {
@@ -53,7 +58,7 @@
53 58
     NSNumber* fontSize = [titleOptions.fontSize getWithDefaultValue:nil];
54 59
     UIColor* fontColor = [titleOptions.color getWithDefaultValue:nil];
55 60
     
56
-    _appearance.titleTextAttributes = [RNNFontAttributesCreator createFromDictionary:_appearance.titleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:fontColor defaultColor:nil];
61
+    self.getAppearance.titleTextAttributes = [RNNFontAttributesCreator createFromDictionary:self.getAppearance.titleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:fontColor defaultColor:nil];
57 62
 }
58 63
 
59 64
 - (void)setLargeTitleAttributes:(RNNLargeTitleOptions *)largeTitleOptions {
@@ -62,7 +67,11 @@
62 67
     NSNumber* fontSize = [largeTitleOptions.fontSize getWithDefaultValue:nil];
63 68
     UIColor* fontColor = [largeTitleOptions.color getWithDefaultValue:nil];
64 69
     
65
-    _appearance.largeTitleTextAttributes = [RNNFontAttributesCreator createFromDictionary:_appearance.largeTitleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:fontColor defaultColor:nil];
70
+    self.getAppearance.largeTitleTextAttributes = [RNNFontAttributesCreator createFromDictionary:self.getAppearance.largeTitleTextAttributes fontFamily:fontFamily fontSize:fontSize defaultFontSize:nil fontWeight:fontWeight color:fontColor defaultColor:nil];
71
+}
72
+
73
+- (UINavigationBarAppearance *)getAppearance {
74
+    return self.currentNavigationItem.standardAppearance;
66 75
 }
67 76
 
68 77
 @end

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

@@ -13,6 +13,8 @@
13 13
 
14 14
 - (BOOL)transparent;
15 15
 
16
+- (void)setBackButtonOptions:(RNNBackButtonOptions *)backButtonOptions;
17
+
16 18
 @property (nonatomic) BOOL translucent;
17 19
 @property (nonatomic, strong) UIColor* backgroundColor;
18 20
 

+ 18
- 18
playground/ios/NavigationTests/RNNRootViewControllerTest.m Bestand weergeven

@@ -60,7 +60,7 @@
60 60
 	[self.uut viewWillAppear:false];
61 61
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
62 62
 
63
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.backgroundColor isEqual:expectedColor]);
63
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.backgroundColor isEqual:expectedColor]);
64 64
 }
65 65
 
66 66
 - (void)testTopBarBackgroundColorWithoutNavigationController {
@@ -127,7 +127,7 @@
127 127
 	__unused RNNStackController* nav = [self createNavigationController];
128 128
 	[self.uut viewWillAppear:false];
129 129
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
130
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
130
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
131 131
 }
132 132
 
133 133
 - (void)testBackgroundColor_validColor {
@@ -149,7 +149,7 @@
149 149
 	self.options.topBar.title.fontFamily = [[Text alloc] initWithValue:inputFont];
150 150
 	[self.uut viewWillAppear:false];
151 151
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:17];
152
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
152
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
153 153
 }
154 154
 
155 155
 - (void)testTopBarHideOnScroll_true {
@@ -165,8 +165,8 @@
165 165
 	self.options.topBar.background.translucent = [[Bool alloc] initWithValue:topBarTranslucentInput];
166 166
 	__unused RNNStackController* nav = [self createNavigationController];
167 167
 	[self.uut viewWillAppear:false];
168
-	XCTAssertTrue(CGColorEqualToColor(self.uut.navigationController.navigationBar.standardAppearance.shadowColor.CGColor, [UINavigationBarAppearance new].shadowColor.CGColor));
169
-	XCTAssertTrue(CGColorEqualToColor(self.uut.navigationController.navigationBar.standardAppearance.backgroundColor.CGColor, UIColor.systemBackgroundColor.CGColor));
168
+	XCTAssertTrue(CGColorEqualToColor(self.uut.navigationItem.standardAppearance.shadowColor.CGColor, [UINavigationBarAppearance new].shadowColor.CGColor));
169
+	XCTAssertTrue(CGColorEqualToColor(self.uut.navigationItem.standardAppearance.backgroundColor.CGColor, UIColor.systemBackgroundColor.CGColor));
170 170
 }
171 171
 
172 172
 - (void)testTopBarTransparent {
@@ -218,7 +218,7 @@
218 218
 	UIFont* initialFont = self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"];
219 219
 	[self.uut viewWillAppear:false];
220 220
 	UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue];
221
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
221
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
222 222
 }
223 223
 
224 224
 - (void)testTopBarLargeTitleFontSize_withoutTextFontFamily_withTextColor {
@@ -231,8 +231,8 @@
231 231
 	[self.uut viewWillAppear:false];
232 232
 	UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue];
233 233
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
234
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
235
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
234
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
235
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
236 236
 }
237 237
 
238 238
 - (void)testTopBarLargeTitleFontSize_withTextFontFamily_withTextColor {
@@ -247,8 +247,8 @@
247 247
 	[self.uut viewWillAppear:false];
248 248
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
249 249
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
250
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
251
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
250
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
251
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSColor"] isEqual:expectedColor]);
252 252
 }
253 253
 
254 254
 - (void)testTopBarLargeTitleFontSize_withTextFontFamily_withoutTextColor {
@@ -259,7 +259,7 @@
259 259
 	__unused RNNStackController* nav = [self createNavigationController];
260 260
 	[self.uut viewWillAppear:false];
261 261
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
262
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
262
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.largeTitleTextAttributes[@"NSFont"] isEqual:expectedFont]);
263 263
 }
264 264
 
265 265
 
@@ -270,7 +270,7 @@
270 270
 	UIFont* initialFont = self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"];
271 271
 	[self.uut viewWillAppear:false];
272 272
 	UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue];
273
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
273
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
274 274
 }
275 275
 
276 276
 - (void)testTopBarTextFontSize_withoutTextFontFamily_withTextColor {
@@ -283,8 +283,8 @@
283 283
 	[self.uut viewWillAppear:false];
284 284
 	UIFont* expectedFont = [UIFont fontWithDescriptor:initialFont.fontDescriptor size:topBarTextFontSizeInput.floatValue];
285 285
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
286
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
287
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
286
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
287
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
288 288
 }
289 289
 
290 290
 - (void)testTopBarTextFontSize_withTextFontFamily_withTextColor {
@@ -298,8 +298,8 @@
298 298
 	[self.uut viewWillAppear:false];
299 299
 	UIColor* expectedColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:1];
300 300
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
301
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
302
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
301
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
302
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSColor"] isEqual:expectedColor]);
303 303
 }
304 304
 
305 305
 - (void)testTopBarTextFontSize_withTextFontFamily_withoutTextColor {
@@ -310,7 +310,7 @@
310 310
 	__unused RNNStackController* nav = [self createNavigationController];
311 311
 	[self.uut viewWillAppear:false];
312 312
 	UIFont* expectedFont = [UIFont fontWithName:inputFont size:15];
313
-	XCTAssertTrue([self.uut.navigationController.navigationBar.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
313
+	XCTAssertTrue([self.uut.navigationItem.standardAppearance.titleTextAttributes[@"NSFont"] isEqual:expectedFont]);
314 314
 }
315 315
 
316 316
 // TODO: Currently not passing
@@ -468,7 +468,7 @@
468 468
 	self.options.topBar.noBorder = [[Bool alloc] initWithValue:topBarNoBorderInput];
469 469
 	__unused RNNStackController* nav = [self createNavigationController];
470 470
 	[self.uut viewWillAppear:false];
471
-	XCTAssertNil(self.uut.navigationController.navigationBar.standardAppearance.shadowColor);
471
+	XCTAssertNil(self.uut.navigationItem.standardAppearance.shadowColor);
472 472
 }
473 473
 
474 474
 - (void)testTopBarNoBorderOff {

+ 2
- 1
playground/ios/NavigationTests/RNNStackControllerTest.m Bestand weergeven

@@ -137,7 +137,8 @@
137 137
 	[_vc1 overrideOptions:_options];
138 138
 	
139 139
 	[self.uut popViewControllerAnimated:NO];
140
-	XCTAssertEqual(_vc1.resolveOptions.topBar.background.color.get, self.uut.navigationBar.standardAppearance.backgroundColor);
140
+	[_vc1 viewWillAppear:YES];
141
+	XCTAssertEqual(_vc1.resolveOptions.topBar.background.color.get, self.uut.childViewControllers.lastObject.navigationItem.standardAppearance.backgroundColor);
141 142
 }
142 143
 
143 144
 - (void)testPopViewControllerSetDefaultTopBarBackgroundForPoppingViewController {

+ 5
- 4
playground/ios/NavigationTests/RNNStackPresenterTest.m Bestand weergeven

@@ -1,9 +1,10 @@
1 1
 #import <XCTest/XCTest.h>
2 2
 #import <OCMock/OCMock.h>
3
-#import "RNNStackPresenter.h"
3
+#import <ReactNativeNavigation/RNNStackPresenter.h>
4 4
 #import "UINavigationController+RNNOptions.h"
5 5
 #import "RNNStackController.h"
6 6
 #import "UIImage+Utils.h"
7
+#import "RNNComponentViewController+Utils.h"
7 8
 
8 9
 @interface RNNStackPresenterTest : XCTestCase
9 10
 
@@ -18,7 +19,7 @@
18 19
 - (void)setUp {
19 20
 	[super setUp];
20 21
 	self.uut = [[RNNStackPresenter alloc] init];
21
-	RNNStackController* stackController = [[RNNStackController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:self.uut eventEmitter:nil childViewControllers:@[[UIViewController new], [UIViewController new]]];
22
+	RNNStackController* stackController = [[RNNStackController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:self.uut eventEmitter:nil childViewControllers:@[[RNNComponentViewController createWithComponentId:@"component1"], [RNNComponentViewController createWithComponentId:@"component2"]]];
22 23
 	self.boundViewController = [OCMockObject partialMockForObject:stackController];
23 24
     [self.uut bindViewController:self.boundViewController];
24 25
 	self.options = [[RNNNavigationOptions alloc] initEmptyOptions];
@@ -41,7 +42,7 @@
41 42
 	_options.topBar.background.color = [[Color alloc] initWithValue:[UIColor redColor]];
42 43
 	
43 44
 	[self.uut applyOptionsBeforePopping:self.options];
44
-	XCTAssertTrue([_boundViewController.navigationBar.standardAppearance.backgroundColor isEqual:[UIColor redColor]]);
45
+	XCTAssertTrue([_boundViewController.childViewControllers.lastObject.navigationItem.standardAppearance.backgroundColor isEqual:[UIColor redColor]]);
45 46
 }
46 47
 
47 48
 - (void)testApplyOptionsShouldSetLargeTitleVisible {
@@ -98,7 +99,7 @@
98 99
 	self.options.topBar.backButton.icon = icon;
99 100
 	[self.uut applyOptions:self.options];
100 101
 	XCTAssertEqual(self.boundViewController.viewControllers.firstObject.navigationItem.backBarButtonItem.tintColor, UIColor.redColor);
101
-	XCTAssertTrue([self.boundViewController.navigationBar.standardAppearance.backIndicatorImage isEqual:image]);
102
+	XCTAssertTrue([self.boundViewController.viewControllers.lastObject.navigationItem.standardAppearance.backIndicatorImage isEqual:image]);
102 103
 }
103 104
 
104 105
 - (void)testBackgroundColor_validColor {

+ 4
- 3
playground/ios/NavigationTests/TopBarAppearancePresenterTest.m Bestand weergeven

@@ -4,6 +4,7 @@
4 4
 #import "UIViewController+RNNOptions.h"
5 5
 #import <ReactNativeNavigation/RNNStackController.h>
6 6
 #import <ReactNativeNavigation/RNNComponentViewController.h>
7
+#import "RNNComponentViewController+Utils.h"
7 8
 
8 9
 @interface TopBarAppearancePresenterTest : XCTestCase
9 10
 
@@ -17,7 +18,7 @@
17 18
 
18 19
 - (void)setUp {
19 20
     [super setUp];
20
-	_componentViewController = [[RNNComponentViewController alloc] initWithLayoutInfo:nil rootViewCreator:nil eventEmitter:nil presenter:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil];
21
+	_componentViewController = [RNNComponentViewController createWithComponentId:@"componentId"];
21 22
 	_stack = [[RNNStackController alloc] initWithLayoutInfo:nil creator:nil options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:[[RNNNavigationOptions alloc] initEmptyOptions] presenter:_uut eventEmitter:nil childViewControllers:@[_componentViewController]];
22 23
 	_uut = [[TopBarAppearancePresenter alloc] initWithNavigationController:_stack];
23 24
 }
@@ -30,8 +31,8 @@
30 31
 	mergeOptions.topBar.title.fontSize = [Number withValue:@(21)];
31 32
 	RNNNavigationOptions* withDefault = [mergeOptions withDefault:defaultOptions];
32 33
 	[_uut mergeOptions:mergeOptions.topBar withDefault:withDefault.topBar];
33
-	XCTAssertEqual(_stack.navigationBar.standardAppearance.titleTextAttributes[NSForegroundColorAttributeName], UIColor.redColor);
34
-	UIFont* font = _stack.navigationBar.standardAppearance.titleTextAttributes[NSFontAttributeName];
34
+	XCTAssertEqual(_stack.childViewControllers.lastObject.navigationItem.standardAppearance.titleTextAttributes[NSForegroundColorAttributeName], UIColor.redColor);
35
+	UIFont* font = _stack.childViewControllers.lastObject.navigationItem.standardAppearance.titleTextAttributes[NSFontAttributeName];
35 36
 	XCTAssertEqual(font.pointSize, 21);
36 37
 }
37 38
 

+ 8
- 0
playground/ios/NavigationTests/utils/RNNComponentViewController+Utils.h Bestand weergeven

@@ -0,0 +1,8 @@
1
+#import <ReactNativeNavigation/ReactNativeNavigation.h>
2
+#import <ReactNativeNavigation/RNNComponentViewController.h>
3
+
4
+@interface RNNComponentViewController (Utils)
5
+
6
++ (RNNComponentViewController *)createWithComponentId:(NSString *)componentId;
7
+
8
+@end

+ 11
- 0
playground/ios/NavigationTests/utils/RNNComponentViewController+Utils.m Bestand weergeven

@@ -0,0 +1,11 @@
1
+#import "RNNComponentViewController+Utils.h"
2
+
3
+@implementation RNNComponentViewController (Utils)
4
+
5
++ (RNNComponentViewController *)createWithComponentId:(NSString *)componentId {
6
+	RNNLayoutInfo* layoutInfo = [[RNNLayoutInfo alloc] init];
7
+	layoutInfo.componentId = componentId;
8
+	return [[RNNComponentViewController alloc] initWithLayoutInfo:layoutInfo rootViewCreator:nil eventEmitter:nil presenter:nil options:nil defaultOptions:nil];
9
+}
10
+
11
+@end

+ 6
- 0
playground/ios/playground.xcodeproj/project.pbxproj Bestand weergeven

@@ -19,6 +19,7 @@
19 19
 		50996C6823AA477400008F89 /* RNNRootViewControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 50996C6723AA477400008F89 /* RNNRootViewControllerTest.m */; };
20 20
 		50996C6923AA487800008F89 /* RNNTestRootViewCreator.m in Sources */ = {isa = PBXBuildFile; fileRef = E58D263D2385888C003F36BA /* RNNTestRootViewCreator.m */; };
21 21
 		50BCB27623F1A2B100D6C8E5 /* TopBarAppearancePresenterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 50BCB27523F1A26600D6C8E5 /* TopBarAppearancePresenterTest.m */; };
22
+		50C9A8D4240FB9D000BD699F /* RNNComponentViewController+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = 50C9A8D3240FB9D000BD699F /* RNNComponentViewController+Utils.m */; };
22 23
 		67C681D42B662A53F29C19DA /* Pods_NavigationIOS12Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEE0B5D45FD34FBABC6586CF /* Pods_NavigationIOS12Tests.framework */; };
23 24
 		9D204F3DC4FBCD81583BF99F /* Pods_playground.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A3340545EAAF11C1F146864 /* Pods_playground.framework */; };
24 25
 		E5046080227748EA00212BD8 /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E504607F227748EA00212BD8 /* JavaScriptCore.framework */; };
@@ -92,6 +93,8 @@
92 93
 		50996C6123AA46DD00008F89 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
93 94
 		50996C6723AA477400008F89 /* RNNRootViewControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNRootViewControllerTest.m; sourceTree = "<group>"; };
94 95
 		50BCB27523F1A26600D6C8E5 /* TopBarAppearancePresenterTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TopBarAppearancePresenterTest.m; sourceTree = "<group>"; };
96
+		50C9A8D2240FB9D000BD699F /* RNNComponentViewController+Utils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNNComponentViewController+Utils.h"; sourceTree = "<group>"; };
97
+		50C9A8D3240FB9D000BD699F /* RNNComponentViewController+Utils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "RNNComponentViewController+Utils.m"; sourceTree = "<group>"; };
95 98
 		7F8E255E2E08F6ECE7DF6FE3 /* Pods-playground.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-playground.release.xcconfig"; path = "Target Support Files/Pods-playground/Pods-playground.release.xcconfig"; sourceTree = "<group>"; };
96 99
 		84E32151E3A71C2B7328BCB4 /* Pods_NavigationTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_NavigationTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
97 100
 		B484A10A046B0046B98A76B5 /* Pods-playground.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-playground.debug.xcconfig"; path = "Target Support Files/Pods-playground/Pods-playground.debug.xcconfig"; sourceTree = "<group>"; };
@@ -293,6 +296,8 @@
293 296
 				E58D26302385888B003F36BA /* RNNTestBase.h */,
294 297
 				501C86B7239FE9C400E0B631 /* UIImage+Utils.h */,
295 298
 				501C86B8239FE9C400E0B631 /* UIImage+Utils.m */,
299
+				50C9A8D2240FB9D000BD699F /* RNNComponentViewController+Utils.h */,
300
+				50C9A8D3240FB9D000BD699F /* RNNComponentViewController+Utils.m */,
296 301
 			);
297 302
 			path = utils;
298 303
 			sourceTree = "<group>";
@@ -747,6 +752,7 @@
747 752
 				E58D265B2385888C003F36BA /* UIViewController+RNNOptionsTest.m in Sources */,
748 753
 				E58D26532385888C003F36BA /* RNNSideMenuPresenterTest.m in Sources */,
749 754
 				50BCB27623F1A2B100D6C8E5 /* TopBarAppearancePresenterTest.m in Sources */,
755
+				50C9A8D4240FB9D000BD699F /* RNNComponentViewController+Utils.m in Sources */,
750 756
 				50647FE323E3196800B92025 /* RNNExternalViewControllerTests.m in Sources */,
751 757
 				E58D264D2385888C003F36BA /* RNNOverlayManagerTest.m in Sources */,
752 758
 				501C86B9239FE9C400E0B631 /* UIImage+Utils.m in Sources */,