ソースを参照

Fix sideMenu intuitive side width - #4527 (#4528)

Yogev Ben David 5 年 前
コミット
07cc9d3f62
No account linked to committer's email address

+ 2
- 0
lib/ios/RNNSideMenuChildVC.h ファイルの表示

20
 
20
 
21
 - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter type:(RNNSideMenuChildType)type;
21
 - (instancetype)initWithLayoutInfo:(RNNLayoutInfo *)layoutInfo childViewControllers:(NSArray *)childViewControllers options:(RNNNavigationOptions *)options defaultOptions:(RNNNavigationOptions *)defaultOptions presenter:(RNNViewControllerPresenter *)presenter type:(RNNSideMenuChildType)type;
22
 
22
 
23
+- (void)setWidth:(CGFloat)width;
24
+
23
 @end
25
 @end

+ 6
- 0
lib/ios/RNNSideMenuChildVC.m ファイルの表示

60
 	[self.view bringSubviewToFront:self.child.view];
60
 	[self.view bringSubviewToFront:self.child.view];
61
 }
61
 }
62
 
62
 
63
+- (void)setWidth:(CGFloat)width {
64
+	CGRect frame = self.child.view.frame;
65
+	frame.size.width = width;
66
+	self.child.view.frame = frame;
67
+}
68
+
63
 - (UIViewController *)getCurrentChild {
69
 - (UIViewController *)getCurrentChild {
64
 	return self.child;
70
 	return self.child;
65
 }
71
 }

+ 2
- 0
lib/ios/RNNSideMenuController.m ファイルの表示

76
 	switch (side) {
76
 	switch (side) {
77
 		case MMDrawerSideRight:
77
 		case MMDrawerSideRight:
78
 			self.maximumRightDrawerWidth = width;
78
 			self.maximumRightDrawerWidth = width;
79
+			[self.right setWidth:width];
79
 			break;
80
 			break;
80
 		case MMDrawerSideLeft:
81
 		case MMDrawerSideLeft:
81
 			self.maximumLeftDrawerWidth = width;
82
 			self.maximumLeftDrawerWidth = width;
83
+			[self.left setWidth:width];
82
 		default:
84
 		default:
83
 			break;
85
 			break;
84
 	}
86
 	}

+ 4
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj ファイルの表示

204
 		507F43F81FF525B500D9425B /* RNNSegmentedControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 507F43F61FF525B500D9425B /* RNNSegmentedControl.h */; };
204
 		507F43F81FF525B500D9425B /* RNNSegmentedControl.h in Headers */ = {isa = PBXBuildFile; fileRef = 507F43F61FF525B500D9425B /* RNNSegmentedControl.h */; };
205
 		507F43F91FF525B500D9425B /* RNNSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 507F43F71FF525B500D9425B /* RNNSegmentedControl.m */; };
205
 		507F43F91FF525B500D9425B /* RNNSegmentedControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 507F43F71FF525B500D9425B /* RNNSegmentedControl.m */; };
206
 		507F44201FFA8A8800D9425B /* RNNParentProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 507F441F1FFA8A8800D9425B /* RNNParentProtocol.h */; };
206
 		507F44201FFA8A8800D9425B /* RNNParentProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 507F441F1FFA8A8800D9425B /* RNNParentProtocol.h */; };
207
+		5085DD2D21DCF75A0032E64B /* RNNSideMenuControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5085DD2C21DCF75A0032E64B /* RNNSideMenuControllerTest.m */; };
207
 		50887C1520ECC5C200D06111 /* RNNButtonOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50887C1320ECC5C200D06111 /* RNNButtonOptions.h */; };
208
 		50887C1520ECC5C200D06111 /* RNNButtonOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 50887C1320ECC5C200D06111 /* RNNButtonOptions.h */; };
208
 		50887C1620ECC5C200D06111 /* RNNButtonOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887C1420ECC5C200D06111 /* RNNButtonOptions.m */; };
209
 		50887C1620ECC5C200D06111 /* RNNButtonOptions.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887C1420ECC5C200D06111 /* RNNButtonOptions.m */; };
209
 		50887CA920F26BFE00D06111 /* RNNOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */; };
210
 		50887CA920F26BFE00D06111 /* RNNOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */; };
526
 		507F43F61FF525B500D9425B /* RNNSegmentedControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNSegmentedControl.h; sourceTree = "<group>"; };
527
 		507F43F61FF525B500D9425B /* RNNSegmentedControl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNSegmentedControl.h; sourceTree = "<group>"; };
527
 		507F43F71FF525B500D9425B /* RNNSegmentedControl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSegmentedControl.m; sourceTree = "<group>"; };
528
 		507F43F71FF525B500D9425B /* RNNSegmentedControl.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSegmentedControl.m; sourceTree = "<group>"; };
528
 		507F441F1FFA8A8800D9425B /* RNNParentProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNParentProtocol.h; sourceTree = "<group>"; };
529
 		507F441F1FFA8A8800D9425B /* RNNParentProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNNParentProtocol.h; sourceTree = "<group>"; };
530
+		5085DD2C21DCF75A0032E64B /* RNNSideMenuControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNSideMenuControllerTest.m; sourceTree = "<group>"; };
529
 		50887C1320ECC5C200D06111 /* RNNButtonOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNButtonOptions.h; sourceTree = "<group>"; };
531
 		50887C1320ECC5C200D06111 /* RNNButtonOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RNNButtonOptions.h; sourceTree = "<group>"; };
530
 		50887C1420ECC5C200D06111 /* RNNButtonOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNButtonOptions.m; sourceTree = "<group>"; };
532
 		50887C1420ECC5C200D06111 /* RNNButtonOptions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = RNNButtonOptions.m; sourceTree = "<group>"; };
531
 		50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayWindow.m; sourceTree = "<group>"; };
533
 		50887CA720F26BFD00D06111 /* RNNOverlayWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNNOverlayWindow.m; sourceTree = "<group>"; };
1017
 				509B258E2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m */,
