Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions THPinViewController/THPinView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<THPinViewDelegate>)delegate NS_DESIGNATED_INITIALIZER;

Expand Down
23 changes: 17 additions & 6 deletions THPinViewController/THPinView.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}];
}
}
}

Expand All @@ -281,4 +286,10 @@ - (void)resetInput
[self updateBottomButton];
}

- (void)incorrectPinWasEnteredInPinView
{
[self resetInput];
[self.delegate incorrectPinWasEnteredInPinView:self];
}

@end
1 change: 1 addition & 0 deletions THPinViewController/THPinViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<THPinViewControllerDelegate>)delegate NS_DESIGNATED_INITIALIZER;

Expand Down
10 changes: 10 additions & 0 deletions THPinViewController/THPinViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down