@towsila/expo-ui-library 2.7.2 → 3.0.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,5 +1,5 @@
|
|
|
1
1
|
import { Text, TouchableOpacity, View, StyleSheet, I18nManager, Pressable } from "react-native";
|
|
2
|
-
import {
|
|
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";
|
|
@@ -80,7 +80,7 @@ export default function OnBoarding({
|
|
|
80
80
|
<Text
|
|
81
81
|
style={[
|
|
82
82
|
styles.skipLabel,
|
|
83
|
-
{ color: colors.text.primary, textAlign: I18nManager.isRTL ? "
|
|
83
|
+
{ color: colors.text.primary, textAlign: I18nManager.isRTL ? "right" : "left" },
|
|
84
84
|
]}
|
|
85
85
|
>
|
|
86
86
|
{skipLabel}
|
|
@@ -91,7 +91,7 @@ export default function OnBoarding({
|
|
|
91
91
|
{/* ---------- Content ---------- */}
|
|
92
92
|
<View style={styles.content}>
|
|
93
93
|
{/* Image */}
|
|
94
|
-
<View style={styles.imageContainer}>
|
|
94
|
+
<View style={[styles.imageContainer, I18nManager.isRTL && { transform: [{ scaleX: -1 }] }]}>
|
|
95
95
|
{image}
|
|
96
96
|
</View>
|
|
97
97
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { View,
|
|
1
|
+
import { View, Text, I18nManager } from "react-native";
|
|
2
2
|
import Svg, { Circle } from "react-native-svg";
|
|
3
3
|
import { Fonts, textSize } from "../../tokens/typography";
|
|
4
4
|
|
|
@@ -22,13 +22,13 @@ export default function PageIndicator({
|
|
|
22
22
|
defaultColor,
|
|
23
23
|
}: Props) {
|
|
24
24
|
return (
|
|
25
|
-
<View style={{ alignItems: I18nManager.isRTL ? "flex-
|
|
25
|
+
<View style={{ alignItems: I18nManager.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
|
-
|
|
31
|
-
|
|
30
|
+
<View style={{ flexDirection: I18nManager.isRTL ? "row" : "row-reverse", gap: 8, width: "100%" }}>
|
|
31
|
+
{Array.from({ length: total }).map((_, index) => (
|
|
32
32
|
<View
|
|
33
33
|
key={index}
|
|
34
34
|
style={{
|
|
@@ -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
|
);
|