@towsila/expo-ui-library 3.6.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/ui/input.tsx +24 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, ComponentProps } from "react";
|
|
2
|
-
import { StyleProp, Text, TextInput, TextInputProps, View, ViewProps } from "react-native";
|
|
2
|
+
import { StyleProp, StyleSheet, Text, TextInput, TextInputProps, View, ViewProps } from "react-native";
|
|
3
3
|
import { Ionicons } from "@expo/vector-icons";
|
|
4
4
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
5
5
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
@@ -44,6 +44,7 @@ export default function Input({
|
|
|
44
44
|
const { colors } = useAppTheme();
|
|
45
45
|
const [focused, setFocused] = useState(false);
|
|
46
46
|
const {isRTL} = useLanguage();
|
|
47
|
+
const [prefixW, setPrefixW] = useState(0);
|
|
47
48
|
return (
|
|
48
49
|
<View style={[style, {marginBottom: 4}]}>
|
|
49
50
|
{label && (
|
|
@@ -73,6 +74,17 @@ export default function Input({
|
|
|
73
74
|
}}
|
|
74
75
|
/>
|
|
75
76
|
)}
|
|
77
|
+
{prefix && (
|
|
78
|
+
<View
|
|
79
|
+
onLayout={(e) => setPrefixW(e.nativeEvent.layout.width)}
|
|
80
|
+
style={[
|
|
81
|
+
styles.prefix,
|
|
82
|
+
{ [isRTL ? "left" : "right"]: 0, flexDirection: isRTL?"row":"row-reverse", },
|
|
83
|
+
]}
|
|
84
|
+
>
|
|
85
|
+
{prefix}
|
|
86
|
+
</View>
|
|
87
|
+
)}
|
|
76
88
|
{/* input */}
|
|
77
89
|
<TextInput
|
|
78
90
|
value={value}
|
|
@@ -98,7 +110,7 @@ export default function Input({
|
|
|
98
110
|
direction: isRTL ? "rtl" : "ltr",
|
|
99
111
|
textAlign: isRTL ? "right" : "left",
|
|
100
112
|
|
|
101
|
-
paddingStart: iconLeft ? 42 : 16,
|
|
113
|
+
paddingStart: prefix ? prefixW + 10 : iconLeft ? 42 : 16,
|
|
102
114
|
paddingEnd: iconRight ? 42 : 16,
|
|
103
115
|
|
|
104
116
|
borderColor: error
|
|
@@ -133,3 +145,13 @@ export default function Input({
|
|
|
133
145
|
</View>
|
|
134
146
|
);
|
|
135
147
|
}
|
|
148
|
+
|
|
149
|
+
const styles = StyleSheet.create({
|
|
150
|
+
prefix: {
|
|
151
|
+
position: "absolute",
|
|
152
|
+
top: 0,
|
|
153
|
+
height: 50,
|
|
154
|
+
zIndex: 1,
|
|
155
|
+
alignItems: "center",
|
|
156
|
+
},
|
|
157
|
+
});
|