Skip to content

add support for clearing pin normally #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions THPinViewController/THPinView.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)cancelButtonTappedInPinView:(THPinView *)pinView;
- (void)correctPinWasEnteredInPinView:(THPinView *)pinView;
- (void)incorrectPinWasEnteredInPinView:(THPinView *)pinView;
- (void)pinViewDidStartEntering:(THPinView *)pinView;

@end

Expand All @@ -32,6 +33,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, assign) BOOL disableCancel;

- (instancetype)initWithDelegate:(nullable id<THPinViewDelegate>)delegate NS_DESIGNATED_INITIALIZER;
- (void) resetInput;

@end

Expand Down
4 changes: 4 additions & 0 deletions THPinViewController/THPinView.m
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,10 @@ - (void)pinNumPadView:(THPinNumPadView *)pinNumPadView numberTapped:(NSUInteger)
{
NSUInteger pinLength = [self.delegate pinLengthForPinView:self];

if (pinLength == 0) {
[self.delegate pinViewDidStartEntering:self];
}

if (self.input.length >= pinLength) {
return;
}
Expand Down
2 changes: 2 additions & 0 deletions THPinViewController/THPinViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static const NSInteger THPinViewControllerContentViewTag = 14742;
- (void)pinViewControllerDidDismissAfterPinEntryWasUnsuccessful:(THPinViewController *)pinViewController;
- (void)pinViewControllerWillDismissAfterPinEntryWasCancelled:(THPinViewController *)pinViewController;
- (void)pinViewControllerDidDismissAfterPinEntryWasCancelled:(THPinViewController *)pinViewController;
- (void)pinViewControllerDidStartEntering:(THPinViewController *)pinViewController;

@end

Expand All @@ -45,6 +46,7 @@ static const NSInteger THPinViewControllerContentViewTag = 14742;
@property (nonatomic, assign) BOOL disableDismissAniamtion;

- (instancetype)initWithDelegate:(nullable id<THPinViewControllerDelegate>)delegate NS_DESIGNATED_INITIALIZER;
- (void) clear;

@end

Expand Down
11 changes: 11 additions & 0 deletions THPinViewController/THPinViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ - (UIImage*)blurredContentImage
saturationDeltaFactor:1.8f maskImage:nil];
}

#pragma mark - THPinView actions
- (void) clear
{
[self.pinView resetInput];
}

#pragma mark - THPinViewDelegate

- (NSUInteger)pinLengthForPinView:(THPinView *)pinView
Expand Down Expand Up @@ -247,4 +253,9 @@ - (void)incorrectPinWasEnteredInPinView:(THPinView *)pinView
}
}

- (void)pinViewDidStartEntering:(THPinView *)pinView
{
[self.delegate pinViewControllerDidStartEntering:self];
}

@end