-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPWContentViewController.h
More file actions
266 lines (222 loc) · 7.16 KB
/
PWContentViewController.h
File metadata and controls
266 lines (222 loc) · 7.16 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
//
// ProWidgets
//
// 1.0.0
//
// Created by Alan Yip on 18 Jan 2014
// Copyright 2014 Alan Yip. All rights reserved.
//
#import "header.h"
@interface PWContentViewController : UIViewController {
PWWidget *_widget;
BOOL _shouldAutoConfigureStandardButtons;
BOOL _wantsFullscreen;
BOOL _shouldMaximizeContentHeight;
BOOL _requiresKeyboard;
UIBarButtonItem *_closeButtonItem;
UIBarButtonItem *_actionButtonItem;
NSString *_closeButtonText;
NSString *_actionButtonText;
NSMutableDictionary *_eventHandlers;
}
/**
* Indicates whether this content view controller should configure the standard buttons automatically.
*/
@property(nonatomic) BOOL shouldAutoConfigureStandardButtons;
/**
* Indicates whether the widget should maximize the content size for this content view controller regardless of any other settings.
*/
@property(nonatomic) BOOL wantsFullscreen;
/**
* Indicates whether the widget should maximize the content height for this content view controller.
*/
@property(nonatomic) BOOL shouldMaximizeContentHeight;
/**
* Indicates whether the content of this content view controller requires a keyboard. This affects the position of the widget.
*/
@property(nonatomic) BOOL requiresKeyboard;
/**
* The title of this content view controller. This will be shown in the navigation bar.
*/
@property(nonatomic, copy) NSString *title;
/**
* The text shown in the close button.
*/
@property(nonatomic, copy) NSString *closeButtonText;
/**
* The text shown in the action button.
*/
@property(nonatomic, copy) NSString *actionButtonText;
/**
* Retrieve the event name for close event.
*
* @return The event name for close event.
*/
+ (NSString *)closeEventName;
/**
* Retrieve the event name for aciton event.
*
* @return The event name for action event.
*/
+ (NSString *)actionEventName;
/**
* Retrieve the event name for title tapped event.
*
* @return The event name for title tapped event.
*/
+ (NSString *)titleTappedEventName;
/**
* The initializer of content view controller.
* You must not call init directly.
* If you are to subclass this class, [super initForWidget:] method must be called.
*
* @param widget The widget that this content view controller will be pushed to.
*
* @return The content view controller instance.
*/
- (instancetype)initForWidget:(PWWidget *)widget;
- (instancetype)_initForWidget:(PWWidget *)widget; // for subclass
- (void)_setWidget:(PWWidget *)widget;
/**
* Retrieve the widget instance associated with this content view controller.
*
* @return The widget instance.
*/
- (PWWidget *)widget;
/**
* Retrieve the theme instance associated with the widget.
*
* @return The theme instance.
*/
- (PWTheme *)theme;
/**
* Override this method to perform custom tasks when this class is being initialized.
* It is recommended to override this method rather than overriding initForWidget: directly.
* The default implementation does nothing.
*/
- (void)load;
/**
* Load the plist file for this content view controller
*
* @param filename The name of the plist file.
*
* @return Return YES if the plist file is loaded; otherwise, return NO.
*/
- (BOOL)loadPlist:(NSString *)filename;
/**
* To check whether this content view controller is at the top of the navigation stack in the associated widget.
*
* @return Return YES if this content view controller is the top view controller in the navigation stack in the associated widget; otherwise, return NO.
*/
- (BOOL)isTopViewController;
/**
* Notifies the content view controller that the keyboard with the specified height will show.
*
* @param height The height of the keyboard.
*/
- (void)keyboardWillShow:(CGFloat)height;
/**
* Notifies the content view controller that the keyboard will hide.
*/
- (void)keyboardWillHide;
/**
* Override this method to configure the first responder.
* The default implementation of this base class does nothing.
*/
- (void)configureFirstResponder;
/**
* Configure the close button in the navigation item.
*/
- (void)configureCloseButton;
/**
* Configure the action button in the navigation item.
*/
- (void)configureActionButton;
/**
* Configure the back button in the navigation item.
*/
- (void)configureBackButton;
/**
* Configure the standard buttons, including the close, action and back buttons, in the navigation item at once.
*/
- (void)configureStandardButtons;
/**
* Trigger the close event.
* You should register an event handler for close event instead of overriding this method.
*/
- (void)triggerClose;
/**
* Trigger the action event.
* You should register an event handler for action event instead of overriding this method.
*/
- (void)triggerAction;
/**
* Trigger an event with a specified name and object.
*
* @param event The event name.
* @param object The object to be sent to the event handler. This can be nil.
*/
- (void)triggerEvent:(NSString *)event withObject:(id)object;
/**
* Set the event handler for a specified event name.
*
* @param event The event name
* @param target The handler receiver.
* @param selector The handler selector.
*/
- (void)setHandlerForEvent:(NSString *)event target:(id)target selector:(SEL)selector;
/**
* Set the event handler for a specified event name with a block.
*
* @param event The event name.
* @param block The handler block.
*/
- (void)setHandlerForEvent:(NSString *)event block:(void(^)(id))block;
/**
* A shortcut to set the event handler for close event.
*
* @param target The handler receiver.
* @param selector The handler selector.
*/
- (void)setCloseEventHandler:(id)target selector:(SEL)selector;
/**
* A shortcut to set the event handler for close event with a block.
*
* @param block The handler block.
*/
- (void)setCloseEventBlockHandler:(void(^)(id))block;
/**
* A shortcut to set the event handler for action event.
*
* @param target The handler receiver.
* @param selector The handler selector.
*/
- (void)setActionEventHandler:(id)target selector:(SEL)selector;
/**
* A shortcut to set the event handler for action event with a block.
*
* @param block The handler block.
*/
- (void)setActionEventBlockHandler:(void(^)(id))block;
/**
* Override this method to return the preferred content width for this content view controller according to the specified orientation.
*
* @param orientation The current orientation.
*
* @return The content width for this content view controller in the specified orientation.
*/
- (CGFloat)contentWidthForOrientation:(PWWidgetOrientation)orientation;
/**
* Override this method to return the preferred content height for this content view controller according to the specified orientation.
*
* @param orientation The current orientation.
*
* @return The content height for this content view controller in the specified orientation.
*/
- (CGFloat)contentHeightForOrientation:(PWWidgetOrientation)orientation;
- (void)willBePresentedInNavigationController:(UINavigationController *)navigationController;
// this will be called internally
- (void)_willBePresentedInNavigationController:(UINavigationController *)navigationController;
- (void)_presentedInNavigationController:(UINavigationController *)navigationController;
- (void)_dealloc;
@end