import { Ionicons } from '@expo/vector-icons';
import { useRouter, useLocalSearchParams } from 'expo-router';
import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import { useLegalData } from '../../src/hooks';
import { LoadingState, ErrorState, EmptyState } from '../../src/components/StateView';
import { colors , spacing } from '../../src/theme';
/* ===================== 顶部导航 ===================== */
function Header({ onBack }: { onBack: () => void }) {
return (
文书预览
);
}
/* ===================== 页面 ===================== */
export default function LegalTemplateScreen() {
const router = useRouter();
const { id } = useLocalSearchParams();
const { templates, loading, error, refresh } = useLegalData();
const templateId = Array.isArray(id) ? id[0] : id;
const template = templateId ? templates.find((t) => t.id === templateId) : undefined;
return (
router.back()} />
{loading ? (
) : error ? (
) : !template ? (
) : (
{template.name}
{template.description}
{/* selectable:长按正文即可复制,无需额外原生模块(mock 阶段) */}
{template.content}
长按正文即可复制;正式下载 / 导出为 Word·PDF 需后端文件支持,当前为内容预览。
)}
);
}
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,
},
headCard: {
flexDirection: 'row',
alignItems: 'center',
padding: spacing.card,
borderRadius: spacing.card,
backgroundColor: colors.white,
marginBottom: 8,
},
headBody: {
flex: 1,
marginLeft: 12,
},
name: {
fontSize: 16,
fontWeight: '700',
color: colors.textPrimary,
},
desc: {
marginTop: 2,
fontSize: 12,
color: colors.textSecondary,
},
contentCard: {
padding: spacing.card,
borderRadius: spacing.card,
backgroundColor: colors.white,
borderWidth: 1,
borderColor: colors.borderLight,
},
contentText: {
fontSize: 14,
lineHeight: 22,
color: colors.textPrimary,
},
tip: {
marginTop: 12,
fontSize: 12,
color: colors.textHint,
lineHeight: 18,
},
});