@@ -29,7 +29,7 @@ @interface TOPasscodeSettingsViewController ()
29
29
@property (nonatomic , strong ) UILabel *titleLabel;
30
30
@property (nonatomic , strong ) UILabel *errorLabel;
31
31
@property (nonatomic , strong ) UIButton *optionsButton;
32
- @property (nonatomic , strong ) TOPasscodeInputField *numberInputView ;
32
+ @property (nonatomic , strong ) TOPasscodeInputField *inputField ;
33
33
@property (nonatomic , strong ) TOPasscodeSettingsKeypadView *keypadView;
34
34
@property (nonatomic , strong ) TOPasscodeSettingsWarningLabel *warningLabel;
35
35
@@ -89,12 +89,12 @@ - (void)viewDidLoad {
89
89
[self .containerView addSubview: self .titleLabel];
90
90
91
91
// Create number view
92
- self.numberInputView = [[TOPasscodeInputField alloc ] init ];
93
- self.numberInputView .tintColor = [UIColor blackColor ];
94
- self.numberInputView .autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
95
- self.numberInputView .passcodeCompletedHandler = ^(NSString *passcode) { [weakSelf numberViewDidEnterPasscode: passcode]; };
96
- [self .numberInputView sizeToFit ];
97
- [self .containerView addSubview: self .numberInputView ];
92
+ self.inputField = [[TOPasscodeInputField alloc ] init ];
93
+ self.inputField .tintColor = [UIColor blackColor ];
94
+ self.inputField .autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
95
+ self.inputField .passcodeCompletedHandler = ^(NSString *passcode) { [weakSelf numberViewDidEnterPasscode: passcode]; };
96
+ [self .inputField sizeToFit ];
97
+ [self .containerView addSubview: self .inputField ];
98
98
99
99
// Create keypad view
100
100
self.keypadView = [[TOPasscodeSettingsKeypadView alloc ] initWithFrame: CGRectZero];
@@ -129,20 +129,20 @@ - (void)viewDidLoad {
129
129
// Add callbacks for the keypad view
130
130
self.keypadView .numberButtonTappedHandler = ^(NSInteger number) {
131
131
NSString *numberString = [NSString stringWithFormat: @" %ld " , number];
132
- [weakSelf.numberInputView appendPasscodeCharacters: numberString animated: NO ];
132
+ [weakSelf.inputField appendPasscodeCharacters: numberString animated: NO ];
133
133
};
134
134
135
- self.keypadView .deleteButtonTappedHandler = ^{ [weakSelf.numberInputView deletePasscodeCharactersOfCount: 1 animated: NO ]; };
135
+ self.keypadView .deleteButtonTappedHandler = ^{ [weakSelf.inputField deletePasscodeCharactersOfCount: 1 animated: NO ]; };
136
136
137
137
// Set height of the container view (This will never change)
138
138
CGRect frame = self.containerView .frame ;
139
139
frame.size .width = self.view .bounds .size .width ;
140
- frame.size .height = CGRectGetHeight (self.titleLabel .frame ) + CGRectGetHeight (self.numberInputView .frame )
140
+ frame.size .height = CGRectGetHeight (self.titleLabel .frame ) + CGRectGetHeight (self.inputField .frame )
141
141
+ CGRectGetHeight (self.warningLabel .frame ) + (kTOPasscodeSettingsLabelInputSpacing * 2 .0f );
142
142
self.containerView .frame = CGRectIntegral (frame);
143
143
144
144
// Work out the vertical offset of the container view assuming the warning label doesn't count
145
- self.verticalMidPoint = CGRectGetHeight (self.titleLabel .frame ) + CGRectGetHeight (self.numberInputView .frame )
145
+ self.verticalMidPoint = CGRectGetHeight (self.titleLabel .frame ) + CGRectGetHeight (self.inputField .frame )
146
146
+ kTOPasscodeSettingsLabelInputSpacing ;
147
147
self.verticalMidPoint *= 0 .5f ;
148
148
@@ -168,7 +168,7 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
168
168
self.optionsButton .hidden = !(state == TOPasscodeSettingsViewStateEnterNewPassword);
169
169
170
170
// Clear the input view
171
- self.numberInputView .passcode = nil ;
171
+ self.inputField .passcode = nil ;
172
172
173
173
// Update the warning label
174
174
self.warningLabel .hidden = !(confirmingPasscode && self.failedPasscodeAttemptCount > 0 );
@@ -179,8 +179,12 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
179
179
self.warningLabel .frame = frame;
180
180
181
181
// Change the input view if needed
182
- if (self.passcodeType < TOPasscodeTypeCustomNumeric) {
183
- self.numberInputView .fixedLength = (self.passcodeType == TOPasscodeTypeSixDigits) ? 6 : 4 ;
182
+ if (type < TOPasscodeTypeCustomNumeric) {
183
+ self.inputField .style = TOPasscodeInputFieldStyleFixed;
184
+ self.inputField .fixedInputView .length = (self.passcodeType == TOPasscodeTypeSixDigits) ? 6 : 4 ;
185
+ }
186
+ else {
187
+ self.inputField .style = TOPasscodeInputFieldStyleVariable;
184
188
}
185
189
186
190
// Update text depending on state
@@ -200,13 +204,13 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
200
204
[self .titleLabel sizeToFit ];
201
205
frame = self.titleLabel .frame ;
202
206
frame.origin .x = (CGRectGetWidth (self.containerView .frame ) - CGRectGetWidth (frame)) * 0 .5f ;
203
- self.titleLabel .frame = frame;
207
+ self.titleLabel .frame = CGRectIntegral ( frame) ;
204
208
205
209
// Resize passcode view
206
- [self .numberInputView sizeToFit ];
207
- frame = self.numberInputView .frame ;
210
+ [self .inputField sizeToFit ];
211
+ frame = self.inputField .frame ;
208
212
frame.origin .x = (CGRectGetWidth (self.containerView .frame ) - CGRectGetWidth (frame)) * 0 .5f ;
209
- self.numberInputView .frame = frame;
213
+ self.inputField .frame = CGRectIntegral ( frame) ;
210
214
}
211
215
212
216
- (void )transitionToState : (TOPasscodeSettingsViewState)state animated : (BOOL )animated
@@ -302,21 +306,21 @@ - (void)viewDidLayoutSubviews
302
306
self.titleLabel .frame = CGRectIntegral (frame);
303
307
304
308
// Set frame of number pad
305
- frame = self.numberInputView .frame ;
309
+ frame = self.inputField .frame ;
306
310
frame.origin .x = (CGRectGetWidth (self.view .frame ) - CGRectGetWidth (frame)) * 0 .5f ;
307
311
frame.origin .y = (CGRectGetHeight (self.titleLabel .frame ) + kTOPasscodeSettingsLabelInputSpacing );
308
- self.numberInputView .frame = CGRectIntegral (frame);
312
+ self.inputField .frame = CGRectIntegral (frame);
309
313
310
314
// Set the frame for the warning view
311
315
frame = self.warningLabel .frame ;
312
316
frame.origin .x = (CGRectGetWidth (self.view .frame ) - CGRectGetWidth (frame)) * 0 .5f ;
313
- frame.origin .y = CGRectGetMaxY (self.numberInputView .frame ) + kTOPasscodeSettingsLabelInputSpacing ;
317
+ frame.origin .y = CGRectGetMaxY (self.inputField .frame ) + kTOPasscodeSettingsLabelInputSpacing ;
314
318
self.warningLabel .frame = CGRectIntegral (frame);
315
319
316
320
// Set the frame of the error view
317
321
frame = self.errorLabel .frame ;
318
322
frame.size = [self .errorLabel sizeThatFits: CGSizeMake (300 .0f , CGFLOAT_MAX)];
319
- frame.origin .y = CGRectGetMaxY (self.numberInputView .frame ) + kTOPasscodeSettingsLabelInputSpacing ;
323
+ frame.origin .y = CGRectGetMaxY (self.inputField .frame ) + kTOPasscodeSettingsLabelInputSpacing ;
320
324
frame.origin .x = (CGRectGetWidth (self.containerView .frame ) - CGRectGetWidth (frame)) * 0 .5f ;
321
325
self.errorLabel .frame = CGRectIntegral (frame);
322
326
}
@@ -345,7 +349,7 @@ - (void)applyThemeForStyle:(TOPasscodeSettingsViewStyle)style
345
349
self.titleLabel .textColor = inputColor;
346
350
347
351
// Set the number input tint
348
- self.numberInputView .tintColor = inputColor;
352
+ self.inputField .tintColor = inputColor;
349
353
350
354
// Set the tint color of the incorrect warning label
351
355
UIColor *warningColor = nil ;
@@ -382,7 +386,7 @@ - (void)validateCurrentPasscodeAttemptWithPasscode:(NSString *)passcode
382
386
BOOL correct = [self .delegate passcodeSettingsViewController: self didAttemptCurrentPasscode: passcode];
383
387
if (!correct) {
384
388
self.failedPasscodeAttemptCount ++;
385
- [self .numberInputView resetPasscodeAnimated: YES playImpact: YES ];
389
+ [self .inputField resetPasscodeAnimated: YES playImpact: YES ];
386
390
}
387
391
else {
388
392
[self transitionToState: TOPasscodeSettingsViewStateEnterNewPassword animated: YES ];
0 commit comments