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 index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ declare module '@twotalltotems/react-native-otp-input' {
type KeyboardType = 'default' | 'email-address' | 'number-pad' | 'phone-pad';

export interface InputProps {
pinGroups: number;
/**
* Digits of pins in the OTP
*/
Expand Down
21 changes: 18 additions & 3 deletions index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export default class OTPInputView extends Component<InputProps, OTPInputViewStat
clearInputs: false,
placeholderCharacter: "",
selectionColor: '#000',
pinGroups: 1,
}

private fields: TextInput[] | null[] = []
Expand Down Expand Up @@ -213,10 +214,24 @@ export default class OTPInputView extends Component<InputProps, OTPInputViewStat
)
}

renderTextGroups = (pinList: TextInput[],groupIndex: number, pinPerGroups: number)=>{
const currentIndex= (groupIndex*pinPerGroups)

return (
<View pointerEvents="none" key={groupIndex + "view"} testID="inputGroupSlotView" style={{marginHorizontal:15}}>
{pinList.slice(currentIndex,(currentIndex+pinPerGroups)).map((pinVal,pinIndex) =>{
this.renderOneInputField(pinVal,(currentIndex+pinIndex))
})}
</View>)
}
renderTextFields = () => {
const { pinCount } = this.props
const array = new Array(pinCount).fill(0)
return array.map(this.renderOneInputField)
const { pinCount, pinGroups } = this.props
const pinPerGrops = Math.ceil(pinCount/pinGroups);
const pinCountArray = new Array(pinCount).fill(0)
const pinGroupsArray = new Array(pinGroups).fill(0)
return pinGroupsArray.map((_,index)=>{
return this.renderTextGroups(pinCountArray,index,pinPerGrops)
})
}

render() {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,11 @@
wcwidth "^1.0.1"
ws "^1.1.0"

"@react-native-community/clipboard@^1.2.2":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@react-native-community/clipboard/-/clipboard-1.5.1.tgz#32abb3ea2eb91ee3f9c5fb1d32d5783253c9fabe"
integrity sha512-AHAmrkLEH5UtPaDiRqoULERHh3oNv7Dgs0bTC0hO5Z2GdNokAMPT5w8ci8aMcRemcwbtdHjxChgtjbeA38GBdA==

"@sinonjs/commons@^1.7.0":
version "1.7.1"
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.7.1.tgz#da5fd19a5f71177a53778073978873964f49acf1"
Expand Down