Skip to content
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

Allow custom number and lettering fonts for keypad button #24

Closed
Closed
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
6 changes: 6 additions & 0 deletions TOPasscodeViewController/TOPasscodeViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ NS_ASSUME_NONNULL_BEGIN
/** Optionally change the tint color of the UI element that indicates input progress (eg the row of circles) */
@property (nonatomic, strong, nullable) UIColor *inputProgressViewTintColor;

/** Optionally change the number font of all keypad circle buttons. **/
@property (nonatomic, strong, nullable) UIFont *keypadButtonNumberFont;

/** Optionally change the lettering font of all keypad circle buttons. **/
@property (nonatomic, strong, nullable) UIFont *keypadButtonLetteringFont;

/** If the style isn't translucent, changes the tint color of the keypad circle button outlines. */
@property (nonatomic, strong, nullable) UIColor *keypadButtonBackgroundTintColor;

Expand Down
10 changes: 10 additions & 0 deletions TOPasscodeViewController/TOPasscodeViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,16 @@ - (void)setkeypadButtonBackgroundTintColor:(UIColor *)keypadButtonBackgroundTint
self.passcodeView.keypadButtonBackgroundColor = keypadButtonBackgroundTintColor;
}

- (void)setKeypadButtonNumberFont:(UIFont *)keypadButtonNumberFont
{
self.passcodeView.keypadButtonNumberFont = keypadButtonNumberFont;
}

- (void)setKeypadButtonLetteringFont:(UIFont *)keypadButtonLetteringFont
{
self.passcodeView.keypadButtonLetteringFont = keypadButtonLetteringFont;
}

- (UIColor *)keypadButtonBackgroundTintColor { return self.passcodeView.keypadButtonBackgroundColor; }

- (void)setKeypadButtonTextColor:(UIColor *)keypadButtonTextColor
Expand Down
2 changes: 2 additions & 0 deletions TOPasscodeViewController/Views/Main/TOPasscodeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ NS_ASSUME_NONNULL_BEGIN
/* Overrides for theming the various elements. */
@property (nonatomic, strong, nullable) UIColor *titleLabelColor;
@property (nonatomic, strong, nullable) UIColor *inputProgressViewTintColor;
@property (nonatomic, strong, nullable) UIFont *keypadButtonNumberFont;
@property (nonatomic, strong, nullable) UIFont *keypadButtonLetteringFont;
@property (nonatomic, strong, nullable) UIColor *keypadButtonBackgroundColor;
@property (nonatomic, strong, nullable) UIColor *keypadButtonTextColor;
@property (nonatomic, strong, nullable) UIColor *keypadButtonHighlightedTextColor;
Expand Down
26 changes: 24 additions & 2 deletions TOPasscodeViewController/Views/Main/TOPasscodeView.m
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,16 @@ - (void)updateSubviewsForContentLayout:(TOPasscodeViewContentLayout *)contentLay
self.inputField.submitButtonFontSize = contentLayout.submitButtonFontSize;

// Keypad
self.keypadView.buttonNumberFont = contentLayout.circleButtonTitleLabelFont;
self.keypadView.buttonLetteringFont = contentLayout.circleButtonLetteringLabelFont;
if (_keypadButtonNumberFont != nil) {
self.keypadView.buttonNumberFont = _keypadButtonNumberFont;
} else {
self.keypadView.buttonNumberFont = contentLayout.circleButtonTitleLabelFont;
}
if (_keypadButtonLetteringFont != nil) {
self.keypadView.buttonLetteringFont = _keypadButtonLetteringFont;
} else {
self.keypadView.buttonLetteringFont = contentLayout.circleButtonLetteringLabelFont;
}
self.keypadView.buttonLetteringSpacing = contentLayout.circleButtonLetteringSpacing;
self.keypadView.buttonLabelSpacing = contentLayout.circleButtonLabelSpacing;
self.keypadView.buttonSpacing = contentLayout.circleButtonSpacing;
Expand Down Expand Up @@ -544,6 +552,20 @@ - (void)setStyle:(TOPasscodeViewStyle)style
[self applyThemeForStyle:style];
}

- (void)setKeypadButtonNumberFont:(UIFont *)keypadButtonNumberFont
{
if (keypadButtonNumberFont == _keypadButtonNumberFont) { return; }
_keypadButtonNumberFont = keypadButtonNumberFont;
self.keypadView.buttonNumberFont = keypadButtonNumberFont;
}

- (void)setKeypadButtonLetteringFont:(UIFont *)keypadButtonLetteringFont
{
if (keypadButtonLetteringFont == _keypadButtonLetteringFont) { return; }
_keypadButtonLetteringFont = keypadButtonLetteringFont;
self.keypadView.buttonLetteringFont = keypadButtonLetteringFont;
}

- (void)setLeftButton:(UIButton *)leftButton
{
if (leftButton == _leftButton) { return; }
Expand Down