Skip to content

Commit

Permalink
fix: merge containers into one
Browse files Browse the repository at this point in the history
  • Loading branch information
anday013 committed May 25, 2024
1 parent 4da4c01 commit 37bfe66
Show file tree
Hide file tree
Showing 3 changed files with 328 additions and 343 deletions.
5 changes: 1 addition & 4 deletions src/OtpInput/OtpInput.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ import { StyleSheet } from "react-native";

export const styles = StyleSheet.create({
container: {
width: "100%",
flexDirection: "row",
},
inputsContainer: {
flexDirection: "row",
flex: 1,
justifyContent: "space-between",
},
codeContainer: {
Expand Down
58 changes: 28 additions & 30 deletions src/OtpInput/OtpInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,37 +57,35 @@ export const OtpInput = forwardRef<OtpInputRef, OtpInputProps>((props, ref) => {
};

return (
<View style={[styles.container, containerStyle]}>
<View style={[styles.inputsContainer, inputsContainerStyle]}>
{Array(numberOfDigits)
.fill(0)
.map((_, index) => {
const char = text[index];
const isFocusedInput = index === focusedInputIndex && !disabled && Boolean(hasCursor);
<View style={[styles.container, containerStyle, inputsContainerStyle]}>
{Array(numberOfDigits)
.fill(0)
.map((_, index) => {
const char = text[index];
const isFocusedInput = index === focusedInputIndex && !disabled && Boolean(hasCursor);

return (
<Pressable
key={`${char}-${index}`}
disabled={disabled}
onPress={handlePress}
style={generatePinCodeContainerStyle(isFocusedInput, char)}
testID="otp-input"
>
{isFocusedInput && !hideStick ? (
<VerticalStick
focusColor={focusColor}
style={focusStickStyle}
focusStickBlinkingDuration={focusStickBlinkingDuration}
/>
) : (
<Text style={[styles.codeText, pinCodeTextStyle]}>
{char && secureTextEntry ? "•" : char}
</Text>
)}
</Pressable>
);
})}
</View>
return (
<Pressable
key={`${char}-${index}`}
disabled={disabled}
onPress={handlePress}
style={generatePinCodeContainerStyle(isFocusedInput, char)}
testID="otp-input"
>
{isFocusedInput && !hideStick ? (
<VerticalStick
focusColor={focusColor}
style={focusStickStyle}
focusStickBlinkingDuration={focusStickBlinkingDuration}
/>
) : (
<Text style={[styles.codeText, pinCodeTextStyle]}>
{char && secureTextEntry ? "•" : char}
</Text>
)}
</Pressable>
);
})}
<TextInput
value={text}
onChangeText={handleTextChange}
Expand Down
Loading

0 comments on commit 37bfe66

Please sign in to comment.