@@ -178,7 +178,6 @@ - (void)viewWillAppear:(BOOL)animated
178178
179179- (void )updateContentForState : (TOPasscodeSettingsViewState)state type : (TOPasscodeType)type animated : (BOOL )animated
180180{
181- BOOL confirmingPasscode = state == TOPasscodeSettingsViewStateEnterCurrentPassword;
182181 BOOL variableSizePasscode = (type >= TOPasscodeTypeCustomNumeric);
183182
184183 // Update the visibility of the options button
@@ -190,13 +189,8 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
190189 // Disable the input view
191190 self.inputField .enabled = NO ;
192191
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];
200194
201195 // Change the input view if needed
202196 if (!variableSizePasscode) {
@@ -226,6 +220,8 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
226220 break ;
227221 }
228222
223+ CGRect frame = CGRectZero;
224+
229225 // Reload the 'Done' button
230226 [self .inputField reloadInputViews ];
231227
@@ -264,6 +260,19 @@ - (void)updateContentForState:(TOPasscodeSettingsViewState)state type:(TOPasscod
264260 }];
265261}
266262
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+
267276- (void )transitionToState : (TOPasscodeSettingsViewState)state animated : (BOOL )animated
268277{
269278 // Preserve the current view state
@@ -440,8 +449,8 @@ - (void)validateCurrentPasscodeAttemptWithPasscode:(NSString *)passcode
440449
441450 BOOL correct = [self .delegate passcodeSettingsViewController: self didAttemptCurrentPasscode: passcode];
442451 if (!correct) {
443- self.failedPasscodeAttemptCount ++;
444452 [self .inputField resetPasscodeAnimated: YES playImpact: YES ];
453+ self.failedPasscodeAttemptCount ++;
445454 }
446455 else {
447456 [self transitionToState: TOPasscodeSettingsViewStateEnterNewPassword animated: YES ];
@@ -572,7 +581,7 @@ - (void)setFailedPasscodeAttemptCount:(NSInteger)failedPasscodeAttemptCount
572581{
573582 if (_failedPasscodeAttemptCount == failedPasscodeAttemptCount) { return ; }
574583 _failedPasscodeAttemptCount = failedPasscodeAttemptCount;
575- [self updateContentForState :self .state type: self .passcodeType animated: NO ];
584+ [self updateWarningLabelForState :self .state];
576585}
577586
578587@end
0 commit comments