1019
 				509B258E2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m */,
1018
 				502F0E172179C39900367CC3 /* RNNTabBarPresenterTest.m */,
1020
 				502F0E172179C39900367CC3 /* RNNTabBarPresenterTest.m */,
1019
 				50CE8502217C6C9B00084EBF /* RNNSideMenuPresenterTest.m */,
1021
 				50CE8502217C6C9B00084EBF /* RNNSideMenuPresenterTest.m */,
1022
+				5085DD2C21DCF75A0032E64B /* RNNSideMenuControllerTest.m */,
1020
 				50206A6C21AFE75400B7BB1A /* RNNSideMenuParserTest.m */,
1023
 				50206A6C21AFE75400B7BB1A /* RNNSideMenuParserTest.m */,
1021
 				502F0E152178D09600367CC3 /* RNNBasePresenterTest.m */,
1024
 				502F0E152178D09600367CC3 /* RNNBasePresenterTest.m */,
1022
 				5038A378216D01F6009280BC /* RNNBottomTabOptionsTest.m */,
1025
 				5038A378216D01F6009280BC /* RNNBottomTabOptionsTest.m */,
1398
 				50206A6D21AFE75400B7BB1A /* RNNSideMenuParserTest.m in Sources */,
1401
 				50206A6D21AFE75400B7BB1A /* RNNSideMenuParserTest.m in Sources */,
1399
 				509B258F2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m in Sources */,
1402
 				509B258F2178BE7A00C83C23 /* RNNNavigationControllerPresenterTest.m in Sources */,
1400
 				7B49FECD1E95098500DEB3EA /* RNNModalManagerTest.m in Sources */,
1403
 				7B49FECD1E95098500DEB3EA /* RNNModalManagerTest.m in Sources */,
1404
+				5085DD2D21DCF75A0032E64B /* RNNSideMenuControllerTest.m in Sources */,
1401
 				E83BAD791F27416B00A9F3DD /* RNNRootViewControllerTest.m in Sources */,
1405
 				E83BAD791F27416B00A9F3DD /* RNNRootViewControllerTest.m in Sources */,
1402
 				50CE8503217C6C9B00084EBF /* RNNSideMenuPresenterTest.m in Sources */,
1406
 				50CE8503217C6C9B00084EBF /* RNNSideMenuPresenterTest.m in Sources */,
1403
 				E8DA243D1F973C1900CD552B /* RNNTransitionStateHolderTest.m in Sources */,
1407
 				E8DA243D1F973C1900CD552B /* RNNTransitionStateHolderTest.m in Sources */,

+ 32
- 0
lib/ios/ReactNativeNavigationTests/RNNSideMenuControllerTest.m ファイルの表示

1
+#import <XCTest/XCTest.h>
2
+#import "RNNSideMenuController.h"
3
+#import "RNNRootViewController.h"
4
+
5
+@interface RNNSideMenuControllerTest : XCTestCase
6
+@property (nonatomic, strong) RNNSideMenuController *uut;
7
+@property (nonatomic, strong) RNNSideMenuChildVC *centerVC;
8
+@property (nonatomic, strong) RNNSideMenuChildVC *leftVC;
9
+@property (nonatomic, strong) RNNSideMenuChildVC *rightVC;
10
+@end
11
+
12
+@implementation RNNSideMenuControllerTest
13
+
14
+- (void)setUp {
15
+    [super setUp];
16
+	_leftVC = [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil childViewControllers:@[[RNNRootViewController new]] options:nil defaultOptions:nil presenter:nil type:RNNSideMenuChildTypeLeft];
17
+	_rightVC = [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil childViewControllers:@[[RNNRootViewController new]] options:nil defaultOptions:nil presenter:nil type:RNNSideMenuChildTypeRight];
18
+	_centerVC = [[RNNSideMenuChildVC alloc] initWithLayoutInfo:nil childViewControllers:@[[RNNRootViewController new]] options:nil defaultOptions:nil presenter:nil type:RNNSideMenuChildTypeCenter];
19
+	self.uut = [[RNNSideMenuController alloc] initWithLayoutInfo:nil childViewControllers:@[_leftVC, _centerVC, _rightVC] options:[[RNNNavigationOptions alloc] initEmptyOptions] defaultOptions:nil presenter:nil];
20
+}
21
+
22
+- (void)testSetSideMenuWidthShouldUpdateLeftReactViewFrameWidth {
23
+	[self.uut side:MMDrawerSideLeft width:100];
24
+	XCTAssertEqual(self.uut.left.child.view.frame.size.width, 100.f);
25
+}
26
+
27
+- (void)testSetSideMenuWidthShouldUpdateRightReactViewFrameWidth {
28
+	[self.uut side:MMDrawerSideRight width:150];
29
+	XCTAssertEqual(self.uut.right.child.view.frame.size.width, 150.f);
30
+}
31
+
32
+@end

+ 0
- 3
lib/ios/ReactNativeNavigationTests/RNNSideMenuPresenterTest.m ファイルの表示

82
 	[self.bindedViewController verify];
82
 	[self.bindedViewController verify];
83
 }
83
 }
84
 
84
 
85
-
86
-
87
-
88
 @end
85
 @end