import { Ionicons } from '@expo/vector-icons';
import { useRouter } from 'expo-router';
import { ActivityIndicator, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useAccountSecurity } from '../../src/hooks';
import { colors , spacing } from '../../src/theme';
/* ===================== 子组件:顶部导航 ===================== */
function Header({ onBack }: { onBack: () => void }) {
return (
账号与安全
);
}
/* ===================== 页面 ===================== */
export default function AccountSecurityScreen() {
const router = useRouter();
const { items, loading, error, refresh } = useAccountSecurity();
const handlePress = (item: (typeof items)[number]) => {
if (item.route) {
router.push(item.route);
return;
}
// 待开发项:仅占位,避免死路由
};
return (
router.back()} />
{loading ? (
) : error ? (
加载失败,请重试
重试
) : items.length === 0 ? (
暂无账号安全项
) : (
管理你的登录方式与账号安全,建议定期检查。
{items.map((item, index) => {
const isLast = index === items.length - 1;
const isDanger = item.variant === 'danger';
return (
handlePress(item)}
hitSlop={4}
>
{item.title}
{item.description}
{item.value && {item.value}}
);
})}
)}
);
}
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',
paddingVertical: 14,
borderBottomWidth: 1,
borderBottomColor: colors.borderLight,
},
rowLast: {
borderBottomWidth: 0,
},
rowBody: {
flex: 1,
},
rowTitle: {
fontSize: 15,
fontWeight: '600',
color: colors.textPrimary,
},
rowTitleDanger: {
color: colors.dangerText,
},
rowDesc: {
marginTop: 3,
fontSize: 12,
lineHeight: 16,
color: colors.textSecondary,
},
rowValue: {
fontSize: 13,
color: colors.textSecondary,
marginRight: 4,
},
chevron: {
marginLeft: 2,
},
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,
},
});