@towsila/expo-ui-library 4.12.1 → 4.13.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.
package/package.json
CHANGED
|
@@ -58,12 +58,12 @@ export default function VerificationCodeScreen({
|
|
|
58
58
|
<View style={{marginTop:20}}>
|
|
59
59
|
<OtpInput length={4} onChange={setCode} size={70}/>
|
|
60
60
|
{count !== 0 ? (
|
|
61
|
-
<Text style={{ textAlign:align, color: colors.text.placeholder, fontSize: textSize.xs, fontFamily: Fonts.montserrat.regular}}>
|
|
61
|
+
<Text style={{ textAlign:align, color: colors.text.placeholder, fontSize: textSize.xs, fontFamily: Fonts.montserrat.regular, marginTop: 10}}>
|
|
62
62
|
{resendText}: {count} {unit}
|
|
63
63
|
</Text>
|
|
64
64
|
) : (
|
|
65
65
|
<TouchableOpacity onPress={handleResend}>
|
|
66
|
-
<Text style={{textAlign:align, color: colors.primary, fontSize: textSize.sm, fontFamily: Fonts.montserrat.regular }}>
|
|
66
|
+
<Text style={{textAlign:align, color: colors.primary, fontSize: textSize.sm, fontFamily: Fonts.montserrat.regular, marginTop: 10 }}>
|
|
67
67
|
{resendBtn}
|
|
68
68
|
</Text>
|
|
69
69
|
</TouchableOpacity>
|
|
@@ -1,154 +1,237 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
TouchableOpacity,
|
|
3
|
+
View,
|
|
4
|
+
Text,
|
|
5
|
+
Modal,
|
|
6
|
+
Pressable,
|
|
7
|
+
Animated,
|
|
8
|
+
useWindowDimensions,
|
|
9
|
+
} from "react-native";
|
|
2
10
|
import React, { useState, useEffect, useRef } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {Logout} from "@towsila/icons";
|
|
11
|
+
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
12
|
+
import { Logout } from "@towsila/icons";
|
|
5
13
|
import ThemeToggle from "./themeToggle";
|
|
6
14
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
7
15
|
import { useLanguage } from "../../context/LanguageContext";
|
|
8
16
|
import { Menu } from "../../types/menu";
|
|
9
17
|
import LanguageSelect from "./languageSelect";
|
|
10
18
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
11
|
-
const SIDEBAR_WIDTH = Dimensions.get("window").width * 0.7;
|
|
12
19
|
|
|
13
|
-
interface AsideProps{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
interface AsideProps {
|
|
21
|
+
visible: boolean;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
logo: React.ReactNode;
|
|
24
|
+
name?: string;
|
|
25
|
+
menu: Menu[];
|
|
26
|
+
onLogout: () => void;
|
|
27
|
+
logoutLabel: string;
|
|
28
|
+
onNavigate: (link: string) => void;
|
|
29
|
+
themeLabel?: string;
|
|
23
30
|
}
|
|
24
31
|
|
|
25
|
-
export default function AsideBar({
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
Animated.timing(slideAnim, {
|
|
49
|
-
toValue: -SIDEBAR_WIDTH,
|
|
50
|
-
duration: 200,
|
|
51
|
-
useNativeDriver: true,
|
|
52
|
-
}),
|
|
53
|
-
Animated.timing(fadeAnim, {
|
|
54
|
-
toValue: 0,
|
|
55
|
-
duration: 200,
|
|
56
|
-
useNativeDriver: true,
|
|
57
|
-
}),
|
|
58
|
-
]).start();
|
|
59
|
-
}
|
|
60
|
-
}, [visible]);
|
|
61
|
-
const align = isRTL ? "row-reverse":"row";
|
|
62
|
-
return(
|
|
63
|
-
<Modal visible={visible} transparent animationType="none" onRequestClose={onClose}>
|
|
64
|
-
<View style={{ flex: 1, flexDirection:align}}>
|
|
65
|
-
{/* Animated sidebar panel sliding from left */}
|
|
66
|
-
<Animated.View style={{
|
|
67
|
-
justifyContent: "space-between",
|
|
68
|
-
height: "100%",
|
|
69
|
-
width: isRTL ? SIDEBAR_WIDTH : -SIDEBAR_WIDTH,
|
|
70
|
-
backgroundColor: colors.background.main,
|
|
71
|
-
paddingHorizontal: 20,
|
|
72
|
-
paddingVertical:50,
|
|
73
|
-
transform: [{ translateX: slideAnim }],
|
|
74
|
-
}}>
|
|
75
|
-
{/* top container */}
|
|
76
|
-
<View style={{flex: 1, gap: 30}}>
|
|
77
|
-
{/* logo, name and language row */}
|
|
78
|
-
<View style={{flexDirection:align, alignItems:"center", justifyContent:"space-between"}}>
|
|
79
|
-
<View style={{flexDirection: align, alignItems: "center", gap: 6}}>
|
|
80
|
-
{logo}
|
|
81
|
-
</View>
|
|
82
|
-
<View>
|
|
83
|
-
<LanguageSelect value={language} onChange={setLanguage} />
|
|
84
|
-
</View>
|
|
85
|
-
</View>
|
|
32
|
+
export default function AsideBar({
|
|
33
|
+
logo,
|
|
34
|
+
menu,
|
|
35
|
+
onLogout,
|
|
36
|
+
logoutLabel,
|
|
37
|
+
onNavigate,
|
|
38
|
+
visible,
|
|
39
|
+
onClose,
|
|
40
|
+
themeLabel,
|
|
41
|
+
}: AsideProps) {
|
|
42
|
+
const { language, setLanguage } = useLanguage();
|
|
43
|
+
const { colors } = useAppTheme();
|
|
44
|
+
const { isRTL } = useLanguage();
|
|
45
|
+
const insets = useSafeAreaInsets();
|
|
46
|
+
const { width: screenWidth } = useWindowDimensions();
|
|
47
|
+
|
|
48
|
+
// ~80% of screen, capped at 400 for tablets
|
|
49
|
+
const SIDEBAR_WIDTH = Math.min(screenWidth * 0.8, 400);
|
|
50
|
+
|
|
51
|
+
const [activeIndex, setActiveIndex] = useState<number | null>(0);
|
|
52
|
+
|
|
53
|
+
const slideAnim = useRef(new Animated.Value(-SIDEBAR_WIDTH)).current;
|
|
54
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
86
55
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
fontSize: textSize.md,
|
|
117
|
-
color: isActive ? colors.primary : colors.text.primary,
|
|
118
|
-
flex:1
|
|
119
|
-
}}>
|
|
120
|
-
{item.name}
|
|
121
|
-
</Text>
|
|
122
|
-
</TouchableOpacity>
|
|
123
|
-
);
|
|
124
|
-
})}
|
|
125
|
-
</View>
|
|
126
|
-
</View>
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (visible) {
|
|
58
|
+
Animated.parallel([
|
|
59
|
+
Animated.timing(slideAnim, {
|
|
60
|
+
toValue: 0,
|
|
61
|
+
duration: 250,
|
|
62
|
+
useNativeDriver: true,
|
|
63
|
+
}),
|
|
64
|
+
Animated.timing(fadeAnim, {
|
|
65
|
+
toValue: 1,
|
|
66
|
+
duration: 250,
|
|
67
|
+
useNativeDriver: true,
|
|
68
|
+
}),
|
|
69
|
+
]).start();
|
|
70
|
+
} else {
|
|
71
|
+
Animated.parallel([
|
|
72
|
+
Animated.timing(slideAnim, {
|
|
73
|
+
toValue: -SIDEBAR_WIDTH,
|
|
74
|
+
duration: 200,
|
|
75
|
+
useNativeDriver: true,
|
|
76
|
+
}),
|
|
77
|
+
Animated.timing(fadeAnim, {
|
|
78
|
+
toValue: 0,
|
|
79
|
+
duration: 200,
|
|
80
|
+
useNativeDriver: true,
|
|
81
|
+
}),
|
|
82
|
+
]).start();
|
|
83
|
+
}
|
|
84
|
+
}, [visible]);
|
|
127
85
|
|
|
128
|
-
|
|
129
|
-
<View style={{ gap: 16, paddingHorizontal: 16, }}>
|
|
130
|
-
<TouchableOpacity onPress={onLogout} style={{ flexDirection:align, alignItems: "center", gap: 10 }}>
|
|
131
|
-
<Logout width={22} height={22} color={colors.semantic.error} style={[isRTL && {transform: [{scale:-1}]}]}/>
|
|
132
|
-
<Text style={{
|
|
133
|
-
fontFamily: Fonts.montserrat.regular,
|
|
134
|
-
fontSize: textSize.md,
|
|
135
|
-
color: colors.text.primary,
|
|
136
|
-
}}>
|
|
137
|
-
{logoutLabel}
|
|
138
|
-
</Text>
|
|
139
|
-
</TouchableOpacity>
|
|
140
|
-
<ThemeToggle label={themeLabel}/>
|
|
141
|
-
</View>
|
|
142
|
-
</Animated.View>
|
|
86
|
+
const align = isRTL ? "row-reverse" : "row";
|
|
143
87
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
88
|
+
return (
|
|
89
|
+
<Modal
|
|
90
|
+
visible={visible}
|
|
91
|
+
transparent
|
|
92
|
+
animationType="none"
|
|
93
|
+
onRequestClose={onClose}
|
|
94
|
+
statusBarTranslucent
|
|
95
|
+
>
|
|
96
|
+
<View style={{ flex: 1, flexDirection: align }}>
|
|
97
|
+
{/* Animated sidebar panel */}
|
|
98
|
+
<Animated.View
|
|
99
|
+
style={{
|
|
100
|
+
justifyContent: "space-between",
|
|
101
|
+
height: "100%",
|
|
102
|
+
width: SIDEBAR_WIDTH,
|
|
103
|
+
backgroundColor: colors.background.main,
|
|
104
|
+
paddingHorizontal: 20,
|
|
105
|
+
paddingTop: Math.max(insets.top, 20) + 20,
|
|
106
|
+
paddingBottom: Math.max(insets.bottom, 20),
|
|
107
|
+
transform: [{ translateX: slideAnim }],
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{/* top container */}
|
|
111
|
+
<View style={{ flex: 1, gap: 30 }}>
|
|
112
|
+
{/* logo, name and language row */}
|
|
113
|
+
<View
|
|
114
|
+
style={{
|
|
115
|
+
flexDirection: align,
|
|
116
|
+
alignItems: "center",
|
|
117
|
+
justifyContent: "space-between",
|
|
118
|
+
gap: 12,
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
{/* Logo takes remaining width, dropdown stays far side */}
|
|
122
|
+
<View
|
|
123
|
+
style={{
|
|
124
|
+
flexDirection: align,
|
|
125
|
+
alignItems: "center",
|
|
126
|
+
gap: 6,
|
|
127
|
+
flex: 1,
|
|
128
|
+
minWidth: 0,
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
{logo}
|
|
132
|
+
</View>
|
|
133
|
+
<View style={{ flexShrink: 0 }}>
|
|
134
|
+
<LanguageSelect value={language} onChange={setLanguage} />
|
|
135
|
+
</View>
|
|
136
|
+
</View>
|
|
137
|
+
|
|
138
|
+
{/* menu links */}
|
|
139
|
+
<View style={{ flex: 1, gap: 11 }}>
|
|
140
|
+
{menu.map((item, index) => {
|
|
141
|
+
const isActive = activeIndex === index;
|
|
142
|
+
return (
|
|
143
|
+
<TouchableOpacity
|
|
144
|
+
key={index}
|
|
145
|
+
style={{
|
|
146
|
+
flexDirection: align,
|
|
147
|
+
alignItems: "center",
|
|
148
|
+
gap: 12,
|
|
149
|
+
paddingVertical: 14,
|
|
150
|
+
paddingHorizontal: 16,
|
|
151
|
+
borderRadius: 10,
|
|
152
|
+
backgroundColor: isActive
|
|
153
|
+
? colors.primary + "40"
|
|
154
|
+
: "transparent",
|
|
155
|
+
}}
|
|
156
|
+
onPress={() => {
|
|
157
|
+
setActiveIndex(index);
|
|
158
|
+
onNavigate(item.link);
|
|
159
|
+
onClose();
|
|
160
|
+
}}
|
|
161
|
+
>
|
|
162
|
+
{item.iconSvg && (
|
|
163
|
+
<View
|
|
164
|
+
style={{
|
|
165
|
+
flexShrink: 0,
|
|
166
|
+
...(isRTL && { transform: [{ scaleX: -1 }] }),
|
|
167
|
+
}}
|
|
168
|
+
>
|
|
169
|
+
{item.iconSvg?.(
|
|
170
|
+
isActive ? colors.primary : colors.text.primary,
|
|
171
|
+
isActive
|
|
172
|
+
)}
|
|
173
|
+
</View>
|
|
174
|
+
)}
|
|
175
|
+
<Text
|
|
176
|
+
numberOfLines={1}
|
|
177
|
+
style={{
|
|
178
|
+
fontFamily: isActive
|
|
179
|
+
? Fonts.montserrat.semiBold
|
|
180
|
+
: Fonts.montserrat.regular,
|
|
181
|
+
fontSize: textSize.md,
|
|
182
|
+
color: isActive ? colors.primary : colors.text.primary,
|
|
183
|
+
flex: 1,
|
|
184
|
+
minWidth: 0,
|
|
185
|
+
textAlign: isRTL ? "right" : "left",
|
|
186
|
+
}}
|
|
187
|
+
>
|
|
188
|
+
{item.name}
|
|
189
|
+
</Text>
|
|
190
|
+
</TouchableOpacity>
|
|
191
|
+
);
|
|
192
|
+
})}
|
|
193
|
+
</View>
|
|
194
|
+
</View>
|
|
195
|
+
|
|
196
|
+
{/* bottom container */}
|
|
197
|
+
<View style={{ gap: 16, paddingHorizontal: 16 }}>
|
|
198
|
+
<TouchableOpacity
|
|
199
|
+
onPress={onLogout}
|
|
200
|
+
style={{ flexDirection: align, alignItems: "center", gap: 10 }}
|
|
201
|
+
>
|
|
202
|
+
<View style={{ flexShrink: 0 }}>
|
|
203
|
+
<Logout
|
|
204
|
+
width={22}
|
|
205
|
+
height={22}
|
|
206
|
+
color={colors.semantic.error}
|
|
207
|
+
style={isRTL ? { transform: [{ scaleX: -1 }] } : undefined}
|
|
149
208
|
/>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
209
|
+
</View>
|
|
210
|
+
<Text
|
|
211
|
+
numberOfLines={1}
|
|
212
|
+
style={{
|
|
213
|
+
flexShrink: 1,
|
|
214
|
+
minWidth: 0,
|
|
215
|
+
fontFamily: Fonts.montserrat.regular,
|
|
216
|
+
fontSize: textSize.md,
|
|
217
|
+
color: colors.text.primary,
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
{logoutLabel}
|
|
221
|
+
</Text>
|
|
222
|
+
</TouchableOpacity>
|
|
223
|
+
<ThemeToggle label={themeLabel} />
|
|
224
|
+
</View>
|
|
225
|
+
</Animated.View>
|
|
226
|
+
|
|
227
|
+
{/* Dimmed backdrop — full remaining width, tap to close */}
|
|
228
|
+
<Animated.View style={{ flex: 1, opacity: fadeAnim }}>
|
|
229
|
+
<Pressable
|
|
230
|
+
style={{ flex: 1, backgroundColor: "rgba(0,0,0,0.5)" }}
|
|
231
|
+
onPress={onClose}
|
|
232
|
+
/>
|
|
233
|
+
</Animated.View>
|
|
234
|
+
</View>
|
|
235
|
+
</Modal>
|
|
236
|
+
);
|
|
154
237
|
}
|
package/src/types/menu.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type Menu = {
|
|
|
4
4
|
key?: string,
|
|
5
5
|
icon?: keyof typeof Ionicons.glyphMap;
|
|
6
6
|
iconActive?: keyof typeof Ionicons.glyphMap;
|
|
7
|
-
iconSvg?: (color: string)=>React.ReactNode;
|
|
7
|
+
iconSvg?: (color: string, isActive?: boolean)=>React.ReactNode;
|
|
8
8
|
name: string;
|
|
9
9
|
link: string;
|
|
10
10
|
}
|