Browse Source

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

Yogev Ben David 5 years ago
parent
commit
643233c9e2
No account linked to committer's email address

+ 2
- 0
lib/ios/RNNSideMenuController.m View File

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

+ 9
- 4
lib/ios/RNNSideMenuPresenter.m View File

18
 	[sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
18
 	[sideMenuController setAnimationVelocityRight:[options.sideMenu.right.animationVelocity getWithDefaultValue:840.0f]];
19
 	
19
 	
20
 	[sideMenuController setAnimationType:[options.sideMenu.animationType getWithDefaultValue:nil]];
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 View File

44
 	self.options.sideMenu.right.shouldStretchDrawer = [[Bool alloc] initWithBOOL:NO];
44
 	self.options.sideMenu.right.shouldStretchDrawer = [[Bool alloc] initWithBOOL:NO];
45
 	self.options.sideMenu.right.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
45
 	self.options.sideMenu.right.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
46
 	self.options.sideMenu.left.animationVelocity = [[Double alloc] initWithValue:@(100.0f)];
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
 	[[self.bindedViewController expect] side:MMDrawerSideLeft enabled:NO];
48
 	[[self.bindedViewController expect] side:MMDrawerSideLeft enabled:NO];
51
 	[[self.bindedViewController expect] side:MMDrawerSideRight enabled:NO];
49
 	[[self.bindedViewController expect] side:MMDrawerSideRight enabled:NO];
53
 	[[self.bindedViewController expect] setShouldStretchRightDrawer:NO];
51
 	[[self.bindedViewController expect] setShouldStretchRightDrawer:NO];
54
 	[[self.bindedViewController expect] setAnimationVelocityLeft:100.0f];
52
 	[[self.bindedViewController expect] setAnimationVelocityLeft:100.0f];
55
 	[[self.bindedViewController expect] setAnimationVelocityRight:100.0f];
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
 	[[self.bindedViewController expect] side:MMDrawerSideLeft width:100.0f];
64
 	[[self.bindedViewController expect] side:MMDrawerSideLeft width:100.0f];
57
 	[[self.bindedViewController expect] side:MMDrawerSideRight width:100.0f];
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
 	[self.bindedViewController verify];
69
 	[self.bindedViewController verify];
62
 }
70
 }
63
 
71
 
64
 
72
 
73
+
65
 @end
74
 @end