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