Skip to content

Commit b61c4fd

Browse files
authored
Remove 'unfocused' props from PinInput (#760)
1 parent b1ace00 commit b61c4fd

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

example/src/PinInputExample.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ const PinInputExample: React.FC = () => {
1616
value={value1}
1717
onChangeText={setValue1}
1818
focusedBorderColor="green"
19-
unFocusedBorderColor="gray"
2019
focusedBackgroundColor="rgba(0,1,0,0.2)"
2120
focusedBorderWidth={5}
22-
unFocusedBorderWidth={3}
2321
focusedTextColor="green"
24-
style={{ borderRadius: 35, fontWeight: 800 }}
22+
style={{
23+
borderRadius: 35,
24+
fontWeight: "800",
25+
backgroundColor: "gray",
26+
borderWidth: 3,
27+
}}
2528
/>
2629
</Section>
2730
<Section title="PinInput (custom cell)" style={{}}>

packages/core/src/components/PinInput/PinInput.tsx

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import {
33
StyleProp,
44
ViewStyle,
5+
TextStyle,
56
TextInput as NativeTextInput,
67
View,
78
StyleSheet,
@@ -29,14 +30,10 @@ interface PinInputProps extends TextInputProps {
2930
blurOnFull?: boolean;
3031
renderItem?: ({ cellValue, index, isFocused }: CellItem) => JSX.Element;
3132
focusedBorderColor?: string;
32-
unFocusedBorderColor?: string;
3333
focusedBackgroundColor?: string;
34-
unFocusedBackgroundColor?: string;
3534
focusedBorderWidth?: number;
36-
unFocusedBorderWidth?: number;
3735
focusedTextColor?: string;
38-
unFocusedTextColor?: string;
39-
style?: StyleProp<ViewStyle>;
36+
style?: StyleProp<ViewStyle | TextStyle>;
4037
theme: Theme;
4138
}
4239

@@ -51,14 +48,10 @@ const PinInput = React.forwardRef<NativeTextInput, PinInputProps>(
5148
renderItem,
5249
value,
5350
onChangeText,
54-
focusedBorderColor = theme.colors.primary,
55-
unFocusedBorderColor = theme.colors.disabled,
51+
focusedBorderColor,
5652
focusedBackgroundColor,
57-
unFocusedBackgroundColor,
58-
focusedBorderWidth = 2,
59-
unFocusedBorderWidth = 1,
60-
focusedTextColor = theme.colors.strong,
61-
unFocusedTextColor = focusedTextColor,
53+
focusedBorderWidth,
54+
focusedTextColor,
6255
style,
6356
...rest
6457
},
@@ -109,27 +102,27 @@ const PinInput = React.forwardRef<NativeTextInput, PinInputProps>(
109102
testID="default-code-input-cell"
110103
style={[
111104
styles.cell,
112-
{
113-
borderWidth: isFocused
114-
? focusedBorderWidth
115-
: unFocusedBorderWidth,
116-
borderColor: isFocused
117-
? focusedBorderColor
118-
: unFocusedBorderColor,
119-
backgroundColor: isFocused
120-
? focusedBackgroundColor
121-
: unFocusedBackgroundColor,
122-
},
105+
{ borderColor: theme.colors.disabled },
123106
viewStyles,
107+
isFocused && focusedBorderWidth
108+
? { borderWidth: focusedBorderWidth }
109+
: undefined,
110+
isFocused && focusedBorderColor
111+
? { borderColor: focusedBorderColor }
112+
: undefined,
113+
isFocused && focusedBackgroundColor
114+
? { backgroundColor: focusedBackgroundColor }
115+
: undefined,
124116
]}
125117
>
126118
<PinInputText
127119
style={[
128120
styles.cellText,
129-
{
130-
color: isFocused ? focusedTextColor : unFocusedTextColor,
131-
},
121+
{ color: theme.colors.strong },
132122
textStyles,
123+
isFocused && focusedTextColor
124+
? { color: focusedTextColor }
125+
: undefined,
133126
]}
134127
isFocused={isFocused}
135128
>
@@ -156,6 +149,7 @@ const styles = StyleSheet.create({
156149
aspectRatio: 1,
157150
maxWidth: 70,
158151
maxHeight: 70,
152+
borderWidth: 1,
159153
},
160154
cellText: {
161155
fontSize: 25,

0 commit comments

Comments
 (0)