import React from 'react'; import { View, Text, TouchableOpacity, StyleSheet, ActivityIndicator } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useRouter } from 'expo-router'; import { Ionicons } from '@expo/vector-icons'; import { useAuthStore } from '../store/authStore'; import { useSettingsStore } from '../store/settingsStore'; import { useTheme } from '../utils/theme'; import { useCheckUpdate } from '../hooks/useCheckUpdate'; export default function SettingsScreen() { const router = useRouter(); const { isLoggedIn, logout } = useAuthStore(); const { darkMode, setDarkMode, trafficSaving, setTrafficSaving } = useSettingsStore(); const theme = useTheme(); const { currentVersion, isChecking, downloadProgress, checkUpdate } = useCheckUpdate(); const handleLogout = async () => { await logout(); router.back(); }; return ( router.back()} style={styles.backBtn}> 设置 版本信息 当前版本 v{currentVersion} 更新 {isChecking ? ( <> 检查中... ) : downloadProgress !== null ? ( 下载中 {downloadProgress}% ) : ( 检查更新 )} 外观 setDarkMode(false)} activeOpacity={0.7} > 浅色 setDarkMode(true)} activeOpacity={0.7} > 深色 流量 setTrafficSaving(false)} activeOpacity={0.7} > 标准 setTrafficSaving(true)} activeOpacity={0.7} > 节流 {trafficSaving && ( 封面低画质 · 首页视频不自动播放 · 视频默认 360p )} {isLoggedIn && ( 退出登录 )} ); } const styles = StyleSheet.create({ safe: { flex: 1 }, topBar: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 8, paddingVertical: 8, borderBottomWidth: StyleSheet.hairlineWidth, }, backBtn: { padding: 4, width: 32 }, spacer: { width: 32 }, topTitle: { flex: 1, fontSize: 16, fontWeight: '600', textAlign: 'center', }, section: { marginTop: 16, paddingHorizontal: 16, paddingVertical: 14, borderTopWidth: StyleSheet.hairlineWidth, borderBottomWidth: StyleSheet.hairlineWidth, }, sectionLabel: { fontSize: 13, marginBottom: 10 }, optionRow: { flexDirection: 'row', gap: 10 }, option: { paddingHorizontal: 20, paddingVertical: 6, borderRadius: 20, borderWidth: 1, borderColor: '#e0e0e0', backgroundColor: 'transparent', }, optionActive: { borderColor: '#00AEEC', backgroundColor: '#e8f7fd' }, optionText: { fontSize: 14, color: '#666' }, optionTextActive: { color: '#00AEEC', fontWeight: '600' }, hint: { fontSize: 12, marginTop: 8 }, versionRow: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', }, versionLabel: { fontSize: 14 }, versionValue: { fontSize: 14 }, updateBtn: { flexDirection: 'row', alignItems: 'center', paddingVertical: 6, }, updateBtnText: { fontSize: 14, color: '#00AEEC', fontWeight: '600' }, logoutBtn: { margin: 24, paddingVertical: 12, borderRadius: 8, borderWidth: 1, borderColor: '#ff4757', alignItems: 'center', }, logoutText: { fontSize: 15, color: '#ff4757', fontWeight: '600' }, });