@@ -178,7 +178,6 @@ - (void)viewWillAppear:(BOOL)animated
178
178
179
179
- (void )updateContentForState : (TOPasscodeSettingsViewState)state type : (TOPasscodeType)type animated : (BOOL )animated
180
180
{
181
- BOOL confirmingPasscode = state == TOPasscodeSettingsViewStateEnterCurrentPassword;
182
181
BOOL variableSizePasscode = (type >= TOPasscodeTypeCustomNumeric);
183
182
184
183
// Update the visibility of the options button
@@ -190,13 +189,8 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
190
189
// Disable the input view
191
190
self.inputField .enabled = NO ;
192
191
193
- // Update the warning label
194
- self.warningLabel .hidden = !(confirmingPasscode && self.failedPasscodeAttemptCount > 0 );
195
- self.warningLabel .numberOfWarnings = self.failedPasscodeAttemptCount ;
196
-
197
- CGRect frame = self.warningLabel .frame ;
198
- frame.origin .x = (CGRectGetWidth (self.view .frame ) - frame.size .width ) * 0 .5f ;
199
- self.warningLabel .frame = frame;
192
+ // Update the warning label
193
+ [self updateWarningLabelForState: state];
200
194
201
195
// Change the input view if needed
202
196
if (!variableSizePasscode) {
@@ -226,6 +220,8 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
226
220
break ;
227
221
}
228
222
223
+ CGRect frame = CGRectZero;
224
+
229
225
// Reload the 'Done' button
230
226
[self .inputField reloadInputViews ];
231
227
@@ -264,6 +260,19 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
264
260
}];
265
261
}
266
262
263
+ - (void )updateWarningLabelForState : (TOPasscodeSettingsViewState)state
264
+ {
265
+ BOOL confirmingPasscode = state == TOPasscodeSettingsViewStateEnterCurrentPassword;
266
+
267
+ // Update the warning label
268
+ self.warningLabel .hidden = !(confirmingPasscode && self.failedPasscodeAttemptCount > 0 );
269
+ self.warningLabel .numberOfWarnings = self.failedPasscodeAttemptCount ;
270
+
271
+ CGRect frame = self.warningLabel .frame ;
272
+ frame.origin .x = (CGRectGetWidth (self.view .frame ) - frame.size .width ) * 0 .5f ;
273
+ self.warningLabel .frame = frame;
274
+ }
275
+
267
276
- (void )transitionToState : (TOPasscodeSettingsViewState)state animated : (BOOL )animated
268
277
{
269
278
// Preserve the current view state
@@ -440,8 +449,8 @@ - (void)validateCurrentPasscodeAttemptWithPasscode:(NSString *)passcode
440
449
441
450
BOOL correct = [self .delegate passcodeSettingsViewController: self didAttemptCurrentPasscode: passcode];
442
451
if (!correct) {
443
- self.failedPasscodeAttemptCount ++;
444
452
[self .inputField resetPasscodeAnimated: YES playImpact: YES ];
453
+ self.failedPasscodeAttemptCount ++;
445
454
}
446
455
else {
447
456
[self transitionToState: TOPasscodeSettingsViewStateEnterNewPassword animated: YES ];
@@ -572,7 +581,7 @@ - (void)setFailedPasscodeAttemptCount:(NSInteger)failedPasscodeAttemptCount
572
581
{
573
582
if (_failedPasscodeAttemptCount == failedPasscodeAttemptCount) { return ; }
574
583
_failedPasscodeAttemptCount = failedPasscodeAttemptCount;
575
- [self updateContentForState :self .state type: self .passcodeType animated: NO ];
584
+ [self updateWarningLabelForState :self .state];
576
585
}
577
586
578
587
@end
0 commit comments