-
Notifications
You must be signed in to change notification settings - Fork 0
/
BZGFormField.h
executable file
·85 lines (66 loc) · 2.21 KB
/
BZGFormField.h
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
//
// BZGFormField.h
//
// Copyright (c) 2013 Ben Guo
//
// https://github.com/benzguo/BZGFormField
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, BZGLeftIndicatorState) {
BZGLeftIndicatorStateInactive,
BZGLeftIndicatorStateActive
};
typedef NS_ENUM(NSInteger, BZGFormFieldState) {
BZGFormFieldStateInvalid,
BZGFormFieldStateValid,
BZGFormFieldStateNone
};
@protocol BZGFormFieldDelegate;
typedef BOOL (^BZGTextValidationBlock)(NSString *text);
@interface BZGFormField : UIView <UITextFieldDelegate, UIAlertViewDelegate>
@property (weak, nonatomic) id <BZGFormFieldDelegate> delegate;
@property (strong, nonatomic) UITextField *textField;
@property (strong, nonatomic) UIButton *leftIndicator;
@property (strong, nonatomic) UIAlertView *alertView;
/**
The width of the left indicator when inactive, relative to the height of the form field.
*/
@property (assign, nonatomic) CGFloat leftIndicatorInactiveWidth;
/**
The width of the left indicator when active, relative to the height of the form field.
*/
@property (assign, nonatomic) CGFloat leftIndicatorActiveWidth;
/**
The padding between the left indicator and the text field, relative to the height of the form field.
*/
@property (assign, nonatomic) CGFloat leftIndicatorRightPadding;
/**
The color of the left indicator when the form is invalid.
*/
@property (strong, nonatomic) UIColor *leftIndicatorInvalidColor;
/**
The color of the left indicator when the form is valid.
*/
@property (strong, nonatomic) UIColor *leftIndicatorValidColor;
/**
The color of the left indicator when the form is neither invalid nor valid.
*/
@property (strong, nonatomic) UIColor *leftIndicatorNoneColor;
/**
Returns the current state of the form (invalid | valid | none)
*/
- (BZGFormFieldState)formFieldState;
/**
Returns the current state of the left indicator (inactive | active)
*/
- (BZGLeftIndicatorState)leftIndicatorState;
/**
Sets the validation block for the text field.
*/
- (void)setTextValidationBlock:(BZGTextValidationBlock)block;
@end
/**
At the moment, a form field just forwards all UITextFieldDelegate and UIAlertViewDelegate messages to its delegate.
*/
@protocol BZGFormFieldDelegate <UITextFieldDelegate, UIAlertViewDelegate>
@end