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
·252 lines (220 loc) · 9.26 KB
/
SCLAlertView.h
File metadata and controls
executable file
·252 lines (220 loc) · 9.26 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
//
// SCLAlertView.h
// SCLAlertView
//
// Created by Diogo Autilio on 9/26/14.
// Copyright (c) 2014 AnyKey Entertainment. All rights reserved.
//
#import <UIKit/UIKit.h>
#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,
Custom
};
/** Alert hide animation styles
*
* Set SCLAlertView hide animation type.
*/
typedef NS_ENUM(NSInteger, SCLAlertViewHideAnimation)
{
FadeOut,
SlideOutToBottom,
SlideOutToTop,
SlideOutToLeft,
SlideOutToRight
};
/** Alert show animation styles
*
* Set SCLAlertView show animation type.
*/
typedef NS_ENUM(NSInteger, SCLAlertViewShowAnimation)
{
FadeIn,
SlideInFromBottom,
SlideInFromTop,
SlideInFromLeft,
SlideInFromRight
};
/** Alert background styles
*
* Set SCLAlertView background type.
*/
typedef NS_ENUM(NSInteger, SCLAlertViewBackground)
{
Shadow,
Blur
};
/** Title Label
*
* The text displayed as title.
*/
@property UILabel *labelTitle;
/** Text view with the body message
*
* Holds the textview.
*/
@property UITextView *viewText;
/** 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 button format block.
*
* Holds the button format block.
* Support keys : backgroundColor, textColor
*/
@property (nonatomic, copy) CompleteButtonFormatBlock completeButtonFormatBlock;
/** 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;
/** 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;
/** Add Text Field
*
* @param title The text displayed on the textfield.
*/
- (UITextField *)addTextField:(NSString *)title;
/** 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:(ValidationBlock)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;
/** 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;
/** 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;
/** 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;
/** 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;
/** 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;
/** 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;
/** 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;
@end