Skip to content

Commit 4835d1b

Browse files
author
Luke Brandon Farrell
authored
Merge pull request #18 from gtsaousidis/changeKeyboardValues
Change keyboard values
2 parents 79bd582 + a51d006 commit 4835d1b

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

PinKeyboard.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import React, { Component } from "react";
7-
import { View, Image, Text, StyleSheet, Platform } from "react-native";
7+
import { View, Image, Text, StyleSheet, Platform, TouchableOpacity } from "react-native";
88
import Ripple from "react-native-material-ripple";
99
import PropTypes from "prop-types";
1010

@@ -131,6 +131,7 @@ class PinKeyboard extends Component {
131131
} = styles;
132132
/** Props */
133133
const {
134+
disableRippleEffect,
134135
keyDown,
135136
keyboardFunc,
136137
keyboardDisabledStyle,
@@ -161,19 +162,22 @@ class PinKeyboard extends Component {
161162

162163
// We want to block keyboard interactions if it has been disabled.
163164
if (!disabled) {
165+
const KeyComponent = disableRippleEffect ? TouchableOpacity : Ripple;
166+
const keyProps = {
167+
[disableRippleEffect ? 'onPress' : 'onPressIn'] : () =>
168+
keyboardFuncSet[row][column]
169+
? keyboardFuncSet[row][column]()
170+
: keyDown(entity)
171+
}
164172
return (
165-
<Ripple
173+
<KeyComponent
166174
rippleColor={"#000"}
167175
key={column}
168-
onPressIn={() =>
169-
keyboardFuncSet[row][column]
170-
? keyboardFuncSet[row][column]()
171-
: keyDown(entity)
172-
}
176+
{...keyProps}
173177
style={[keyContainerStyle, keyDefaultStyle, keyStyle]}
174178
>
175179
{keyJsx}
176-
</Ripple>
180+
</KeyComponent>
177181
);
178182
} else {
179183
return (
@@ -242,7 +246,8 @@ PinKeyboard.propTypes = {
242246
keyTextStyle: PropTypes.object,
243247
keyImageStyle: PropTypes.object,
244248
errorStyle: PropTypes.object,
245-
errorTextStyle: PropTypes.object
249+
errorTextStyle: PropTypes.object,
250+
disableRippleEffect: PropTypes.bool
246251
};
247252

248253
PinKeyboard.defaultProps = {

PinScreen.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,9 @@ class PinScreen extends Component {
100100
keyTextStyle,
101101
keyImageStyle,
102102
errorStyle,
103-
errorTextStyle
103+
errorTextStyle,
104+
keyboard,
105+
disableRippleEffect
104106
} = this.props;
105107
/** State */
106108
const { pin } = this.state;
@@ -151,6 +153,8 @@ class PinScreen extends Component {
151153
keyImageStyle={keyImageStyle}
152154
errorStyle={errorStyle}
153155
errorTextStyle={errorTextStyle}
156+
keyboard={keyboard}
157+
disableRippleEffect={disableRippleEffect}
154158
/>
155159
{this.props.ItemFooter}
156160
</SafeAreaView>
@@ -246,6 +250,8 @@ PinScreen.propTypes = {
246250
headerBackgroundColor: PropTypes.string,
247251
footerBackgroundColor: PropTypes.string,
248252
ItemFooter: PropTypes.element,
253+
keyboard: PropTypes.array,
254+
disableRippleEffect: PropTypes.bool,
249255

250256
// Style props
251257
containerStyle: PropTypes.object,

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,14 @@ The `<PinScreen />` is a great plug and play solution for a PIN screen.
148148
| containerStyle | object | Yes | See PinScreen.js | Style applied to the container. Background colour can be set here. |
149149
| logoStyle | object | Yes | | Style applied to your logo. |
150150
| taglineStyle | object | Yes | See PinScreen.js | Style applied to the tagline. |
151+
| pin | string | Yes | | The pin value. |
151152
| pinContainerStyle | object | Yes | See PinInput.js | Style applied to PINS container. |
152153
| pinStyle | object | Yes | See PinInput.js | Style applied to each circle PIN. |
153154
| pinActiveStyle | object | Yes | See PinInput.js | Style applied to each circle PIN when it is active. |
155+
| keyboard | array | Yes | See PinKeyboard.js | 4 x 3 matrix containing the value for each key. Image or text. |
154156
| keyboardStyle | object | Yes | See PinKeyboard.js | Style applied to the keyboard. |
155157
| keyboardDisabledStyle | object | Yes | See PinKeyboard.js | Style applied when the keyboard is disabled. |
158+
| disableRippleEffect | bool | Yes | false | Disables the ripple effect from the keys. |
156159
| keyStyle | object | Yes | See PinKeyboard.js | Style applied to each key on the keyboard. |
157160
| keyTextStyle | object | Yes | See PinKeyboard.js | Style applied to the text inside each key. |
158161
| keyImageStyle | object | Yes | See PinKeyboard.js | Style applied to image in a key. If an image is passed. |
@@ -172,6 +175,7 @@ in the future.
172175
| keyboardFunc | array | Yes | See PinKeyboard.js | 4 x 3 matrix containing custom functions for each key. Pass null for no function. |
173176
| keyboardStyle | object | Yes | See PinKeyboard.js | Style applied to the keyboard. |
174177
| keyboardDisabledStyle | object | Yes | See PinKeyboard.js | Style applied when the keyboard is disabled. |
178+
| disableRippleEffect | bool | Yes | false | Disables the ripple effect from the keys. |
175179
| keyStyle | object | Yes | See PinKeyboard.js | Style applied to each key on the keyboard. |
176180
| keyTextStyle | object | Yes | See PinKeyboard.js | Style applied to the text inside each key. |
177181
| keyImageStyle | object | Yes | See PinKeyboard.js | Style applied to image in a key. If an image is passed. |
@@ -218,4 +222,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
218222

219223
<!-- ALL-CONTRIBUTORS-LIST:END -->
220224

221-
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
225+
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

0 commit comments

Comments
 (0)