Feature: Toggle English alphabet appearing on PIN pad #167
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New feature: Toggle English alphabet on PIN Pad
Often, implementations of PINs need a PIN pad that includes letters below the numbers (for example, Apple's unlock screen). For the app I am developing, I wanted letters on the PIN pads. I thought others might want it as well.
This PR introduces two props to toggle hiding/showing the letters, and toggling the style of the letters:
alphabetCharsVisible
false
false
boolean
Note how the default for
alphabetCharsVisible
isfalse
, so this PR will not break the layout of anyone's current implementation. Developers can easily switch this on by addingalphabetCharsVisible={true}
to the PinCode.styleAlphabet
alphabetCharsVisible={true}
)fontSize: grid.unit/2, fontWeight: "300"
StyleProp<TextStyle>
Developers can easily toggle
styleAlphabet
the same way they do withstyleTextTitle
or any otherStyleProp<TextStyle>
prop, in order to change font weight, size, color, etc. (Example:styleAlphabet={{fontWeight: '400', fontSize: 12}}
)Finally, this PR is only frontend, and does not in any way affect how the PIN is stored -- ie, it is still stored as numbers only.
Some samples:
Compare with the alphabetic layout on Apple's screen, which was the inspiration:
Note: Internally, this PR adds a map called
alphanumericMap
toPinCode.tsx
. Currently, the alphanumericMaps uses the mapping found on Apple's unlock screen (ie 1 maps to nothing, 2 maps toABC
... 9 maps toWXYZ
) .Some English PIN pads instead set (1 =
QZ
, 2ABC
, ... 9WXY
). I choose not to implement this because I think the latter is less common on mobile layouts, and really only used for physical PIN pads. This could be a future PR to support multiple PIN layouts or to add a Prop that allows developers to create their own mapping.