You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.4 KiB

import { View, Text, StyleSheet, TouchableOpacity, SafeAreaView, StatusBar, Platform } from "react-native";
1 month ago
import BackIcon from "../../components/BackIcon";
import fontSize from "../../utils/fontsizeUtils";
import LeftArrowIcon from "../../components/DownArrowIcon";
import { useNavigation } from "@react-navigation/native";
import { NativeStackNavigationProp } from "@react-navigation/native-stack";
import { useState, useEffect } from "react";
import { settingApi, MySetting } from "../../services/api/setting";
import { RootStackParamList } from "../../navigation/types";
import { eventBus } from "../../utils/eventBus";
4 weeks ago
import AsyncStorage from '@react-native-async-storage/async-storage';
3 weeks ago
import { useTranslation } from "react-i18next";
1 month ago
export const SettingList = () => {
3 weeks ago
const { t } = useTranslation();
1 month ago
const [mySetting, setMySetting] = useState<MySetting>();
const getMySetting = async () => {
const res = await settingApi.getMySetting()
console.log("MySetting:");
1 month ago
console.log(res);
setMySetting(res);
}
useEffect(() => {
getMySetting();
const refreshSetting = () => {
getMySetting();
}
eventBus.on("refreshSetting", refreshSetting);
return () => {
eventBus.off("refreshSetting", refreshSetting);
};
}, []);
const navigation =
useNavigation<NativeStackNavigationProp<RootStackParamList>>();
return (
<SafeAreaView style={styles.safeArea}>
<StatusBar barStyle="dark-content" backgroundColor="#fff" />
<View style={styles.safeAreaContent}>
<View style={styles.header}>
<TouchableOpacity
onPress={() => navigation.goBack()}
1 month ago
>
<BackIcon size={fontSize(24)} />
</TouchableOpacity>
3 weeks ago
<Text style={styles.headerTitle}>{t("settings.title")}</Text>
<View style={styles.placeholder} />
</View>
<View style={styles.content}>
<View style={styles.item}>
3 weeks ago
<Text>{t("settings.profile")}</Text>
1 month ago
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</View>
<View style={styles.item}>
3 weeks ago
<Text>{t("settings.change_password")}</Text>
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</View>
<View style={styles.item}>
3 weeks ago
<Text>{t("settings.change_phone")}</Text>
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</View>
1 month ago
</View>
<View style={styles.content}>
<TouchableOpacity
onPress={() => {
if (mySetting?.language && mySetting?.currency) {
navigation.navigate("MyAddress");
}
}}
style={styles.item}
>
3 weeks ago
<Text>{t("settings.my_address")}</Text>
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</TouchableOpacity>
<View style={styles.item}>
3 weeks ago
<Text>{t("settings.feedback")}</Text>
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</View>
<View style={styles.item}>
3 weeks ago
<Text>{t("settings.privacy_policy")}</Text>
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</View>
<View style={styles.item}>
3 weeks ago
<Text>{t("settings.terms_of_use")}</Text>
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</View>
4 weeks ago
<TouchableOpacity style={styles.item} onPress={() => {
AsyncStorage.clear();
navigation.navigate("CountrySelect");
}}>
3 weeks ago
<Text>{t("settings.clear_cache")}</Text>
1 month ago
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</TouchableOpacity>
<View>
<TouchableOpacity
onPress={() => {
// if (mySetting?.language && mySetting?.currency) {
navigation.navigate("CountrySetting", { mySetting });
// }
}}
style={styles.item}
>
3 weeks ago
<Text>{t("settings.language_currency")}</Text>
<Text>
<LeftArrowIcon size={fontSize(20)} color="#acacac" />
</Text>
</TouchableOpacity>
</View>
1 month ago
</View>
</View>
</SafeAreaView>
1 month ago
);
};
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: '#fff',
},
safeAreaContent: {
flex: 1,
paddingTop: 0,
backgroundColor: "#f8f8f8",
},
1 month ago
container: {
flex: 1,
backgroundColor: "#f8f8f8",
},
header: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: 20,
backgroundColor: "#fff",
},
headerTitle: {
fontSize: fontSize(18),
fontWeight: "600",
},
placeholder: {
width: 24,
1 month ago
},
content: {
backgroundColor: "#fff",
borderBottomWidth: 10,
borderBottomColor: "#f8f8f8",
},
item: {
flexDirection: "row",
alignItems: "center",
justifyContent: "space-between",
padding: 20,
borderBottomWidth: 1,
borderBottomColor: "#e0e0e0",
},
});