Quellcode durchsuchen

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

Yogev Ben David vor 5 Jahren
Ursprung
Commit
07cc9d3f62
Es ist kein Benutzerkonto mit dieser Commiter-Email verbunden

+ 2
- 0
lib/ios/RNNSideMenuChildVC.h Datei anzeigen

@@ -20,4 +20,6 @@ typedef NS_ENUM(NSInteger, RNNSideMenuChildType) {
20 20
 
21 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 25
 @end

+ 6
- 0
lib/ios/RNNSideMenuChildVC.m Datei anzeigen

@@ -60,6 +60,12 @@
60 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 69
 - (UIViewController *)getCurrentChild {
64 70
 	return self.child;
65 71
 }

+ 2
- 0
lib/ios/RNNSideMenuController.m Datei anzeigen

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

+ 4
- 0
lib/ios/ReactNativeNavigation.xcodeproj/project.pbxproj Datei anzeigen

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

+ 32
- 0
lib/ios/ReactNativeNavigationTests/RNNSideMenuControllerTest.m Datei anzeigen

@@ -0,0 +1,32 @@
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 Datei anzeigen

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