@towsila/expo-ui-library 4.8.2 → 4.9.1
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/screens/AddReportScreen.tsx +54 -78
- package/src/components/screens/aboutScreen.tsx +7 -6
- package/src/components/ui/select.tsx +224 -0
- package/src/components/ui/textArea.tsx +99 -0
- package/src/index.ts +2 -1
- package/src/components/ui/sharpSelect.tsx +0 -155
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
|
-
import { Text, View, TouchableOpacity } from "react-native";
|
|
2
|
+
import { Text, View, TouchableOpacity, TextInput } from "react-native";
|
|
3
3
|
import TemplateSubPage from "../reusable/templateSubPage";
|
|
4
4
|
import { useSubmitReport } from "../../hooks/useSubmitReport";
|
|
5
5
|
import SharpInput from "../ui/sharpInput";
|
|
@@ -7,20 +7,24 @@ import { useAppTheme } from "../../context/ThemeContext";
|
|
|
7
7
|
import SharpButton from "../ui/sharpButton";
|
|
8
8
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
9
9
|
import ErrorMessage from "../ui/error";
|
|
10
|
-
import
|
|
10
|
+
import TextArea from "../ui/textArea";
|
|
11
|
+
import Select from "../ui/select";
|
|
11
12
|
|
|
12
13
|
interface ReportProps {
|
|
13
14
|
title: string;
|
|
14
15
|
subtitle: string;
|
|
15
16
|
onBack: () => void;
|
|
16
17
|
categories: { value: string; label: string }[];
|
|
17
|
-
detailsPlaceholder
|
|
18
|
+
detailsPlaceholder: string;
|
|
18
19
|
submitLabel: string;
|
|
19
20
|
onSubmit: (target: string, reason: string) => Promise<void>;
|
|
20
21
|
error?: string;
|
|
21
22
|
textLabel?: string;
|
|
22
23
|
selectLabel?:string;
|
|
24
|
+
selectPlaceholder:string;
|
|
23
25
|
t?: (key: string) => string;
|
|
26
|
+
onCancel?:()=>void;
|
|
27
|
+
cancel?:string
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
export default function AddReport({
|
|
@@ -34,7 +38,10 @@ export default function AddReport({
|
|
|
34
38
|
error,
|
|
35
39
|
textLabel,
|
|
36
40
|
selectLabel,
|
|
41
|
+
selectPlaceholder,
|
|
37
42
|
t,
|
|
43
|
+
onCancel,
|
|
44
|
+
cancel
|
|
38
45
|
}: ReportProps) {
|
|
39
46
|
const form = useSubmitReport({ onSubmit });
|
|
40
47
|
const { colors } = useAppTheme();
|
|
@@ -48,90 +55,59 @@ export default function AddReport({
|
|
|
48
55
|
error={error}
|
|
49
56
|
onBack={onBack}
|
|
50
57
|
>
|
|
51
|
-
{/* Category chips */}
|
|
52
58
|
<View style={{ marginBottom: 16 }}>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<SharpContainer
|
|
70
|
-
height={50}
|
|
71
|
-
bgColor={colors.background.main}
|
|
72
|
-
borderColor={isSelected ? colors.primary : colors.semantic.border}
|
|
73
|
-
>
|
|
74
|
-
<TouchableOpacity
|
|
75
|
-
key={cat.value}
|
|
76
|
-
onPress={() => {
|
|
77
|
-
form.setValue("target", cat.value);
|
|
78
|
-
form.clearError("target");
|
|
79
|
-
}}
|
|
80
|
-
style={{ flex: 1, alignItems: "center", justifyContent: "center", paddingHorizontal: 14 }}
|
|
81
|
-
>
|
|
82
|
-
<Text style={{
|
|
83
|
-
fontSize: textSize.xs,
|
|
84
|
-
fontFamily: Fonts.montserrat.regular,
|
|
85
|
-
color: colors.text.secondary,
|
|
86
|
-
}}>
|
|
87
|
-
{cat.label}
|
|
88
|
-
</Text>
|
|
89
|
-
</TouchableOpacity>
|
|
90
|
-
</SharpContainer>
|
|
59
|
+
<Select
|
|
60
|
+
options={categories}
|
|
61
|
+
value={form.values.target}
|
|
62
|
+
onChange={(value) => {
|
|
63
|
+
form.setValue("target", value);
|
|
64
|
+
form.clearError("target");
|
|
65
|
+
}}
|
|
66
|
+
label={selectLabel}
|
|
67
|
+
placeholder={selectPlaceholder ?? "Select a category"}
|
|
68
|
+
error={
|
|
69
|
+
form.errors.target
|
|
70
|
+
? t?.(form.errors.target) || form.errors.target
|
|
71
|
+
: undefined
|
|
72
|
+
}
|
|
73
|
+
bgColor={colors.background.card}
|
|
74
|
+
/>
|
|
91
75
|
</View>
|
|
92
|
-
);
|
|
93
|
-
})}
|
|
94
|
-
</View>
|
|
95
|
-
{form.errors.target && <ErrorMessage message={t?.(form.errors.target) || form.errors.target} />}
|
|
96
|
-
</View>
|
|
97
|
-
|
|
98
|
-
{/* Details textarea */}
|
|
99
|
-
<View style={{ marginBottom: 16 }}>
|
|
100
|
-
<SharpInput
|
|
101
|
-
value={form.values.reason}
|
|
102
|
-
onChangeText={(text) => {
|
|
103
|
-
if (text.length <= MAX_CHARS) {
|
|
104
|
-
form.setValue("reason", text);
|
|
105
|
-
setCharCount(text.length);
|
|
106
|
-
}
|
|
107
|
-
}}
|
|
108
|
-
placeholder={detailsPlaceholder}
|
|
109
|
-
label={textLabel}
|
|
110
|
-
multiline
|
|
111
|
-
numberOfLines={4}
|
|
112
|
-
textAlignVertical="top"
|
|
113
|
-
height={100}
|
|
114
|
-
error={form.errors.reason ? t?.(form.errors.reason) : ""}
|
|
115
|
-
onClearError={() => form.clearError("reason")}
|
|
116
|
-
bgColor={colors.background.main}
|
|
117
|
-
/>
|
|
118
|
-
{/* Character counter */}
|
|
119
|
-
<Text style={{
|
|
120
|
-
fontSize: textSize.xs,
|
|
121
|
-
fontFamily: Fonts.montserrat.regular,
|
|
122
|
-
color: charCount >= MAX_CHARS ? colors.semantic.error : colors.text.placeholder,
|
|
123
|
-
textAlign: "right",
|
|
124
|
-
}}>
|
|
125
|
-
{charCount} / {MAX_CHARS}
|
|
126
|
-
</Text>
|
|
127
|
-
</View>
|
|
128
76
|
|
|
77
|
+
<TextArea
|
|
78
|
+
value={form.values.reason}
|
|
79
|
+
onChangeText={(text) => {
|
|
80
|
+
form.setValue("reason", text);
|
|
81
|
+
setCharCount(text.length);
|
|
82
|
+
}}
|
|
83
|
+
label={textLabel}
|
|
84
|
+
placeholder={detailsPlaceholder}
|
|
85
|
+
error={
|
|
86
|
+
form.errors.reason
|
|
87
|
+
? t?.(form.errors.reason) || form.errors.reason
|
|
88
|
+
: undefined
|
|
89
|
+
}
|
|
90
|
+
onClearError={() => form.clearError("reason")}
|
|
91
|
+
maxLength={MAX_CHARS}
|
|
92
|
+
minHeight={120}
|
|
93
|
+
bgColor={colors.background.main}
|
|
94
|
+
showCharCount
|
|
95
|
+
/>
|
|
96
|
+
<View style={{gap: 10, position: "absolute", left: 0, right:0, bottom: 40}}>
|
|
129
97
|
<SharpButton
|
|
130
98
|
text={submitLabel}
|
|
131
99
|
bgColor={colors.primary}
|
|
132
100
|
onPress={form.handleSubmit}
|
|
133
101
|
loading={form.loading}
|
|
134
102
|
/>
|
|
103
|
+
{cancel && (
|
|
104
|
+
<SharpButton
|
|
105
|
+
text={cancel}
|
|
106
|
+
bgColor={colors.primary}
|
|
107
|
+
onPress={onCancel}
|
|
108
|
+
/>
|
|
109
|
+
)}
|
|
110
|
+
</View>
|
|
135
111
|
</TemplateSubPage>
|
|
136
112
|
);
|
|
137
113
|
}
|
|
@@ -3,6 +3,7 @@ import TemplateSubPage from "../reusable/templateSubPage";
|
|
|
3
3
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
4
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
5
5
|
import Badge from "../ui/badge";
|
|
6
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
6
7
|
|
|
7
8
|
interface AboutProps {
|
|
8
9
|
title: string;
|
|
@@ -25,7 +26,7 @@ export default function AboutScreen({
|
|
|
25
26
|
}: AboutProps) {
|
|
26
27
|
const { colors } = useAppTheme();
|
|
27
28
|
const styles = createStyles(colors);
|
|
28
|
-
|
|
29
|
+
const {isRTL} = useLanguage();
|
|
29
30
|
return (
|
|
30
31
|
<TemplateSubPage
|
|
31
32
|
title={title}
|
|
@@ -35,7 +36,7 @@ export default function AboutScreen({
|
|
|
35
36
|
<View style={styles.container}>
|
|
36
37
|
{/* Header */}
|
|
37
38
|
<View style={styles.header}>
|
|
38
|
-
<View style={{marginBottom:20, flexDirection:"row", justifyContent:"space-between", alignItems:"center"}}>
|
|
39
|
+
<View style={{marginBottom:20, flexDirection:isRTL?"row":"row-reverse", justifyContent:"space-between", alignItems:"center"}}>
|
|
39
40
|
{logo}
|
|
40
41
|
<Badge
|
|
41
42
|
text="v1.0.0"
|
|
@@ -44,9 +45,9 @@ export default function AboutScreen({
|
|
|
44
45
|
/>
|
|
45
46
|
</View>
|
|
46
47
|
|
|
47
|
-
<Text style={styles.appName}>{appName}</Text>
|
|
48
|
+
<Text style={[styles.appName , {textAlign:isRTL ? "left":"right"}]}>{appName}</Text>
|
|
48
49
|
|
|
49
|
-
<Text style={styles.slogan}>
|
|
50
|
+
<Text style={[styles.slogan , {textAlign:isRTL ? "left":"right"}]}>
|
|
50
51
|
{slogan}
|
|
51
52
|
</Text>
|
|
52
53
|
</View>
|
|
@@ -55,11 +56,11 @@ export default function AboutScreen({
|
|
|
55
56
|
<View style={styles.sections}>
|
|
56
57
|
{sections.map((section, index) => (
|
|
57
58
|
<View key={index} style={styles.card}>
|
|
58
|
-
<Text style={styles.sectionTitle}>
|
|
59
|
+
<Text style={[styles.sectionTitle, {textAlign:isRTL ? "left":"right"}]}>
|
|
59
60
|
{section.title}
|
|
60
61
|
</Text>
|
|
61
62
|
|
|
62
|
-
<Text style={styles.sectionText}>
|
|
63
|
+
<Text style={[styles.sectionText, {textAlign:isRTL ? "left":"right"}]}>
|
|
63
64
|
{section.text}
|
|
64
65
|
</Text>
|
|
65
66
|
</View>
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
|
|
2
|
+
import { useState, useRef } from "react";
|
|
3
|
+
import {
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
TouchableOpacity,
|
|
7
|
+
ScrollView,
|
|
8
|
+
Modal,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
import { useAppTheme } from "../../context/ThemeContext";
|
|
11
|
+
import { Fonts, textSize } from "../../tokens/typography";
|
|
12
|
+
import { Ionicons } from "@expo/vector-icons";
|
|
13
|
+
import ErrorMessage from "./error";
|
|
14
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
15
|
+
|
|
16
|
+
interface Option {
|
|
17
|
+
value: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface SelectProps {
|
|
22
|
+
options: Option[];
|
|
23
|
+
value: string;
|
|
24
|
+
onChange: (value: string) => void;
|
|
25
|
+
label?: string;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
error?: string;
|
|
28
|
+
onClearError?: () => void;
|
|
29
|
+
height?: number;
|
|
30
|
+
bgColor?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default function Select({
|
|
34
|
+
options,
|
|
35
|
+
value,
|
|
36
|
+
onChange,
|
|
37
|
+
label,
|
|
38
|
+
placeholder = "Select an option",
|
|
39
|
+
error,
|
|
40
|
+
onClearError,
|
|
41
|
+
height = 50,
|
|
42
|
+
bgColor,
|
|
43
|
+
}: SelectProps) {
|
|
44
|
+
const [open, setOpen] = useState(false);
|
|
45
|
+
const [dropdownPos, setDropdownPos] = useState({
|
|
46
|
+
x: 0,
|
|
47
|
+
y: 0,
|
|
48
|
+
width: 0,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const triggerRef = useRef<View>(null);
|
|
52
|
+
const { colors } = useAppTheme();
|
|
53
|
+
const {isRTL} = useLanguage();
|
|
54
|
+
|
|
55
|
+
const selectedLabel = options.find(
|
|
56
|
+
(option) => option.value === value
|
|
57
|
+
)?.label;
|
|
58
|
+
|
|
59
|
+
const handleOpen = () => {
|
|
60
|
+
triggerRef.current?.measureInWindow((x, y, width, measuredHeight) => {
|
|
61
|
+
setDropdownPos({
|
|
62
|
+
x,
|
|
63
|
+
y: y + measuredHeight,
|
|
64
|
+
width,
|
|
65
|
+
});
|
|
66
|
+
setOpen(true);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
onClearError?.();
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<View style={{ marginBottom: 4 }}>
|
|
74
|
+
{label && (
|
|
75
|
+
<Text
|
|
76
|
+
style={{
|
|
77
|
+
color: colors.text.primary,
|
|
78
|
+
fontSize: textSize.xs,
|
|
79
|
+
fontFamily: Fonts.montserrat.semiBold,
|
|
80
|
+
marginBottom: 6,
|
|
81
|
+
textAlign: isRTL?"left":"right"
|
|
82
|
+
}}
|
|
83
|
+
>
|
|
84
|
+
{label}
|
|
85
|
+
</Text>
|
|
86
|
+
)}
|
|
87
|
+
|
|
88
|
+
<TouchableOpacity
|
|
89
|
+
activeOpacity={0.8}
|
|
90
|
+
onPress={() => (open ? setOpen(false) : handleOpen())}
|
|
91
|
+
>
|
|
92
|
+
<View ref={triggerRef} collapsable={false}>
|
|
93
|
+
<View
|
|
94
|
+
style={{
|
|
95
|
+
height,
|
|
96
|
+
backgroundColor: bgColor ?? colors.background.main,
|
|
97
|
+
borderWidth: 1.4,
|
|
98
|
+
borderColor: error
|
|
99
|
+
? colors.semantic.error
|
|
100
|
+
: open
|
|
101
|
+
? colors.primary
|
|
102
|
+
: colors.text.primary,
|
|
103
|
+
borderRadius: 12,
|
|
104
|
+
paddingHorizontal: 14,
|
|
105
|
+
flexDirection: isRTL?"row":"row-reverse",
|
|
106
|
+
alignItems: "center",
|
|
107
|
+
justifyContent: "space-between",
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<Text
|
|
111
|
+
numberOfLines={1}
|
|
112
|
+
style={{
|
|
113
|
+
flex: 1,
|
|
114
|
+
fontSize: textSize.sm,
|
|
115
|
+
fontFamily: Fonts.montserrat.regular,
|
|
116
|
+
color: colors.text.primary,
|
|
117
|
+
textAlign: isRTL?"left":"right"
|
|
118
|
+
}}
|
|
119
|
+
>
|
|
120
|
+
{selectedLabel ?? placeholder}
|
|
121
|
+
</Text>
|
|
122
|
+
|
|
123
|
+
<Ionicons
|
|
124
|
+
name={open ? "chevron-up" : "chevron-down"}
|
|
125
|
+
size={16}
|
|
126
|
+
color={colors.text.primary}
|
|
127
|
+
/>
|
|
128
|
+
</View>
|
|
129
|
+
</View>
|
|
130
|
+
</TouchableOpacity>
|
|
131
|
+
|
|
132
|
+
{error && <ErrorMessage message={error} />}
|
|
133
|
+
|
|
134
|
+
<Modal
|
|
135
|
+
visible={open}
|
|
136
|
+
transparent
|
|
137
|
+
animationType="fade"
|
|
138
|
+
onRequestClose={() => setOpen(false)}
|
|
139
|
+
>
|
|
140
|
+
<TouchableOpacity
|
|
141
|
+
style={{ flex: 1 }}
|
|
142
|
+
activeOpacity={1}
|
|
143
|
+
onPress={() => setOpen(false)}
|
|
144
|
+
>
|
|
145
|
+
<View
|
|
146
|
+
style={{
|
|
147
|
+
position: "absolute",
|
|
148
|
+
top: dropdownPos.y + 50,
|
|
149
|
+
left: dropdownPos.x,
|
|
150
|
+
width: dropdownPos.width,
|
|
151
|
+
maxHeight: 240,
|
|
152
|
+
backgroundColor: bgColor ?? colors.background.card,
|
|
153
|
+
borderRadius: 12,
|
|
154
|
+
borderWidth: 1.4,
|
|
155
|
+
borderColor: colors.text.primary,
|
|
156
|
+
overflow: "hidden",
|
|
157
|
+
elevation: 6,
|
|
158
|
+
shadowColor: "#000",
|
|
159
|
+
shadowOffset: { width: 0, height: 3 },
|
|
160
|
+
shadowOpacity: 0.12,
|
|
161
|
+
shadowRadius: 5,
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
<ScrollView
|
|
165
|
+
bounces={false}
|
|
166
|
+
keyboardShouldPersistTaps="handled"
|
|
167
|
+
nestedScrollEnabled
|
|
168
|
+
showsVerticalScrollIndicator={false}
|
|
169
|
+
>
|
|
170
|
+
{options.map((option, index) => {
|
|
171
|
+
const isSelected = option.value === value;
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<TouchableOpacity
|
|
175
|
+
key={option.value}
|
|
176
|
+
onPress={() => {
|
|
177
|
+
onChange(option.value);
|
|
178
|
+
setOpen(false);
|
|
179
|
+
}}
|
|
180
|
+
style={{
|
|
181
|
+
minHeight: 48,
|
|
182
|
+
paddingVertical: 12,
|
|
183
|
+
paddingHorizontal: 14,
|
|
184
|
+
flexDirection: isRTL ? "row":"row-reverse",
|
|
185
|
+
alignItems: "center",
|
|
186
|
+
justifyContent: "space-between",
|
|
187
|
+
backgroundColor: isSelected
|
|
188
|
+
? colors.primary + "12"
|
|
189
|
+
: bgColor ?? colors.background.card,
|
|
190
|
+
}}
|
|
191
|
+
>
|
|
192
|
+
<Text
|
|
193
|
+
style={{
|
|
194
|
+
flex: 1,
|
|
195
|
+
fontSize: textSize.sm,
|
|
196
|
+
fontFamily: isSelected
|
|
197
|
+
? Fonts.montserrat.semiBold
|
|
198
|
+
: Fonts.montserrat.regular,
|
|
199
|
+
color: isSelected
|
|
200
|
+
? colors.primary
|
|
201
|
+
: colors.text.primary,
|
|
202
|
+
textAlign: isRTL?"left":"right"
|
|
203
|
+
}}
|
|
204
|
+
>
|
|
205
|
+
{option.label}
|
|
206
|
+
</Text>
|
|
207
|
+
|
|
208
|
+
{isSelected && (
|
|
209
|
+
<Ionicons
|
|
210
|
+
name="checkmark"
|
|
211
|
+
size={18}
|
|
212
|
+
color={colors.primary}
|
|
213
|
+
/>
|
|
214
|
+
)}
|
|
215
|
+
</TouchableOpacity>
|
|
216
|
+
);
|
|
217
|
+
})}
|
|
218
|
+
</ScrollView>
|
|
219
|
+
</View>
|
|
220
|
+
</TouchableOpacity>
|
|
221
|
+
</Modal>
|
|
222
|
+
</View>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Text, TextInput, View } from "react-native";
|
|
2
|
+
import { useAppTheme } from "../../context/ThemeContext";
|
|
3
|
+
import { Fonts, textSize } from "../../tokens/typography";
|
|
4
|
+
import ErrorMessage from "./error";
|
|
5
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
6
|
+
|
|
7
|
+
interface TextAreaProps {
|
|
8
|
+
value: string;
|
|
9
|
+
onChangeText: (text: string) => void;
|
|
10
|
+
label?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
error?: string;
|
|
13
|
+
onClearError?: () => void;
|
|
14
|
+
maxLength?: number;
|
|
15
|
+
minHeight?: number;
|
|
16
|
+
bgColor?: string;
|
|
17
|
+
showCharCount?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function TextArea({
|
|
21
|
+
value,
|
|
22
|
+
onChangeText,
|
|
23
|
+
label,
|
|
24
|
+
placeholder,
|
|
25
|
+
error,
|
|
26
|
+
onClearError,
|
|
27
|
+
maxLength = 500,
|
|
28
|
+
minHeight = 120,
|
|
29
|
+
bgColor,
|
|
30
|
+
showCharCount = false,
|
|
31
|
+
}: TextAreaProps) {
|
|
32
|
+
const { colors } = useAppTheme();
|
|
33
|
+
const {isRTL} = useLanguage();
|
|
34
|
+
const handleChange = (text: string) => {
|
|
35
|
+
onChangeText(text);
|
|
36
|
+
onClearError?.();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<View style={{ marginBottom: 16 }}>
|
|
41
|
+
{label && (
|
|
42
|
+
<Text
|
|
43
|
+
style={{
|
|
44
|
+
fontSize: textSize.xs,
|
|
45
|
+
fontFamily: Fonts.montserrat.semiBold,
|
|
46
|
+
color: colors.text.primary,
|
|
47
|
+
marginBottom: 6,
|
|
48
|
+
textAlign: isRTL ? "left":"right"
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{label}
|
|
52
|
+
</Text>
|
|
53
|
+
)}
|
|
54
|
+
|
|
55
|
+
<TextInput
|
|
56
|
+
value={value}
|
|
57
|
+
onChangeText={handleChange}
|
|
58
|
+
placeholder={placeholder}
|
|
59
|
+
multiline
|
|
60
|
+
textAlignVertical="top"
|
|
61
|
+
maxLength={maxLength}
|
|
62
|
+
placeholderTextColor={colors.text.placeholder}
|
|
63
|
+
style={{
|
|
64
|
+
minHeight,
|
|
65
|
+
padding: 14,
|
|
66
|
+
backgroundColor: bgColor ?? colors.background.card,
|
|
67
|
+
borderWidth: 1.4,
|
|
68
|
+
borderColor: error
|
|
69
|
+
? colors.semantic.error
|
|
70
|
+
: colors.text.primary,
|
|
71
|
+
borderRadius: 12,
|
|
72
|
+
fontSize: textSize.sm,
|
|
73
|
+
fontFamily: Fonts.montserrat.regular,
|
|
74
|
+
color: colors.text.primary,
|
|
75
|
+
textAlign: isRTL?"left":"right"
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
|
|
79
|
+
{showCharCount && (
|
|
80
|
+
<Text
|
|
81
|
+
style={{
|
|
82
|
+
fontSize: textSize.xs,
|
|
83
|
+
fontFamily: Fonts.montserrat.regular,
|
|
84
|
+
color:
|
|
85
|
+
value.length >= maxLength
|
|
86
|
+
? colors.semantic.error
|
|
87
|
+
: colors.text.placeholder,
|
|
88
|
+
textAlign: isRTL ? "right" : "left",
|
|
89
|
+
marginTop: 4,
|
|
90
|
+
}}
|
|
91
|
+
>
|
|
92
|
+
{maxLength} / {value.length}
|
|
93
|
+
</Text>
|
|
94
|
+
)}
|
|
95
|
+
|
|
96
|
+
{error && <ErrorMessage message={error} />}
|
|
97
|
+
</View>
|
|
98
|
+
);
|
|
99
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -52,7 +52,7 @@ export {useUpdateUser} from "./hooks/useUpdateUser";
|
|
|
52
52
|
export {default as LegalScreen} from "./components/screens/LegalScreen";
|
|
53
53
|
export {default as AddReportScreen} from "./components/screens/AddReportScreen";
|
|
54
54
|
export {useSubmitReport} from "./hooks/useSubmitReport";
|
|
55
|
-
export {default as
|
|
55
|
+
export {default as Select} from "./components/ui/select";
|
|
56
56
|
export {useForm} from "./hooks/useForm";
|
|
57
57
|
export {default as AboutScreen} from "./components/screens/aboutScreen";
|
|
58
58
|
export {default as Badge} from "./components/ui/badge";
|
|
@@ -81,3 +81,4 @@ export {default as PhonePrefix} from "./components/ui/phonePrefix";
|
|
|
81
81
|
export {default as ProfileScreen} from "./components/screens/profileScreen";
|
|
82
82
|
export { default as RequestCard } from "./components/ui/requestCard";
|
|
83
83
|
export { Request, RequestStatus } from "./types/request";
|
|
84
|
+
export {default as TextArea} from "./components/ui/textArea";
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import { useState, useRef } from "react";
|
|
2
|
-
import { Text, View, TouchableOpacity, ScrollView, Modal } from "react-native";
|
|
3
|
-
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
|
-
import { Fonts, textSize } from "../../tokens/typography";
|
|
5
|
-
import { Ionicons } from "@expo/vector-icons";
|
|
6
|
-
import SharpContainer from "./sharpContainer";
|
|
7
|
-
import ErrorMessage from "./error";
|
|
8
|
-
|
|
9
|
-
interface Option {
|
|
10
|
-
value: string;
|
|
11
|
-
label: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface SharpSelectProps {
|
|
15
|
-
options: Option[];
|
|
16
|
-
value: string;
|
|
17
|
-
onChange: (value: string) => void;
|
|
18
|
-
label?: string;
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
error?: string;
|
|
21
|
-
onClearError?: () => void;
|
|
22
|
-
height?: number;
|
|
23
|
-
bgColor?: string;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export default function SharpSelect({
|
|
27
|
-
options,
|
|
28
|
-
value,
|
|
29
|
-
onChange,
|
|
30
|
-
label,
|
|
31
|
-
placeholder = "Select an option",
|
|
32
|
-
error,
|
|
33
|
-
onClearError,
|
|
34
|
-
height = 50,
|
|
35
|
-
bgColor,
|
|
36
|
-
}: SharpSelectProps) {
|
|
37
|
-
const [open, setOpen] = useState(false);
|
|
38
|
-
const [dropdownPos, setDropdownPos] = useState({ x: 0, y: 0, width: 0 });
|
|
39
|
-
const triggerRef = useRef<View>(null);
|
|
40
|
-
const { colors } = useAppTheme();
|
|
41
|
-
|
|
42
|
-
const selectedLabel = options.find((o) => o.value === value)?.label;
|
|
43
|
-
|
|
44
|
-
const getBorderColor = () => {
|
|
45
|
-
if (error) return colors.semantic.error;
|
|
46
|
-
if (open) return colors.primary;
|
|
47
|
-
return colors.semantic.border;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const handleOpen = () => {
|
|
51
|
-
triggerRef.current?.measureInWindow((x, y, width, height) => {
|
|
52
|
-
setDropdownPos({ x, y: y + height, width });
|
|
53
|
-
setOpen(true);
|
|
54
|
-
});
|
|
55
|
-
onClearError?.();
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
return (
|
|
59
|
-
<View style={{ marginBottom: 4 }}>
|
|
60
|
-
{label && (
|
|
61
|
-
<Text style={{
|
|
62
|
-
color: colors.text.primary,
|
|
63
|
-
fontSize: textSize.xs,
|
|
64
|
-
fontFamily: Fonts.montserrat.semiBold,
|
|
65
|
-
marginBottom: 6,
|
|
66
|
-
}}>
|
|
67
|
-
{label}
|
|
68
|
-
</Text>
|
|
69
|
-
)}
|
|
70
|
-
|
|
71
|
-
<TouchableOpacity onPress={() => open ? setOpen(false) : handleOpen()} activeOpacity={0.8}>
|
|
72
|
-
<View ref={triggerRef}>
|
|
73
|
-
<SharpContainer
|
|
74
|
-
height={height}
|
|
75
|
-
bgColor={bgColor ?? colors.background.main}
|
|
76
|
-
borderColor={getBorderColor()}
|
|
77
|
-
>
|
|
78
|
-
<View style={{ flex: 1, flexDirection: "row", alignItems: "center", justifyContent: "space-between", paddingHorizontal: 16 }}>
|
|
79
|
-
<Text style={{
|
|
80
|
-
fontSize: textSize.sm,
|
|
81
|
-
fontFamily: Fonts.montserrat.regular,
|
|
82
|
-
color: selectedLabel ? colors.text.primary : colors.text.secondary,
|
|
83
|
-
}}>
|
|
84
|
-
{selectedLabel ?? placeholder}
|
|
85
|
-
</Text>
|
|
86
|
-
<Ionicons name={open ? "chevron-up" : "chevron-down"} size={16} color={colors.text.secondary} />
|
|
87
|
-
</View>
|
|
88
|
-
</SharpContainer>
|
|
89
|
-
</View>
|
|
90
|
-
</TouchableOpacity>
|
|
91
|
-
|
|
92
|
-
{error && <ErrorMessage message={error} />}
|
|
93
|
-
|
|
94
|
-
{/* Modal dropdown positioned below trigger */}
|
|
95
|
-
<Modal visible={open} transparent animationType="none">
|
|
96
|
-
{/* backdrop to close */}
|
|
97
|
-
<TouchableOpacity
|
|
98
|
-
style={{ flex: 1 }}
|
|
99
|
-
activeOpacity={1}
|
|
100
|
-
onPress={() => setOpen(false)}
|
|
101
|
-
>
|
|
102
|
-
<View style={{
|
|
103
|
-
position: "absolute",
|
|
104
|
-
top: dropdownPos.y + 4,
|
|
105
|
-
left: dropdownPos.x,
|
|
106
|
-
width: dropdownPos.width,
|
|
107
|
-
backgroundColor: bgColor ?? colors.background.card,
|
|
108
|
-
borderRadius: 10,
|
|
109
|
-
maxHeight: 220,
|
|
110
|
-
elevation: 10,
|
|
111
|
-
shadowColor: "#000",
|
|
112
|
-
shadowOffset: { width: 0, height: 4 },
|
|
113
|
-
shadowOpacity: 0.15,
|
|
114
|
-
shadowRadius: 6,
|
|
115
|
-
overflow: "hidden",
|
|
116
|
-
}}>
|
|
117
|
-
<ScrollView
|
|
118
|
-
bounces={false}
|
|
119
|
-
keyboardShouldPersistTaps="handled"
|
|
120
|
-
nestedScrollEnabled
|
|
121
|
-
>
|
|
122
|
-
{options.map((opt, index) => (
|
|
123
|
-
<TouchableOpacity
|
|
124
|
-
key={opt.value}
|
|
125
|
-
onPress={() => {
|
|
126
|
-
onChange(opt.value);
|
|
127
|
-
setOpen(false);
|
|
128
|
-
}}
|
|
129
|
-
style={{
|
|
130
|
-
paddingVertical: 14,
|
|
131
|
-
paddingHorizontal: 16,
|
|
132
|
-
flexDirection: "row",
|
|
133
|
-
alignItems: "center",
|
|
134
|
-
justifyContent: "space-between",
|
|
135
|
-
borderBottomWidth: index < options.length - 1 ? 1 : 0,
|
|
136
|
-
borderBottomColor: colors.background.main,
|
|
137
|
-
backgroundColor: opt.value === value ? colors.primary + "15" : "transparent",
|
|
138
|
-
}}
|
|
139
|
-
>
|
|
140
|
-
<Text style={{
|
|
141
|
-
fontSize: textSize.sm,
|
|
142
|
-
fontFamily: opt.value === value ? Fonts.montserrat.semiBold : Fonts.montserrat.regular,
|
|
143
|
-
color: opt.value === value ? colors.primary : colors.text.primary,
|
|
144
|
-
}}>
|
|
145
|
-
{opt.label}
|
|
146
|
-
</Text>
|
|
147
|
-
</TouchableOpacity>
|
|
148
|
-
))}
|
|
149
|
-
</ScrollView>
|
|
150
|
-
</View>
|
|
151
|
-
</TouchableOpacity>
|
|
152
|
-
</Modal>
|
|
153
|
-
</View>
|
|
154
|
-
);
|
|
155
|
-
}
|