import { Ionicons } from '@expo/vector-icons';
import { useRouter } 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 } from '../../src/theme';
import type { LegalTemplate } from '../../src/types';
/* ===================== 顶部导航 ===================== */
function Header({ onBack }: { onBack: () => void }) {
return (
文书模板
);
}
/* ===================== 模板卡片 ===================== */
function TemplateCard({ template, onPress }: { template: LegalTemplate; onPress: () => void }) {
return (
{template.name}
{template.description}
);
}
/* ===================== 页面 ===================== */
export default function LegalTemplatesScreen() {
const router = useRouter();
const { templates, loading, error, refresh } = useLegalData();
return (
router.back()} />
{loading ? (
) : error ? (
) : templates.length === 0 ? (
) : (
{templates.map((template) => (
router.push(`/legal/template?id=${template.id}`)}
/>
))}
)}
);
}
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: {
fontSize: 17,
fontWeight: '700',
color: colors.textPrimary,
},
scroll: {
flex: 1,
},
content: {
padding: 12,
paddingBottom: 24,
},
templateGrid: {
gap: 8,
},
templateCard: {
flexDirection: 'row',
alignItems: 'center',
padding: 12,
borderRadius: 8,
backgroundColor: colors.white,
},
templateBody: {
flex: 1,
marginLeft: 12,
marginRight: 8,
},
templateName: {
fontSize: 14,
fontWeight: '700',
color: colors.textPrimary,
},
templateDesc: {
marginTop: 2,
fontSize: 12,
color: colors.textSecondary,
},
});