Skip to content

Commit 3d4af0f

Browse files
author
Larry Tin
committed
Add fluent interface for GDDPBViewOption
1 parent 1f5ceb8 commit 3d4af0f

3 files changed

Lines changed: 72 additions & 1 deletion

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// Created by Larry Tin on 10/7/16.
3+
//
4+
5+
#import <Foundation/Foundation.h>
6+
#import "GoodowExtrasOption.pbobjc.h"
7+
#import "GoodowBool.pbobjc.h"
8+
9+
@interface GDDPBViewOption (FluentInterface)
10+
11+
- (GDDPBViewOption *(^)(enum GDDPBLaunchMode launchMode))setLaunchMode;
12+
- (GDDPBViewOption *(^)(enum GDDPBStackMode stackMode))setStackMode;
13+
14+
- (GDDPBViewOption *(^)(enum GDPBBool statusBar))setStatusBar;
15+
- (GDDPBViewOption *(^)(enum GDPBBool navBar))setNavBar;
16+
- (GDDPBViewOption *(^)(UIStatusBarStyle statusBarStyle))setStatusBarStyle;
17+
- (GDDPBViewOption *(^)(UIBarStyle navBarStyle))setNavBarStyle;
18+
- (GDDPBViewOption *(^)(BOOL hidesBottomBarWhenPushed))setHidesBottomBarWhenPushed;
19+
- (GDDPBViewOption *(^)(enum GDPBBool tabBar))setTabBar;
20+
- (GDDPBViewOption *(^)(UIInterfaceOrientationMask supportedInterfaceOrientations))setSupportedInterfaceOrientations;
21+
- (GDDPBViewOption *(^)(enum GDPBBool autorotate))setAutorotate;
22+
23+
- (GDDPBViewOption *(^)(BOOL needsRefresh))setNeedsRefresh;
24+
- (GDDPBViewOption *(^)(BOOL attemptRotationToDeviceOrientation))setAttemptRotationToDeviceOrientation;
25+
- (GDDPBViewOption *(^)(UIDeviceOrientation deviceOrientation))setDeviceOrientation;
26+
- (GDDPBViewOption *(^)(enum GDPBBool toolBar))setToolBar;
27+
28+
- (GDDPBViewOption *(^)(UIInterfaceOrientation preferredInterfaceOrientationForPresentation))setPreferredInterfaceOrientationForPresentation;
29+
- (GDDPBViewOption *(^)(UIModalPresentationStyle modalPresentationStyle))setModalPresentationStyle;
30+
- (GDDPBViewOption *(^)(UIModalTransitionStyle modalTransitionStyle))setModalTransitionStyle;
31+
- (GDDPBViewOption *(^)(UIRectEdge edgesForExtendedLayout))setEedgesForExtendedLayout;
32+
@end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//
2+
// Created by Larry Tin on 10/7/16.
3+
//
4+
5+
#import "GDDPBExtrasOption+FluentInterface.h"
6+
7+
#define kImplementMethodChaining(name) \
8+
- (GDDPBViewOption *(^)(int name))set##name { \
9+
return ^GDDPBViewOption *(int name) { \
10+
self.name = name; \
11+
return self; \
12+
}; \
13+
}
14+
15+
@implementation GDDPBViewOption (FluentInterface)
16+
17+
kImplementMethodChaining(LaunchMode);
18+
kImplementMethodChaining(StackMode);
19+
20+
kImplementMethodChaining(StatusBar);
21+
kImplementMethodChaining(NavBar);
22+
kImplementMethodChaining(StatusBarStyle);
23+
kImplementMethodChaining(NavBarStyle);
24+
kImplementMethodChaining(HidesBottomBarWhenPushed);
25+
kImplementMethodChaining(TabBar);
26+
kImplementMethodChaining(SupportedInterfaceOrientations);
27+
kImplementMethodChaining(Autorotate);
28+
29+
kImplementMethodChaining(NeedsRefresh);
30+
kImplementMethodChaining(AttemptRotationToDeviceOrientation);
31+
kImplementMethodChaining(DeviceOrientation);
32+
kImplementMethodChaining(ToolBar);
33+
34+
kImplementMethodChaining(PreferredInterfaceOrientationForPresentation);
35+
kImplementMethodChaining(ModalPresentationStyle);
36+
kImplementMethodChaining(ModalTransitionStyle);
37+
kImplementMethodChaining(EdgesForExtendedLayout);
38+
39+
@end

GDDataDrivenView/protos/goodow_extras_option.proto

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ message ViewOption {
2828
uint32 supported_interface_orientations = 12; // UIInterfaceOrientationMask
2929
goodow.protobuf.Bool autorotate = 13; // 是否应该自动旋转
3030

31-
bool needsRefresh = 21;
31+
bool needs_refresh = 21;
3232
bool attempt_rotation_to_device_orientation = 22;
3333
uint32 device_orientation = 23; // 更改设备的朝向 UIDeviceOrientation
3434
goodow.protobuf.Bool tool_bar = 24;

0 commit comments

Comments
 (0)