import { FC, useCallback, useState } from "react" import { TextStyle, View, ViewStyle } from "react-native" import i18n from "i18next" import { useMMKVString } from "react-native-mmkv" import { Button } from "@/components/Button" import { Dialog } from "@/components/Dialog" import { Icon } from "@/components/Icon" import { ListItem } from "@/components/ListItem" import { Screen } from "@/components/Screen" import { Text } from "@/components/Text" import { useAuth } from "@/context/AuthContext" import { translate } from "@/i18n/translate" import { AppStackScreenProps } from "@/navigators/navigationTypes" import { useAppTheme } from "@/theme/context" import { $styles } from "@/theme/styles" import type { ThemedStyle } from "@/theme/types" import { s } from "@/utils/responsive" import { storage } from "@/utils/storage" import { useHeader } from "@/utils/useHeader" // Language display names const LANGUAGE_NAMES: Record = { en: "English", zh: "中文", ja: "日本語", ko: "한국어", es: "Español", fr: "Français", ar: "العربية", hi: "हिन्दी", } // Theme display names const THEME_NAMES: Record = { system: "System", light: "Light", dark: "Dark", } export const SettingsScreen: FC> = function SettingsScreen({ navigation, }) { const { themed, theme } = useAppTheme() const { logout } = useAuth() const [showLogoutDialog, setShowLogoutDialog] = useState(false) // Read the stored theme preference directly from MMKV const [themeScheme] = useMMKVString("ignite.themeScheme", storage) // Get current theme name for display: if no stored value, it's "system" const currentThemeName = themeScheme === "light" || themeScheme === "dark" ? THEME_NAMES[themeScheme] : THEME_NAMES.system const handleLogoutPress = useCallback(() => { setShowLogoutDialog(true) }, []) const handleLogoutConfirm = useCallback(() => { setShowLogoutDialog(false) logout() }, [logout]) useHeader( { title: translate("settingsScreen:title"), leftIcon: "back", onLeftPress: () => navigation.goBack(), }, [], ) return ( {/* Content */} {/* Appearance Section */} {currentThemeName} } onPress={() => navigation.navigate("Theme")} /> {/* Language Section */} {LANGUAGE_NAMES[i18n.language?.split("-")[0] || "en"] || "English"} } onPress={() => navigation.navigate("Language")} /> {/* Logout Button - Fixed at bottom */}