@towsila/expo-ui-library 4.11.5 → 4.12.0

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.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/src/components/reusable/templateSubPage.tsx +46 -31
  3. package/src/components/screens/AddReportScreen.tsx +55 -61
  4. package/src/components/screens/LegalScreen.tsx +27 -30
  5. package/src/components/screens/VerificationCodeScreen.tsx +4 -2
  6. package/src/components/screens/confirmDeleteScreen.tsx +81 -27
  7. package/src/components/screens/forgotPasswordScreen.tsx +15 -12
  8. package/src/components/screens/loginScreen.tsx +183 -79
  9. package/src/components/screens/onBoarding.tsx +98 -73
  10. package/src/components/screens/profileScreen.tsx +84 -32
  11. package/src/components/screens/resetPassword.tsx +3 -0
  12. package/src/components/screens/signUpScreen.tsx +98 -93
  13. package/src/components/screens/sucessScreen.tsx +75 -28
  14. package/src/components/ui/AnimatedSuccessIcon.tsx +15 -8
  15. package/src/components/ui/OTPInput.tsx +59 -17
  16. package/src/components/ui/PageTopBar.tsx +45 -33
  17. package/src/components/ui/customPopup.tsx +78 -86
  18. package/src/components/ui/dynamicForm.tsx +49 -18
  19. package/src/components/ui/input.tsx +102 -65
  20. package/src/components/ui/navigationCard.tsx +60 -47
  21. package/src/components/ui/pageIndicator.tsx +42 -18
  22. package/src/components/ui/requestCard.tsx +161 -105
  23. package/src/components/ui/requestCardSkeleton.tsx +38 -0
  24. package/src/components/ui/select.tsx +49 -33
  25. package/src/components/ui/sharpButton.tsx +37 -20
  26. package/src/components/ui/skeleton.tsx +38 -0
  27. package/src/components/ui/termsPopup.tsx +74 -45
  28. package/src/components/ui/textArea.tsx +37 -40
  29. package/src/components/ui/toast.tsx +49 -52
@@ -1,12 +1,19 @@
1
- import { View, Text, StyleSheet, Modal, Animated, Dimensions, ViewStyle } from "react-native";
1
+ import {
2
+ View,
3
+ Text,
4
+ StyleSheet,
5
+ Modal,
6
+ Animated,
7
+ useWindowDimensions,
8
+ ViewStyle,
9
+ } from "react-native";
2
10
  import { useEffect, useRef } from "react";
11
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
3
12
  import { Fonts, textSize } from "../../tokens/typography";
4
13
  import { useAppTheme } from "../../context/ThemeContext";
5
14
  import { useLanguage } from "../../context/LanguageContext";
6
15
  import SharpButton from "./sharpButton";
7
16
 
