forked from dogo/SCLAlertView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCLAlertView.h
More file actions
executable file
·373 lines (325 loc) · 13.7 KB
/
Copy pathSCLAlertView.h
File metadata and controls
executable file
·373 lines (325 loc) · 13.7 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
//
// SCLAlertView.h
// SCLAlertView
//
// Created by Diogo Autilio on 9/26/14.
// Copyright (c) 2014 AnyKey Entertainment. All rights reserved.
//
@import UIKit;
#import "SCLButton.h"
typedef NSAttributedString* (^SCLAttributedFormatBlock)(NSString *value);
typedef void (^DismissBlock)(void);
@interface SCLAlertView : UIViewController
/** Alert Styles
*
* Set SCLAlertView Style
*/
typedef NS_ENUM(NSInteger, SCLAlertViewStyle)
{
Success,
Error,
Notice,
Warning,
Info,
Edit,
Waiting,
Custom
};
/** Alert hide animation styles
*
* Set SCLAlertView hide animation type.
*/
typedef NS_ENUM(NSInteger, SCLAlertViewHideAnimation)
{
FadeOut,
SlideOutToBottom,
SlideOutToTop,
SlideOutToLeft,
SlideOutToRight,
SlideOutToCenter,
SlideOutFromCenter
};
/** Alert show animation styles
*
* Set SCLAlertView show animation type.
*/
typedef NS_ENUM(NSInteger, SCLAlertViewShowAnimation)
{
FadeIn,
SlideInFromBottom,
SlideInFromTop,
SlideInFromLeft,
SlideInFromRight,
SlideInFromCenter,
SlideInToCenter
};
/** Alert background styles
*
* Set SCLAlertView background type.
*/
typedef NS_ENUM(NSInteger, SCLAlertViewBackground)
{
Shadow,
Blur,
Transparent
};
/** Title Label
*
* The text displayed as title.
*/
@property UILabel *labelTitle;
/** Text view with the body message
*
* Holds the textview.
*/
@property UITextView *viewText;
/** Activity Indicator
*
* Holds the activityIndicator.
*/
@property UIActivityIndicatorView *activityIndicatorView;
/** Dismiss on tap outside
*
* A boolean value that determines whether to dismiss when tapping outside the SCLAlertView.
* (Default: NO)
*/
@property (nonatomic, assign) BOOL shouldDismissOnTapOutside;
/** Sound URL
*
* Holds the sound NSURL path.
*/
@property (nonatomic, strong) NSURL *soundURL;
/** Set text attributed format block
*
* Holds the attributed string.
*/
@property (nonatomic, copy) SCLAttributedFormatBlock attributedFormatBlock;
/** Set Complete button format block.
*
* Holds the button format block.
* Support keys : backgroundColor, borderWidth, borderColor, textColor
*/
@property (nonatomic, copy) CompleteButtonFormatBlock completeButtonFormatBlock;
/** Set button format block.
*
* Holds the button format block.
* Support keys : backgroundColor, borderWidth, borderColor, textColor
*/
@property (nonatomic, copy) ButtonFormatBlock buttonFormatBlock;
/** Hide animation type
*
* Holds the hide animation type.
* (Default: FadeOut)
*/
@property (nonatomic) SCLAlertViewHideAnimation hideAnimationType;
/** Show animation type
*
* Holds the show animation type.
* (Default: SlideInFromTop)
*/
@property (nonatomic) SCLAlertViewShowAnimation showAnimationType;
/** Set SCLAlertView background type.
*
* SCLAlertView background type.
* (Default: Shadow)
*/
@property (nonatomic) SCLAlertViewBackground backgroundType;
/** Set custom color to SCLAlertView.
*
* SCLAlertView custom color.
* (Buttons, top circle and borders)
*/
@property (nonatomic, strong) UIColor *customViewColor;
/** Set custom color to SCLAlertView background.
*
* SCLAlertView background custom color.
*/
@property (nonatomic, strong) UIColor *backgroundViewColor;
/** Set custom tint color for icon image.
*
* SCLAlertView icon tint color
*/
@property (nonatomic, strong) UIColor *iconTintColor;
/** Set custom circle icon height.
*
* Circle icon height
*/
@property (nonatomic) CGFloat circleIconHeight;
/** Set SCLAlertView extension bounds.
*
* Set new bounds (EXTENSION ONLY)
*/
@property (nonatomic) CGRect extensionBounds;
/** Initialize SCLAlertView using a new window.
*
* Init with new window
*/
- (instancetype)initWithNewWindow;
/** Warns that alerts is gone
*
* Warns that alerts is gone using block
*/
- (void)alertIsDismissed:(DismissBlock)dismissBlock;
/** Hide SCLAlertView
*
* Hide SCLAlertView using animation and removing from super view.
*/
- (void)hideView;
/** SCLAlertView visibility
*
* Returns if the alert is visible or not.
*/
- (BOOL)isVisible;
/** Remove Top Circle
*
* Remove top circle from SCLAlertView.
*/
- (void)removeTopCircle;
/** Add Text Field
*
* @param title The text displayed on the textfield.
*/
- (UITextField *)addTextField:(NSString *)title;
/** Add a custom Text Field
*
* @param textField The custom textfield provided by the programmer.
*/
- (void)addCustomTextField:(UITextField *)textField;
/** Set SubTitle Height
*
* @deprecated Deprecated since 0.5.2+ .
* @param value Height of scrollable subtitle text field.
*/
- (void)setSubTitleHeight:(CGFloat)value __deprecated;
/** Set Title font family and size
*
* @param titleFontFamily The family name used to displayed the title.
* @param size Font size.
*/
- (void)setTitleFontFamily:(NSString *)titleFontFamily withSize:(CGFloat)size;
/** Set Text field font family and size
*
* @param bodyTextFontFamily The family name used to displayed the text field.
* @param size Font size.
*/
- (void)setBodyTextFontFamily:(NSString *)bodyTextFontFamily withSize:(CGFloat)size;
/** Set Buttons font family and size
*
* @param buttonsFontFamily The family name used to displayed the buttons.
* @param size Font size.
*/
- (void)setButtonsTextFontFamily:(NSString *)buttonsFontFamily withSize:(CGFloat)size;
/** Add a Button with a title and a block to handle when the button is pressed.
*
* @param title The text displayed on the button.
* @param action A block of code to be executed when the button is pressed.
*/
- (SCLButton *)addButton:(NSString *)title actionBlock:(SCLActionBlock)action;
/** Add a Button with a title, a block to handle validation, and a block to handle when the button is pressed and validation succeeds.
*
* @param title The text displayed on the button.
* @param validationBlock A block of code that will allow you to validate fields or do any other logic you may want to do to determine if the alert should be dismissed or not. Inside of this block, return a BOOL indicating whether or not the action block should be called and the alert dismissed.
* @param action A block of code to be executed when the button is pressed and validation passes.
*/
- (SCLButton *)addButton:(NSString *)title validationBlock:(SCLValidationBlock)validationBlock actionBlock:(SCLActionBlock)action;
/** Add a Button with a title, a target and a selector to handle when the button is pressed.
*
* @param title The text displayed on the button.
* @param target Add target for particular event.
* @param selector A method to be executed when the button is pressed.
*/
- (SCLButton *)addButton:(NSString *)title target:(id)target selector:(SEL)selector;
/** Show Success SCLAlertView
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showSuccess:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showSuccess:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Show Error SCLAlertView
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showError:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showError:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Show Notice SCLAlertView
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showNotice:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showNotice:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Show Warning SCLAlertView
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showWarning:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showWarning:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Show Info SCLAlertView
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showInfo:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showInfo:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Show Edit SCLAlertView
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showEdit:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showEdit:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Show Title SCLAlertView using a predefined type
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param style One of predefined SCLAlertView styles.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showTitle:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle style:(SCLAlertViewStyle)style closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showTitle:(NSString *)title subTitle:(NSString *)subTitle style:(SCLAlertViewStyle)style closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Shows a custom SCLAlertView without using a predefined type, allowing for a custom image and color to be specified.
*
* @param vc The view controller the alert view will be displayed in.
* @param image A UIImage object to be used as the icon for the alert view.
* @param color A UIColor object to be used to tint the background of the icon circle and the buttons.
* @param title The title text of the alert view.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showCustom:(UIViewController *)vc image:(UIImage *)image color:(UIColor *)color title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showCustom:(UIImage *)image color:(UIColor *)color title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
/** Show Waiting SCLAlertView with UIActityIndicator.
*
* @param vc The view controller the alert view will be displayed in.
* @param title The text displayed on the button.
* @param subTitle The subtitle text of the alert view.
* @param closeButtonTitle The text for the close button.
* @param duration The amount of time the alert will remain on screen until it is automatically dismissed. If automatic dismissal is not desired, set to 0.
*/
- (void)showWaiting:(UIViewController *)vc title:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
- (void)showWaiting:(NSString *)title subTitle:(NSString *)subTitle closeButtonTitle:(NSString *)closeButtonTitle duration:(NSTimeInterval)duration;
@end