Pārlūkot izejas kodu

sideMenu.width should be initialized on viewController init (#4268)

Yogev Ben David 5 gadus atpakaļ
vecāks
revīzija
643233c9e2
No account linked to committer's email address

+ 2
- 0
lib/ios/RNNSideMenuController.m Parādīt failu

@@ -28,6 +28,8 @@
28 28
 	self.openDrawerGestureModeMask = MMOpenDrawerGestureModeAll;
29 29
 	self.closeDrawerGestureModeMask = MMCloseDrawerGestureModeAll;
30 30
 	
31
+	[self.presenter applyOptionsOnInit:self.resolveOptions];
32
+	
31 33
 	// Fixes #3697
32 34
 	[self setExtendedLayoutIncludesOpaqueBars:YES];
33 35
 	self.edgesForExtendedLayout |= UIRectEdgeBottom;

+ 9
- 4
lib/ios/RNNSideMenuPresenter.m Parādīt failu

@@ -18,13 +18,18 @@
18 18
 	[sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
19 19
 	
20 20
 	[sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:nil]];
21
+}
21 22
 
22
-	if (options.sideMenu.left.width.hasValue) {
23
-		[sideMenuController side:MMDrawerSideLeft width:options.sideMenu.left.width.get];
23
+- (void)applyOptionsOnInit:(RNNNavigationOptions *)initialOptions {
24
+	[super applyOptionsOnInit:initialOptions];
25
+	
26
+	RNNSideMenuController* sideMenuController = self.bindedViewController;
27
+	if (initialOptions.sideMenu.left.width.hasValue) {
28
+		[sideMenuController side:MMDrawerSideLeft width:initialOptions.sideMenu.left.width.get];
24 29
 	}
25 30
 	
26
-	if (options.sideMenu.right.width.hasValue) {
27
-		[sideMenuController side:MMDrawerSideRight width:options.sideMenu.right.width.get];
31
+	if (initialOptions.sideMenu.right.width.hasValue) {
32
+		[sideMenuController side:MMDrawerSideRight width:initialOptions.sideMenu.right.width.get];
28 33
 	}
29 34
 }
30 35
 

+ 12
- 3
lib/ios/ReactNativeNavigationTests/RNNSideMenuPresenterTest.m Parādīt failu

@@ -44,8 +44,6 @@
44 44
 	self.options.sideMenu.right.shouldStretchDrawer = [[Bool alloc] initWithBOOL:NO];
45 45
 	self.options.sideMenu.right.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
46 46
 	self.options.sideMenu.left.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
47
-	self.options.sideMenu.right.width = [[Double alloc] initWithValue:@(100.0f)];
48
-	self.options.sideMenu.left.width = [[Double alloc] initWithValue:@(100.0f)];
49 47
 	
50 48
 	[[self.bindedViewController expect] side:MMDrawerSideLeft enabled:NO];
51 49
 	[[self.bindedViewController expect] side:MMDrawerSideRight enabled:NO];
@@ -53,13 +51,24 @@
53 51
 	[[self.bindedViewController expect] setShouldStretchRightDrawer:NO];
54 52
 	[[self.bindedViewController expect] setAnimationVelocityLeft:100.0f];
55 53
 	[[self.bindedViewController expect] setAnimationVelocityRight:100.0f];
54
+	
55
+	[self.uut applyOptions:self.options];
56
+	
57
+	[self.bindedViewController verify];
58
+}
59
+
60
+- (void)testApplyOptionsOnInitShouldSetWidthOptions {
61
+	self.options.sideMenu.right.width = [[Double alloc] initWithValue:@(100.0f)];
62
+	self.options.sideMenu.left.width = [[Double alloc] initWithValue:@(100.0f)];
63
+
56 64
 	[[self.bindedViewController expect] side:MMDrawerSideLeft width:100.0f];
57 65
 	[[self.bindedViewController expect] side:MMDrawerSideRight width:100.0f];
58 66
 	
59
-	[self.uut applyOptions:self.options];
67
+	[self.uut applyOptionsOnInit:self.options];
60 68
 	
61 69
 	[self.bindedViewController verify];
62 70
 }
63 71
 
64 72
 
73
+
65 74
 @end