@towsila/expo-ui-library 2.7.3 → 3.0.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,9 +1,10 @@
|
|
|
1
|
-
import { Text, TouchableOpacity, View, StyleSheet
|
|
1
|
+
import { Text, TouchableOpacity, View, StyleSheet } from "react-native";
|
|
2
2
|
import { ArrowBack} from "@towsila/icons";
|
|
3
3
|
import { useAppTheme } from "../../context/ThemeContext";
|
|
4
4
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
5
5
|
import PageIndicator from "../ui/pageIndicator";
|
|
6
6
|
import SharpButton from "../ui/sharpButton";
|
|
7
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
7
8
|
|
|
8
9
|
interface OnBoardingProps {
|
|
9
10
|
onSkip: () => void;
|
|
@@ -33,7 +34,7 @@ export default function OnBoarding({
|
|
|
33
34
|
stepsLabel,
|
|
34
35
|
}: OnBoardingProps) {
|
|
35
36
|
const { colors } = useAppTheme();
|
|
36
|
-
|
|
37
|
+
const {isRTL} = useLanguage();
|
|
37
38
|
return (
|
|
38
39
|
<View
|
|
39
40
|
style={[
|
|
@@ -46,15 +47,11 @@ export default function OnBoarding({
|
|
|
46
47
|
<View style={{ height: 44, flexDirection: "row", alignItems: "center", gap: 15}}>
|
|
47
48
|
<TouchableOpacity onPress={onBack} disabled={!onBack}
|
|
48
49
|
style={{
|
|
49
|
-
// position: "absolute",
|
|
50
|
-
// left: I18nManager.isRTL ? undefined : 0,
|
|
51
|
-
// right: I18nManager.isRTL ? 0 : undefined,
|
|
52
50
|
borderWidth: 1,
|
|
53
51
|
borderColor: colors.text.primary,
|
|
54
52
|
borderRadius: 100,
|
|
55
53
|
paddingVertical: 11,
|
|
56
54
|
paddingHorizontal: 11,
|
|
57
|
-
// zIndex: 1,
|
|
58
55
|
opacity: onBack ? 1: 0.5
|
|
59
56
|
}}
|
|
60
57
|
>
|
|
@@ -62,7 +59,7 @@ export default function OnBoarding({
|
|
|
62
59
|
width={19}
|
|
63
60
|
height={19}
|
|
64
61
|
color={colors.text.primary}
|
|
65
|
-
style={
|
|
62
|
+
style={isRTL && { transform: [{ scaleX: -1 }] }}
|
|
66
63
|
/>
|
|
67
64
|
</TouchableOpacity>
|
|
68
65
|
|
|
@@ -80,7 +77,7 @@ export default function OnBoarding({
|
|
|
80
77
|
<Text
|
|
81
78
|
style={[
|
|
82
79
|
styles.skipLabel,
|
|
83
|
-
{ color: colors.text.primary, textAlign:
|
|
80
|
+
{ color: colors.text.primary, textAlign: isRTL ? "right" : "left" },
|
|
84
81
|
]}
|
|
85
82
|
>
|
|
86
83
|
{skipLabel}
|
|
@@ -91,7 +88,7 @@ export default function OnBoarding({
|
|
|
91
88
|
{/* ---------- Content ---------- */}
|
|
92
89
|
<View style={styles.content}>
|
|
93
90
|
{/* Image */}
|
|
94
|
-
<View style={[styles.imageContainer,
|
|
91
|
+
<View style={[styles.imageContainer,isRTL && { transform: [{ scaleX: -1 }] }]}>
|
|
95
92
|
{image}
|
|
96
93
|
</View>
|
|
97
94
|
|
|
@@ -109,7 +106,7 @@ export default function OnBoarding({
|
|
|
109
106
|
<Text
|
|
110
107
|
style={[
|
|
111
108
|
styles.description,
|
|
112
|
-
{ color: colors.text.secondary },
|
|
109
|
+
{ color: colors.text.secondary,textAlign: isRTL ? "right" : "left", },
|
|
113
110
|
]}
|
|
114
111
|
>
|
|
115
112
|
{description}
|
|
@@ -153,7 +150,6 @@ const styles = StyleSheet.create({
|
|
|
153
150
|
description: {
|
|
154
151
|
fontSize: textSize.sm,
|
|
155
152
|
fontFamily: Fonts.montserrat.regular,
|
|
156
|
-
textAlign: I18nManager.isRTL ? "right" : "left",
|
|
157
153
|
},
|
|
158
154
|
|
|
159
155
|
indicatorContainer: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { View, Text
|
|
2
|
-
import Svg, { Circle } from "react-native-svg";
|
|
1
|
+
import { View, Text } from "react-native";
|
|
3
2
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
3
|
+
import { useLanguage } from "../../context/LanguageContext";
|
|
4
4
|
|
|
5
5
|
type Props = {
|
|
6
6
|
stepsLabel?: string;
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const BAR_HEIGHT = 6;
|
|
15
|
-
|
|
15
|
+
const {isRTL} = useLanguage();
|
|
16
16
|
export default function PageIndicator({
|
|
17
17
|
stepsLabel="Steps",
|
|
18
18
|
total = 3,
|
|
@@ -22,12 +22,12 @@ export default function PageIndicator({
|
|
|
22
22
|
defaultColor,
|
|
23
23
|
}: Props) {
|
|
24
24
|
return (
|
|
25
|
-
<View style={{ alignItems:
|
|
25
|
+
<View style={{ alignItems: isRTL ? "flex-start" : "flex-end", gap: 15, width: "100%" }}>
|
|
26
26
|
<Text style={{ color: textColor, fontSize: textSize.md, fontFamily: Fonts.montserrat.semiBold }}>
|
|
27
27
|
{stepsLabel}
|
|
28
28
|
</Text>
|
|
29
29
|
|
|
30
|
-
<View style={{ flexDirection:
|
|
30
|
+
<View style={{ flexDirection: isRTL ? "row" : "row-reverse", gap: 8, width: "100%" }}>
|
|
31
31
|
{Array.from({ length: total }).map((_, index) => (
|
|
32
32
|
<View
|
|
33
33
|
key={index}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import React, { createContext, useContext, useEffect, useState } from "react";
|
|
2
2
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
3
|
-
import { I18nManager } from "react-native";
|
|
4
|
-
import * as Updates from "expo-updates";
|
|
5
3
|
const LANGUAGE_KEY = "app_language_preference";
|
|
6
4
|
const RTL_LANGUAGES: Language[] = ["ar"];
|
|
7
5
|
|
|
@@ -11,17 +9,16 @@ type LanguageContextValue = {
|
|
|
11
9
|
language: Language;
|
|
12
10
|
setLanguage: (lang: Language) => void;
|
|
13
11
|
isLoaded: boolean;
|
|
12
|
+
isRTL: boolean;
|
|
14
13
|
};
|
|
15
14
|
|
|
16
15
|
const LanguageContext = createContext<LanguageContextValue | null>(null);
|
|
17
16
|
|
|
18
17
|
export function LanguageProvider({
|
|
19
18
|
defaultLanguage = "en",
|
|
20
|
-
onBeforeReload,
|
|
21
19
|
children,
|
|
22
20
|
}: {
|
|
23
21
|
defaultLanguage?: Language;
|
|
24
|
-
onBeforeReload?: () => void;
|
|
25
22
|
children: React.ReactNode;
|
|
26
23
|
}) {
|
|
27
24
|
const [language, setLanguageState] = useState<Language>(defaultLanguage);
|
|
@@ -31,12 +28,6 @@ export function LanguageProvider({
|
|
|
31
28
|
AsyncStorage.getItem(LANGUAGE_KEY).then((saved) => {
|
|
32
29
|
if (saved === "en" || saved === "fr" || saved === "ar") {
|
|
33
30
|
setLanguageState(saved);
|
|
34
|
-
|
|
35
|
-
const shouldBeRTL = RTL_LANGUAGES.includes(saved);
|
|
36
|
-
if (I18nManager.isRTL !== shouldBeRTL) {
|
|
37
|
-
I18nManager.allowRTL(shouldBeRTL);
|
|
38
|
-
I18nManager.forceRTL(shouldBeRTL);
|
|
39
|
-
}
|
|
40
31
|
}
|
|
41
32
|
setIsLoaded(true);
|
|
42
33
|
});
|
|
@@ -46,17 +37,12 @@ export function LanguageProvider({
|
|
|
46
37
|
setLanguageState(lang);
|
|
47
38
|
await AsyncStorage.setItem(LANGUAGE_KEY, lang);
|
|
48
39
|
|
|
49
|
-
const shouldBeRTL = RTL_LANGUAGES.includes(lang);
|
|
50
|
-
if (I18nManager.isRTL !== shouldBeRTL) {
|
|
51
|
-
onBeforeReload?.();
|
|
52
|
-
I18nManager.allowRTL(shouldBeRTL);
|
|
53
|
-
I18nManager.forceRTL(shouldBeRTL);
|
|
54
|
-
await Updates.reloadAsync();
|
|
55
|
-
}
|
|
56
40
|
};
|
|
57
41
|
|
|
42
|
+
const isRTL = RTL_LANGUAGES.includes(language);
|
|
43
|
+
|
|
58
44
|
return (
|
|
59
|
-
<LanguageContext.Provider value={{ language, setLanguage, isLoaded }}>
|
|
45
|
+
<LanguageContext.Provider value={{ language, setLanguage, isLoaded, isRTL}}>
|
|
60
46
|
{children}
|
|
61
47
|
</LanguageContext.Provider>
|
|
62
48
|
);
|