import { useState } from "react"; import { View, Text, Image, Pressable, StyleSheet } from "react-native"; import { BlurView } from "expo-blur"; import Switch from "../components/Switch"; import OptionSelector from "../components/OptionSelector"; import { Container, Title, Input, Button } from "../components/Dialog"; import { Fonts, Style, gutters } from "../styles"; import { icons } from "../assets"; const labelOptions = { name: "Nouveau nom", email: "Nouvelle adresse email", password: "Nouveau mot de passe", language: "Nouvelle langue", }; const languageOptions = { fr: "Français", en: "English", es: "Español", de: "Deutsch", it: "Italiano", }; export default ({ itemKey, type, value, title, onUpdateValue }) => { const [showDialog, setShowDialog] = useState(false); const [inputData, setInputData] = useState(value); const [currentPassword, setCurrentPassword] = useState(""); return ( <> {title} {type === "boolean" ? ( onUpdateValue({ key: itemKey, value: newValue }) } /> ) : ( setShowDialog(true)} style={[ Style.containerRow, { maxWidth: "50%", justifyContent: "flex-end" }, ]} > {itemKey === "password" ? "********" : itemKey === "language" ? languageOptions[value] || value : value} )} } > {`Changement ${title?.toLowerCase()}`} {["password", "email"].includes(itemKey) && ( setCurrentPassword(text)} keyboardType="visible-password" type={"password"} containerStyle={{ marginBottom: gutters / 2 }} /> )} {itemKey === "language" ? ( ) : ( setInputData(text)} autoCapitalize={ ["password", "email"].includes(itemKey) ? "none" : "words" } type={itemKey} containerStyle={{ marginBottom: gutters / 2 }} /> )}