import { Ionicons } from '@expo/vector-icons'; import { useRouter } from 'expo-router'; import { ActivityIndicator, Pressable, ScrollView, StyleSheet, Switch, Text, View } from 'react-native'; import { SafeAreaView } from 'react-native-safe-area-context'; import { useNotificationSettings } from '../../src/hooks'; import { colors , spacing } from '../../src/theme'; /* ===================== 子组件:顶部导航 ===================== */ function Header({ onBack }: { onBack: () => void }) { return ( 消息通知 ); } /* ===================== 页面 ===================== */ export default function NotificationSettingsScreen() { const router = useRouter(); const { settings, loading, error, refresh, toggle, updatingId } = useNotificationSettings(); return (
router.back()} /> {loading ? ( ) : error ? ( 加载失败,请重试 重试 ) : settings.length === 0 ? ( 暂无通知设置项 ) : ( 选择你希望接收的通知类型,重要通知建议保持开启。 {settings.map((item, index) => { const isLast = index === settings.length - 1; return ( {item.title} {item.description} toggle(item.id, next)} disabled={updatingId === item.id} trackColor={{ false: colors.border, true: colors.primaryBorder }} thumbColor={item.enabled ? colors.primary : colors.white} /> ); })} )} ); } const styles = StyleSheet.create({ safeArea: { flex: 1, backgroundColor: colors.pageBg, }, header: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingHorizontal: spacing.card, height: 48, backgroundColor: colors.white, borderBottomWidth: 1, borderBottomColor: colors.borderLight, }, headerBtn: { width: 40, height: 40, alignItems: 'center', justifyContent: 'center', }, headerTitle: { fontSize: 17, fontWeight: '700', color: colors.textPrimary, }, scroll: { flex: 1, }, content: { padding: spacing.card, paddingBottom: 24, }, tip: { fontSize: 12, lineHeight: 17, color: colors.textSecondary, marginBottom: 10, paddingHorizontal: 4, }, card: { backgroundColor: colors.white, borderRadius: spacing.card, paddingHorizontal: spacing.card, }, row: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', paddingVertical: 14, borderBottomWidth: 1, borderBottomColor: colors.borderLight, }, rowLast: { borderBottomWidth: 0, }, rowBody: { flex: 1, marginRight: 12, }, rowTitle: { fontSize: 15, fontWeight: '600', color: colors.textPrimary, }, rowDesc: { marginTop: 3, fontSize: 12, lineHeight: 16, color: colors.textSecondary, }, stateBox: { flex: 1, alignItems: 'center', justifyContent: 'center', }, stateText: { marginTop: 12, fontSize: 14, color: colors.textSecondary, }, retryBtn: { marginTop: 16, paddingHorizontal: 24, paddingVertical: spacing.card, borderRadius: 18, backgroundColor: colors.primaryBtn, }, retryText: { fontSize: 13, fontWeight: '600', color: colors.white, }, });