8
- const { height } = Dimensions.get("window");
9
-
10
17
  interface CustomPopUpProps {
11
18
  visible: boolean;
12
19
  title?: string;
@@ -18,9 +25,6 @@ interface CustomPopUpProps {
18
25
  agreeText?: string;
19
26
  agreeDisabled?: boolean;
20
27
  fontFamily?: string;
21
-
22
- // autoDismiss?: boolean;
23
- // dismissDelay?: number;
24
28
  }
25
29
 
26
30
  export default function CustomPopUp({
@@ -33,119 +37,107 @@ export default function CustomPopUp({
33
37
  closeText = "",
34
38
  agreeText = "",
35
39
  agreeDisabled = false,
36
- fontFamily= Fonts.montserrat.bold,
40
+ fontFamily = Fonts.montserrat.bold,
37
41
  }: CustomPopUpProps) {
38
42
  const { colors } = useAppTheme();
43
+ const { height } = useWindowDimensions(); // reactive to rotation
44
+ const insets = useSafeAreaInsets();
39
45
  const slideAnim = useRef(new Animated.Value(height)).current;
40
46
  const overlayAnim = useRef(new Animated.Value(0)).current;
41
47
 
42
48
  useEffect(() => {
43
- if (visible) {
44
- // animate IN
45
49
  Animated.parallel([
46
50
  Animated.timing(slideAnim, {
47
- toValue: 0,
48
- duration: 400,
51
+ toValue: visible ? 0 : height,
52
+ duration: visible ? 400 : 300,
49
53
  useNativeDriver: true,
50
54
  }),
51
55
  Animated.timing(overlayAnim, {
52
- toValue: 1,
53
- duration: 400,
56
+ toValue: visible ? 1 : 0,
57
+ duration: visible ? 400 : 300,
54
58
  useNativeDriver: true,
55
59
  }),
56
60
  ]).start();
57
- } else {
58
- // animate OUT
59
- Animated.parallel([
60
- Animated.timing(slideAnim, {
61
- toValue: height,
62
- duration: 300,
63
- useNativeDriver: true,
64
- }),
65
- Animated.timing(overlayAnim, {
66
- toValue: 0,
67
- duration: 300,
68
- useNativeDriver: true,
69
- }),
70
- ]).start();
71
- }
72
- }, [visible]);
61
+ }, [visible, height]);
73
62
 
63
+ // Buttons only need to *request* dismissal — the effect handles the animation.
64
+ const handleAgree = () => onAgree?.();
65
+ const handleClose = () => onClose?.();
74
66
 
75
- const handleAgree = () => {
76
- Animated.parallel([
77
- Animated.timing(slideAnim, { toValue: height, duration: 300, useNativeDriver: true }),
78
- Animated.timing(overlayAnim, { toValue: 0, duration: 300, useNativeDriver: true }),
79
- ]).start(() => {
80
- onAgree ? onAgree() : undefined
81
- }); // call onAgree AFTER animation finishes
82
- };
83
- const handleClose = () => {
84
- Animated.parallel([
85
- Animated.timing(slideAnim, {toValue: height, duration: 300,useNativeDriver: true,
86
- }),
87
- Animated.timing(overlayAnim, {toValue: 0,duration: 300,useNativeDriver: true,
88
- }),
89
- ]).start(() => {
90
- onClose ? onClose(): undefined
91
- });
92
- };
93
-
94
-
95
- const {isRTL} = useLanguage();
67
+ const { isRTL } = useLanguage();
96
68
 
97
69
  return (
98
70
  <Modal
99
71
  visible={visible}
100
72
  transparent
101
- animationType="none" // we handle animation manually
73
+ animationType="none"
102
74
  statusBarTranslucent
75
+ onRequestClose={handleClose} // Android back button
103
76
  >
104
- {/* overlay */}
105
- <Animated.View style={[styles.overlay, { opacity: overlayAnim }]} />
77
+ <Animated.View
78
+ style={[styles.overlay, { opacity: overlayAnim }]}
79
+ pointerEvents="none"
80
+ />
106
81
 
107
- {/* sheet */}
108
82
  <Animated.View
109
83
  style={[
110
84
  styles.sheetWrapper,
111
- { transform: [{ translateY: slideAnim }], paddingHorizontal: 10 },
85
+ {
86
+ transform: [{ translateY: slideAnim }],
87
+ paddingHorizontal: 10,
88
+ },
112
89
  ]}
113
90
  >
114
- <View style={[styles.container, { backgroundColor: colors.background.main }]}>
115
- {/* handle bar */}
116
- <View style={[styles.handle, { backgroundColor: colors.text.placeholder }]} />
91
+ <View
92
+ style={[
93
+ styles.container,
94
+ {
95
+ backgroundColor: colors.background.main,
96
+ paddingBottom: insets.bottom + 16, // safe area, not hardcoded 40
97
+ },
98
+ ]}
99
+ >
100
+ <View
101
+ style={[styles.handle, { backgroundColor: colors.text.placeholder }]}
102
+ />
117
103
 
118
- <Text style={{
119
- fontFamily,
120
- fontSize: textSize.xxl,
121
- color: colors.text.primary,
122
- marginBottom: 10,
123
- textAlign:isRTL ? "right" :"left"
124
- }}>
125
- {title}
126
- </Text>
104
+ {title && (
105
+ <Text
106
+ style={{
107
+ fontFamily,
108
+ fontSize: textSize.xxl,
109
+ color: colors.text.primary,
110
+ marginBottom: 10,
111
+ textAlign: isRTL ? "right" : "left",
112
+ }}
113
+ >
114
+ {title}
115
+ </Text>
116
+ )}
127
117
 
128
118
  {header && <View style={{ marginBottom: 10 }}>{header}</View>}
129
119
  <View style={{ marginBottom: 20 }}>{body}</View>
130
120
 
131
121
  <View style={{ gap: 8, width: "100%", marginTop: 20 }}>
132
- {agreeText && <SharpButton
133
- text={agreeText}
134
- onPress={handleAgree}
135
- bgColor={colors.primary}
136
- fontSize={textSize.sm}
137
- height={50}
138
- />}
139
- {closeText ? (
140
- <SharpButton
141
- text={closeText}
142
- onPress={handleClose}
143
- bgColor={colors.primary}
144
- fontSize={textSize.sm}
145
- height={50}
146
- />
147
- ) : null}
148
- </View>
122
+ {agreeText && (
123
+ <SharpButton
124
+ text={agreeText}
125
+ onPress={handleAgree}
126
+ bgColor={colors.primary}
127
+ fontSize={textSize.sm}
128
+ height={50}
129
+ />
130
+ )}
131
+ {closeText ? (
132
+ <SharpButton
133
+ text={closeText}
134
+ onPress={handleClose}
135
+ bgColor={colors.primary}
136
+ fontSize={textSize.sm}
137
+ height={50}
138
+ />
139
+ ) : null}
140
+ </View>
149
141
  </View>
150
142
  </Animated.View>
151
143
  </Modal>
@@ -165,13 +157,13 @@ const styles = StyleSheet.create({
165
157
  borderTopLeftRadius: 24,
166
158
  borderTopRightRadius: 24,
167
159
  padding: 24,
168
- paddingBottom: 40,
160
+ // paddingBottom comes from insets at render
169
161
  },
170
162
  handle: {
171
163
  width: 40,
172
164
  height: 4,
173
165
  borderRadius: 2,
174
166
  alignSelf: "center",
175
- marginBottom: 0,
167
+ marginBottom: 16, // was 0 — now the title isn't glued to the bar
176
168
  },
177
169
  });
@@ -1,5 +1,5 @@
1
1
  import { useState } from "react";
2
- import { View } from "react-native";
2
+ import { View, useWindowDimensions } from "react-native";
3
3
  import { Field } from "../../types/formFields";
4
4
  import Input from "./input";
5
5
 
@@ -27,6 +27,10 @@ export const DynamicForm: React.FC<Props> = ({
27
27
  translator,
28
28
  }) => {
29
29
  const [showPasswordField, setShowPasswordField] = useState<Record<string, boolean>>({});
30
+ const { width } = useWindowDimensions();
31
+
32
+ // On narrow screens, never put two fields in a row — even grouped ones
33
+ const forceStacked = width < 360;
30
34
 
31
35
  // Group consecutive fields that share the same `key`
32
36
  const groups = fields.reduce<KeyedField[][]>((acc, field) => {
@@ -39,44 +43,71 @@ export const DynamicForm: React.FC<Props> = ({
39
43
  return acc;
40
44
  }, []);
41
45
 
42
- const renderField = (field: KeyedField) => (
46
+ // Index of the last field overall — used to pick returnKeyType
47
+ const lastFieldIndex = fields.length - 1;
48
+
49
+ const renderField = (field: KeyedField, indexInFields: number) => (
43
50
  <Input
44
51
  value={formState[field.name] || ""}
45
52
  onChangeText={(text) => setFormState((prev) => ({ ...prev, [field.name]: text }))}
46
53
  iconLeft={field.icon}
47
54
  iconRight={
48
55
  field.secureTextEntry
49
- ? showPasswordField[field.name] ? "eye-off-outline" : "eye-outline"
56
+ ? showPasswordField[field.name]
57
+ ? "eye-off-outline"
58
+ : "eye-outline"
50
59
  : undefined
51
60
  }
52
61
  placeholder={field.placeholder}
53
62
  onPressIconRight={
54
63
  field.secureTextEntry
55
- ? () => setShowPasswordField((prev) => ({ ...prev, [field.name]: !prev[field.name] }))
64
+ ? () =>
65
+ setShowPasswordField((prev) => ({
66
+ ...prev,
67
+ [field.name]: !prev[field.name],
68
+ }))
56
69
  : undefined
57
70
  }
58
71
  secureTextEntry={field.secureTextEntry && !showPasswordField[field.name]}
59
- returnKeyType="next"
72
+ // Last field → "done", everyone else → "next"
73
+ returnKeyType={indexInFields === lastFieldIndex ? "done" : "next"}
60
74
  error={errors[field.name] ? translator?.(errors[field.name]) : ""}
61
75
  onClearError={() => clearError(field.name)}
62
76
  label={field.label}
77
+ keyboardType={(field as any).keyboardType}
78
+ autoComplete={(field as any).autoComplete}
79
+ textContentType={(field as any).textContentType}
80
+ autoCapitalize={(field as any).autoCapitalize}
63
81
  />
64
82
  );
65
83
 
84
+ let fieldCursor = 0;
85
+
66
86
  return (
67
- <View style={{ gap: 4 }}>
68
- {groups.map((group) => (
69
- <View
70
- key={group.map((f) => f.name).join("-")}
71
- style={{ flexDirection: "row", gap: 10, marginBottom: 10 }}
72
- >
73
- {group.map((field) => (
74
- <View key={field.name} style={{ flex: 1, minWidth: 0 }}>
75
- {renderField(field)}
76
- </View>
77
- ))}
78
- </View>
79
- ))}
87
+ <View style={{ gap: 12 }}>
88
+ {groups.map((group) => {
89
+ const startIndex = fieldCursor;
90
+ fieldCursor += group.length;
91
+ const isRow = !forceStacked && group.length > 1;
92
+ return (
93
+ <View
94
+ key={group.map((f) => f.name).join("-")}
95
+ style={{
96
+ flexDirection: isRow ? "row" : "column",
97
+ gap: 10,
98
+ }}
99
+ >
100
+ {group.map((field, i) => (
101
+ <View
102
+ key={field.name}
103
+ style={{ flex: isRow ? 1 : undefined, minWidth: 0 }}
104
+ >
105
+ {renderField(field, startIndex + i)}
106
+ </View>
107
+ ))}
108
+ </View>
109
+ );
110
+ })}
80
111
  </View>
81
112
  );
82
113
  };
@@ -1,26 +1,37 @@
1
1
  import React, { useState, ComponentProps } from "react";
2
- import { StyleProp, StyleSheet, Text, TextInput, TextInputProps, View, ViewProps } from "react-native";
2
+ import {
3
+ StyleProp,
4
+ StyleSheet,
5
+ Text,
6
+ TextInput,
7
+ TextInputProps,
8
+ View,
9
+ ViewStyle,
10
+ Platform,
11
+ } from "react-native";
3
12
  import { Ionicons } from "@expo/vector-icons";
4
13
  import { Fonts, textSize } from "../../tokens/typography";
5
14
  import { useAppTheme } from "../../context/ThemeContext";
6
15
  import { useLanguage } from "../../context/LanguageContext";
7
16
  import ErrorMessage from "./error";
17
+
8
18
  interface InputProps extends TextInputProps {
9
19
  value: string;
10
20
  onChangeText: (text: string) => void;
11
21
  placeholder: string;
12
- iconLeft?: ComponentProps<typeof Ionicons>["name"] ;
13
- iconRight?: ComponentProps<typeof Ionicons>["name"] ;
22
+ iconLeft?: ComponentProps<typeof Ionicons>["name"];
23
+ iconRight?: ComponentProps<typeof Ionicons>["name"];
14
24
  onPressIconRight?: () => void;
15
25
  error?: string;
16
- label?:string;
26
+ label?: string;
17
27
  onClearError: () => void;
18
- style?: StyleProp<ViewProps>;
28
+ style?: StyleProp<ViewStyle>;
19
29
  labelFontFamily?: string;
20
30
  textFontFamily?: string;
21
31
  prefix?: React.ReactNode;
22
- bgColor?:string;
23
- borderColor?:string;
32
+ bgColor?: string;
33
+ borderColor?: string;
34
+ height?: number;
24
35
  }
25
36
 
26
37
  export default function Input({
@@ -39,54 +50,71 @@ export default function Input({
39
50
  prefix,
40
51
  bgColor,
41
52
  borderColor,
53
+ height = 52,
42
54
  ...rest
43
55
  }: InputProps) {
44
56
  const { colors } = useAppTheme();
45
57
  const [focused, setFocused] = useState(false);
46
- const {isRTL} = useLanguage();
58
+ const { isRTL } = useLanguage();
47
59
  const [prefixW, setPrefixW] = useState(0);
48
- const align = isRTL ? "right" :"left"
60
+ const align = isRTL ? "right" : "left";
61
+
49
62
  return (
50
- <View style={[style, {marginBottom: 4}]}>
51
- {label && (
52
- <Text style={{
53
- color: colors.text.primary,
54
- fontSize: textSize.xs,
55
- fontFamily: labelFontFamily,
56
- marginBottom: 6,
57
- textAlign: align
58
- }}>
63
+ <View style={[style, { marginBottom: 4 }]}>
64
+ {label && (
65
+ <Text
66
+ style={{
67
+ color: colors.text.primary,
68
+ fontSize: textSize.xs,
69
+ fontFamily: labelFontFamily,
70
+ marginBottom: 6,
71
+ textAlign: align,
72
+ }}
73
+ >
59
74
  {label}
60
75
  </Text>
61
76
  )}
62
- <View style={{position: "relative"}}>
63
- {/* icon left */}
77
+
78
+ <View style={{ position: "relative" }}>
79
+ {/* icon left — vertically centered via wrapper, scales with field height */}
64
80
  {iconLeft && (
65
- <Ionicons
66
- name={iconLeft}
67
- size={18}
68
- color={error ? colors.semantic.error : focused ? colors.primary : colors.text.secondary}
69
- style={{
70
- position: "absolute",
71
- [align]: 14,
72
- top: "50%",
73
- transform: [{ translateY: -9 }],
74
- zIndex: 1,
81
+ <View
82
+ pointerEvents="none"
83
+ style={{
84
+ position: "absolute",
85
+ [align]: 14,
86
+ top: 0,
87
+ bottom: 0,
88
+ justifyContent: "center",
89
+ zIndex: 1,
75
90
  }}
76
- />
91
+ >
92
+ <Ionicons
93
+ name={iconLeft}
94
+ size={18}
95
+ color={
96
+ error
97
+ ? colors.semantic.error
98
+ : focused
99
+ ? colors.primary
100
+ : colors.text.secondary
101
+ }
102
+ />
103
+ </View>
77
104
  )}
105
+
78
106
  {prefix && (
79
- <View
80
- onLayout={(e) => setPrefixW(e.nativeEvent.layout.width)}
81
- style={[
82
- styles.prefix,
83
- { [align]: 0, flexDirection: isRTL?"row-reverse":"row", },
84
- ]}
85
- >
86
- {prefix}
87
- </View>
107
+ <View
108
+ onLayout={(e) => setPrefixW(e.nativeEvent.layout.width)}
109
+ style={[
110
+ styles.prefix,
111
+ { [align]: 0, flexDirection: isRTL ? "row-reverse" : "row" },
112
+ ]}
113
+ >
114
+ {prefix}
115
+ </View>
88
116
  )}
89
- {/* input */}
117
+
90
118
  <TextInput
91
119
  value={value}
92
120
  onChangeText={(text) => {
@@ -98,10 +126,11 @@ export default function Input({
98
126
  onFocus={() => {
99
127
  setFocused(true);
100
128
  if (error) onClearError?.();
101
- }}
129
+ }}
102
130
  onBlur={() => setFocused(false)}
103
131
  style={{
104
- height: 50,
132
+ // minHeight, not height — grows if user has large system font
133
+ minHeight: height,
105
134
  borderRadius: 10,
106
135
  fontSize: textSize.sm,
107
136
  backgroundColor: bgColor ?? colors.background.card,
@@ -111,38 +140,45 @@ export default function Input({
111
140
  direction: isRTL ? "rtl" : "ltr",
112
141
  textAlign: align,
113
142
 
143
+ // vertical padding so multiline / large fonts aren't cramped
144
+ paddingVertical: Platform.OS === "ios" ? 12 : 8,
145
+
114
146
  paddingStart: prefix ? prefixW + 10 : iconLeft ? 42 : 16,
115
147
  paddingEnd: iconRight ? 42 : 16,
116
148
 
117
149
  borderColor: error
118
- ? colors.semantic.error
119
- : focused
120
- ? colors.primary
121
- : borderColor ?? colors.text.primary,
150
+ ? colors.semantic.error
151
+ : focused
152
+ ? colors.primary
153
+ : borderColor ?? colors.text.primary,
122
154
  borderWidth: error ? 1.5 : focused ? 1.5 : 1,
123
- }}
155
+ }}
124
156
  {...rest}
125
157
  />
158
+
126
159
  {/* icon right */}
127
160
  {iconRight && (
128
- <Ionicons
129
- name={iconRight}
130
- size={18}
131
- color={colors.text.secondary}
132
- onPress={onPressIconRight}
161
+ <View
133
162
  style={{
134
- position: "absolute",
135
- [isRTL ? "left" : "right"]: 14,
136
- top: "50%",
137
- transform: [{ translateY: -9 }],
138
- zIndex: 1,
139
- }}
140
- />
163
+ position: "absolute",
164
+ [isRTL ? "left" : "right"]: 14,
165
+ top: 0,
166
+ bottom: 0,
167
+ justifyContent: "center",
168
+ zIndex: 1,
169
+ }}
170
+ >
171
+ <Ionicons
172
+ name={iconRight}
173
+ size={18}
174
+ color={colors.text.secondary}
175
+ onPress={onPressIconRight}
176
+ />
177
+ </View>
141
178
  )}
142
179
  </View>
143
- {error && (
144
- <ErrorMessage message={error} position={align}/>
145
- )}
180
+
181
+ {error && <ErrorMessage message={error} position={align} />}
146
182
  </View>
147
183
  );
148
184
  }
@@ -151,8 +187,9 @@ const styles = StyleSheet.create({
151
187
  prefix: {
152
188
  position: "absolute",
153
189
  top: 0,
154
- height: 50,
190
+ bottom: 0, // was: height: 50 (broken if height prop changes)
155
191
  zIndex: 1,
156
192
  alignItems: "center",
193
+ justifyContent: "center",
157
194
  },
158
- });
195
+ });