diff --git a/THPinViewController/THPinView.h b/THPinViewController/THPinView.h index 47cbb75..762ad17 100644 --- a/THPinViewController/THPinView.h +++ b/THPinViewController/THPinView.h @@ -30,6 +30,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong, nullable) UIColor *promptColor; @property (nonatomic, assign) BOOL hideLetters; @property (nonatomic, assign) BOOL disableCancel; +@property (nonatomic, assign) BOOL disableShake; - (instancetype)initWithDelegate:(nullable id)delegate NS_DESIGNATED_INITIALIZER; diff --git a/THPinViewController/THPinView.m b/THPinViewController/THPinView.m index d3edd3b..a0e09b6 100644 --- a/THPinViewController/THPinView.m +++ b/THPinViewController/THPinView.m @@ -255,20 +255,25 @@ - (void)pinNumPadView:(THPinNumPadView *)pinNumPadView numberTapped:(NSUInteger) return; } + double delayInSeconds = 0.3f; + dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); if ([self.delegate pinView:self isPinValid:self.input]) { - double delayInSeconds = 0.3f; - dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC)); dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ [self.delegate correctPinWasEnteredInPinView:self]; }); } else { - [self.inputCirclesView shakeWithCompletion:^{ - [self resetInput]; - [self.delegate incorrectPinWasEnteredInPinView:self]; - }]; + if (self.disableShake) { + dispatch_after(popTime, dispatch_get_main_queue(), ^(void){ + [self incorrectPinWasEnteredInPinView]; + }); + } else { + [self.inputCirclesView shakeWithCompletion:^{ + [self incorrectPinWasEnteredInPinView]; + }]; + } } } @@ -281,4 +286,10 @@ - (void)resetInput [self updateBottomButton]; } +- (void)incorrectPinWasEnteredInPinView +{ + [self resetInput]; + [self.delegate incorrectPinWasEnteredInPinView:self]; +} + @end diff --git a/THPinViewController/THPinViewController.h b/THPinViewController/THPinViewController.h index 6ad78cc..ceebc1c 100644 --- a/THPinViewController/THPinViewController.h +++ b/THPinViewController/THPinViewController.h @@ -43,6 +43,7 @@ static const NSInteger THPinViewControllerContentViewTag = 14742; @property (nonatomic, assign) BOOL hideLetters; // hides the letters on the number buttons @property (nonatomic, assign) BOOL disableCancel; // hides the cancel button @property (nonatomic, assign) BOOL disableDismissAniamtion; +@property (nonatomic, assign) BOOL disableShake; // hides the shake - (instancetype)initWithDelegate:(nullable id)delegate NS_DESIGNATED_INITIALIZER; diff --git a/THPinViewController/THPinViewController.m b/THPinViewController/THPinViewController.m index a83310b..436c961 100644 --- a/THPinViewController/THPinViewController.m +++ b/THPinViewController/THPinViewController.m @@ -61,6 +61,7 @@ - (void)viewDidLoad self.pinView.promptColor = self.promptColor; self.pinView.hideLetters = self.hideLetters; self.pinView.disableCancel = self.disableCancel; + self.pinView.disableShake = self.disableShake; self.pinView.translatesAutoresizingMaskIntoConstraints = NO; [self.view addSubview:self.pinView]; // center pin view @@ -152,6 +153,15 @@ - (void)setDisableCancel:(BOOL)disableCancel self.pinView.disableCancel = self.disableCancel; } +- (void)setDisableShake:(BOOL)disableShake +{ + if (self.disableShake == disableShake) { + return; + } + _disableShake = disableShake; + self.pinView.disableShake = self.disableShake; +} + #pragma mark - Blur - (void)addBlurView