-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathALNavigationCoordinatorViewModel.h
More file actions
183 lines (138 loc) · 6.54 KB
/
ALNavigationCoordinatorViewModel.h
File metadata and controls
183 lines (138 loc) · 6.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
//
// ALNavigationCoordinatorViewModel.h
// ALButtonMenu
//
// Copyright © 2016 Anthony Lobianco. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, ALNavigationCoordinatorAnimation)
{
// no animation
ALNavigationCoordinatorAnimationNone = 0,
// the nav controller will expand away from the button's center when showing the menu and
// contract towards the button's center when hiding the menu.
//
ALNavigationCoordinatorAnimationOrigin,
};
typedef NS_OPTIONS(NSInteger, ALNavigationCoordinatorSnapLocation)
{
// none
ALNavigationCoordinatorSnapLocationNone = 0,
// individual positions
ALNavigationCoordinatorSnapLocationTopLeft = (1UL << 0),
ALNavigationCoordinatorSnapLocationTop = (1UL << 1),
ALNavigationCoordinatorSnapLocationTopRight = (1UL << 2),
ALNavigationCoordinatorSnapLocationRight = (1UL << 3),
ALNavigationCoordinatorSnapLocationBottomRight = (1UL << 4),
ALNavigationCoordinatorSnapLocationBottom = (1UL << 5),
ALNavigationCoordinatorSnapLocationBottomLeft = (1UL << 6),
ALNavigationCoordinatorSnapLocationLeft = (1UL << 7),
ALNavigationCoordinatorSnapLocationMiddle = (1UL << 8),
// edges
ALNavigationCoordinatorSnapLocationAllTop = (ALNavigationCoordinatorSnapLocationTopLeft
| ALNavigationCoordinatorSnapLocationTop
| ALNavigationCoordinatorSnapLocationTopRight),
ALNavigationCoordinatorSnapLocationAllRight = (ALNavigationCoordinatorSnapLocationTopRight
| ALNavigationCoordinatorSnapLocationRight
| ALNavigationCoordinatorSnapLocationBottomRight),
ALNavigationCoordinatorSnapLocationAllBottom = (ALNavigationCoordinatorSnapLocationBottomRight
| ALNavigationCoordinatorSnapLocationBottom
| ALNavigationCoordinatorSnapLocationBottomLeft),
ALNavigationCoordinatorSnapLocationAllLeft = (ALNavigationCoordinatorSnapLocationBottomLeft
| ALNavigationCoordinatorSnapLocationLeft
| ALNavigationCoordinatorSnapLocationTopLeft),
// corners
ALNavigationCoordinatorSnapLocationCorners = (ALNavigationCoordinatorSnapLocationTopLeft
| ALNavigationCoordinatorSnapLocationTopRight
| ALNavigationCoordinatorSnapLocationBottomRight
| ALNavigationCoordinatorSnapLocationBottomLeft),
// all
ALNavigationCoordinatorSnapLocationAll = (ALNavigationCoordinatorSnapLocationTopLeft
| ALNavigationCoordinatorSnapLocationTop
| ALNavigationCoordinatorSnapLocationTopRight
| ALNavigationCoordinatorSnapLocationRight
| ALNavigationCoordinatorSnapLocationBottomRight
| ALNavigationCoordinatorSnapLocationBottom
| ALNavigationCoordinatorSnapLocationBottomLeft
| ALNavigationCoordinatorSnapLocationLeft
| ALNavigationCoordinatorSnapLocationMiddle)
};
@protocol ALNavigationCoordinatorViewModelDataSource <NSObject>
/**
Data source method to use in conjunction with ALNavigationCoordinatorModeReplace.
@param index The index of the button that was tapped.
@return The view controller that corresponds with that index. It will be set as the new root controller.
*/
- (UIViewController *)viewControllerForItemAtIndex:(NSUInteger)index;
@end
@interface ALNavigationCoordinatorViewModel : NSObject
/**
The animation type for presenting the root controller when the menu is dismissed.
Default is ALNavigationCoordinatorAnimationOrigin.
*/
@property (nonatomic) ALNavigationCoordinatorAnimation rootControllerAppearingAnimation;
/**
The animation type for dismissing the root controller when the menu is presented.
Default is ALNavigationCoordinatorAnimationOrigin.
*/
@property (nonatomic) ALNavigationCoordinatorAnimation rootControllerDisappearingAnimation;
/**
The menu button's color when the menu is shown.
Default is a pale white color.
*/
@property (nonatomic) UIColor *buttonActiveColor;
/**
If YES, the menu button can be repositioned via long press. See snappingLocations below.
Default is NO.
*/
@property (nonatomic) BOOL buttonCanBeRepositioned;
/**
The menu button's color when the menu is not shown.
Default is a dark grey color.
*/
@property (nonatomic) UIColor *buttonDefaultColor;
/**
A bezier path can be specified to give the menu button a custom shape. It will be scaled down to
proportionally fit inside the button.
Default is a circle path.
*/
@property (nullable, nonatomic) UIBezierPath *buttonPath;
/**
Show a drop shadow while menu button is being dragged around (if buttonCanBeRepositioned is YES).
Default is YES.
*/
@property (nonatomic) BOOL buttonShouldShowShadowDuringReposition;
/**
The button's size.
Default is { 50.f, 50.f }.
*/
@property (nonatomic) CGSize buttonSize;
/**
The number of points outside the button's bounds that will still register as a touch on the button.
Default is 10.f.
*/
@property (nonatomic) CGFloat buttonTouchArea;
/**
The data source that will provide view controller information in conjunction with ALNavigationCoordinatorModeNotify.
*/
@property (nullable, nonatomic, weak) id<ALNavigationCoordinatorViewModelDataSource> dataSource;
/**
The snap location that the button will initially begin at. If value is ALNavigationCoordinatorSnapLocationNone,
the menu button's default position will be { x = snapPadding, y = snapPadding }.
Default is ALNavigationCoordinatorSnapLocationBottomLeft.
*/
@property (nonatomic) ALNavigationCoordinatorSnapLocation initialSnapLocation;
/**
The individual locations that the menu button will snap to if buttonCanBeRepositioned is YES.
Default is ALNavigationCoordinatorSnapLocationCorners.
*/
@property (nonatomic) ALNavigationCoordinatorSnapLocation snapLocations;
/**
The padding from the edge of the screen to the center of the button.
Default is 60.f.
*/
@property (nonatomic) CGFloat snapPadding;
@end
NS_ASSUME_NONNULL_END