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 { useLegalDocument } from '../hooks';
import { colors } from '../theme';
/* ===================== 子组件:顶部导航 ===================== */
function Header({ title, onBack }: { title: string; onBack: () => void }) {
return (
{title}
);
}
/* ===================== 共享页面:法律文档(隐私政策 / 用户协议) ===================== */
export function LegalDocScreen({
docId,
fallbackTitle,
}: {
docId: string;
fallbackTitle: string;
}) {
const router = useRouter();
const { doc, loading, error, refresh } = useLegalDocument(docId);
if (loading) {
return (
);
}
if (error || !doc) {
return (
router.back()} />
加载失败,请重试
重试
);
}
return (
router.back()} />
版本 {doc.version}
更新于 {doc.updatedAt}
{doc.preamble}
{doc.sections.map((section, index) => (
{section.heading}
{section.paragraphs.map((p, pIndex) => (
{p}
))}
))}
本文件含【待确认】占位项,正式发布前需由法务复核并替换公司全称、联系方式、管辖法院等信息。
);
}
const styles = StyleSheet.create({
safeArea: {
flex: 1,
backgroundColor: colors.pageBg,
},
header: {
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
paddingHorizontal: 8,
height: 48,
backgroundColor: colors.white,
borderBottomWidth: 1,
borderBottomColor: colors.borderLight,
},
headerBtn: {
width: 40,
height: 40,
alignItems: 'center',
justifyContent: 'center',
},
headerTitle: {
flex: 1,
textAlign: 'center',
fontSize: 17,
fontWeight: '700',
color: colors.textPrimary,
},
scroll: {
flex: 1,
},
content: {
padding: 16,
paddingBottom: 32,
},
stateBox: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
gap: 12,
},
stateText: {
marginTop: 12,
fontSize: 14,
color: colors.textSecondary,
},
retryBtn: {
marginTop: 16,
paddingHorizontal: 24,
paddingVertical: 8,
borderRadius: 18,
backgroundColor: colors.primaryBtn,
},
retryText: {
fontSize: 13,
fontWeight: '600',
color: colors.white,
},
metaRow: {
flexDirection: 'row',
justifyContent: 'space-between',
marginBottom: 12,
},
metaText: {
fontSize: 12,
color: colors.textHint,
},
preambleCard: {
backgroundColor: colors.infoLight,
borderRadius: 8,
padding: 14,
marginBottom: 16,
},
preambleText: {
fontSize: 13,
lineHeight: 20,
color: colors.textSecondary,
},
section: {
marginBottom: 16,
},
sectionHeading: {
fontSize: 15,
fontWeight: '700',
color: colors.textPrimary,
marginBottom: 8,
},
paragraph: {
fontSize: 13,
lineHeight: 21,
color: colors.textSecondary,
marginBottom: 8,
},
footNote: {
fontSize: 11,
lineHeight: 16,
color: colors.textHint,
marginTop: 8,
},
});