Skip to content

Commit

Permalink
fix: removed unnesaccary states + fixed RTL problems
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadmansour200 committed Jul 24, 2024
1 parent 1a83aa5 commit 1f90adb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
5 changes: 2 additions & 3 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ import LightTheme from "./src/themes/LightTheme";
import "./i18n";
import OnBoardDialog from "./src/components/OnBoardModal";

I18nManager.allowRTL(false);
I18nManager.forceRTL(false);

const Stack = createNativeStackNavigator();

function App() {
const { colors } = useTheme();
const { isVisible, theme } = useSettingsModalStore();
const defaultColorScheme = useColorScheme();
I18nManager.allowRTL(false);
I18nManager.forceRTL(false);

const systemColorSheme =
defaultColorScheme === "dark" ? DarkTheme : LightTheme;
Expand Down
6 changes: 5 additions & 1 deletion src/components/OnBoardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ function OnBoardDialog() {
>
<Pressable
android_ripple={{ color: colors.text, borderless: true }}
style={{ alignSelf: "flex-end" }}
style={{
alignSelf: "flex-end",
marginHorizontal: 5,
marginTop: 5,
}}
onPress={hideModal}
>
<CloseIcon />
Expand Down
13 changes: 5 additions & 8 deletions src/components/SettingsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import AsyncStorage from "@react-native-async-storage/async-storage";
import { Picker } from "@react-native-picker/picker";
import { useTheme } from "@react-navigation/native";
import { useEffect, useState } from "react";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";
import {
Modal,
Expand All @@ -20,14 +20,10 @@ function SettingsModal() {
const { isVisible, setIsVisible, theme, setTheme } = useSettingsModalStore();
const colors = useTheme().colors;
const { t, i18n } = useTranslation();
const [language, setLanguage] = useState(
i18n.language.split("-")[0].toString(),
);

useEffect(() => {
async function setLanguageOnMount() {
const language = await AsyncStorage.getItem("i18nextLng");
setLanguage(language || "en");
i18n.changeLanguage(language || "en");
}
setLanguageOnMount();
Expand Down Expand Up @@ -57,7 +53,7 @@ function SettingsModal() {
>
<Pressable
android_ripple={{ color: colors.text, borderless: true }}
style={{ alignSelf: "flex-end" }}
style={{ alignSelf: "flex-end", marginHorizontal: 5, marginTop: 5 }}
onPress={() => setIsVisible(false)}
>
<CloseIcon />
Expand Down Expand Up @@ -91,10 +87,11 @@ function SettingsModal() {
<Picker
style={{ color: colors.text }}
dropdownIconColor={colors.text}
selectedValue={language}
selectedValue={i18n.language.split("-")[0].toString()}
onValueChange={async (value) => {
await AsyncStorage.setItem("i18nextLng", value);
setLanguage(value);
i18n.changeLanguage(value);

ToastAndroid.show(
t("header.reloadToast"),
ToastAndroid.SHORT,
Expand Down

0 comments on commit 1f90adb

Please sign in to comment.