You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
204 lines
5.0 KiB
204 lines
5.0 KiB
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 (
|
|
<View style={styles.header}>
|
|
<Pressable style={styles.headerBtn} onPress={onBack} hitSlop={8}>
|
|
<Ionicons name="chevron-back" size={24} color={colors.textPrimary} />
|
|
</Pressable>
|
|
<Text style={styles.headerTitle} numberOfLines={1}>
|
|
{title}
|
|
</Text>
|
|
<View style={styles.headerBtn} />
|
|
</View>
|
|
);
|
|
}
|
|
|
|
/* ===================== 共享页面:法律文档(隐私政策 / 用户协议) ===================== */
|
|
|
|
export function LegalDocScreen({
|
|
docId,
|
|
fallbackTitle,
|
|
}: {
|
|
docId: string;
|
|
fallbackTitle: string;
|
|
}) {
|
|
const router = useRouter();
|
|
const { doc, loading, error, refresh } = useLegalDocument(docId);
|
|
|
|
if (loading) {
|
|
return (
|
|
<SafeAreaView style={styles.safeArea} edges={['top']}>
|
|
<Header title={fallbackTitle} onBack={() => router.back()} />
|
|
<View style={styles.stateBox}>
|
|
<ActivityIndicator size="large" color={colors.primary} />
|
|
</View>
|
|
</SafeAreaView>
|
|
);
|
|
}
|
|
|
|
if (error || !doc) {
|
|
return (
|
|
<SafeAreaView style={styles.safeArea} edges={['top']}>
|
|
<Header title={fallbackTitle} onBack={() => router.back()} />
|
|
<View style={styles.stateBox}>
|
|
<Ionicons name="alert-circle-outline" size={40} color={colors.danger} />
|
|
<Text style={styles.stateText}>加载失败,请重试</Text>
|
|
<Pressable style={styles.retryBtn} onPress={refresh}>
|
|
<Text style={styles.retryText}>重试</Text>
|
|
</Pressable>
|
|
</View>
|
|
</SafeAreaView>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<SafeAreaView style={styles.safeArea} edges={['top', 'bottom']}>
|
|
<Header title={doc.title} onBack={() => router.back()} />
|
|
<ScrollView
|
|
style={styles.scroll}
|
|
contentContainerStyle={styles.content}
|
|
showsVerticalScrollIndicator={false}
|
|
>
|
|
<View style={styles.metaRow}>
|
|
<Text style={styles.metaText}>版本 {doc.version}</Text>
|
|
<Text style={styles.metaText}>更新于 {doc.updatedAt}</Text>
|
|
</View>
|
|
|
|
<View style={styles.preambleCard}>
|
|
<Text style={styles.preambleText}>{doc.preamble}</Text>
|
|
</View>
|
|
|
|
{doc.sections.map((section, index) => (
|
|
<View key={index} style={styles.section}>
|
|
<Text style={styles.sectionHeading}>{section.heading}</Text>
|
|
{section.paragraphs.map((p, pIndex) => (
|
|
<Text key={pIndex} style={styles.paragraph}>
|
|
{p}
|
|
</Text>
|
|
))}
|
|
</View>
|
|
))}
|
|
|
|
<Text style={styles.footNote}>
|
|
本文件含【待确认】占位项,正式发布前需由法务复核并替换公司全称、联系方式、管辖法院等信息。
|
|
</Text>
|
|
</ScrollView>
|
|
</SafeAreaView>
|
|
);
|
|
}
|
|
|
|
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,
|
|
},
|
|
});
|
|
|