@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@towsila/expo-ui-library",
3
- "version": "4.12.1",
3
+ "version": "4.13.0",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -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>
@@ -56,7 +56,7 @@ export default function ResetPasswordScreen({
56
56
  onBack={onBack}
57
57
  loading={form.loading}
58
58
  >
59
- <View style={{ marginTop: 20 }}>
59
+ <View style={{ marginTop: 20, gap: 20 }}>
60
60
  {includeOldPassword && (
61
61
  <Input
62
62
  label={oldPasswordLabel}
@@ -1,154 +1,237 @@
1
- import { TouchableOpacity, View, Text, Modal, Pressable, Animated } from "react-native";
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 { Dimensions } from "react-native";
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
- visible: boolean;
15
- onClose: () => void;
16
- logo: React.ReactNode;
17
- name?: string;
18
- menu: Menu[];
19
- onLogout: ()=>void;
20
- logoutLabel: string;
21
- onNavigate: (link: string) => void;
22
- themeLabel?:string;
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({logo, menu, onLogout, logoutLabel, onNavigate, visible, onClose, themeLabel}:AsideProps){
26
- const { language, setLanguage } = useLanguage();
27
- const {colors} = useAppTheme();
28
- const [activeIndex, setActiveIndex] = useState<number | null>(0);
29
- const slideAnim = useRef(new Animated.Value(-SIDEBAR_WIDTH)).current;
30
- const fadeAnim = useRef(new Animated.Value(0)).current;
31
- const {isRTL} = useLanguage();
32
- useEffect(() => {
33
- if (visible) {
34
- Animated.parallel([
35
- Animated.timing(slideAnim, {
36
- toValue: 0,
37
- duration: 250,
38
- useNativeDriver: true,
39
- }),
40
- Animated.timing(fadeAnim, {
41
- toValue: 1,
42
- duration: 250,
43
- useNativeDriver: true,
44
- }),
45
- ]).start();
46
- } else {
47
- Animated.parallel([
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
- {/* menu links */}
88
- <View style={{flex: 1, gap: 11}}>
89
- {menu.map((item, index) => {
90
- const isActive = activeIndex === index;
91
- return (
92
- <TouchableOpacity
93
- key={index}
94
- style={{
95
- flexDirection:align,
96
- alignItems: "center",
97
- gap: 12,
98
- paddingVertical: 14,
99
- paddingHorizontal: 16,
100
- borderRadius: 10,
101
- backgroundColor: isActive ? colors.primary + "20" : "transparent"
102
- }}
103
- onPress={() => {
104
- setActiveIndex(index);
105
- onNavigate(item.link);
106
- onClose();
107
- }}
108
- >
109
- {item.iconSvg && (
110
- <View style={[isRTL && {transform: [{ scaleX: -1 }]} ]}>
111
- {item.iconSvg(isActive ? colors.primary : "transparent")}
112
- </View>
113
- )}
114
- <Text style={{
115
- fontFamily: isActive ? Fonts.montserrat.semiBold : Fonts.montserrat.regular,
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
- {/* bottom container */}
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
- {/* Dimmed backdrop — full remaining width, tap to close */}
145
- <Animated.View style={{ flex: 1, opacity: fadeAnim }}>
146
- <Pressable
147
- style={{ flex: 1, backgroundColor: "rgba(0,0,0,0.5)" }}
148
- onPress={onClose}
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
- </Animated.View>
151
- </View>
152
- </Modal>
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
  }