import type { ReactNode } from 'react' import { Modal, View, Text, ScrollView, Pressable, StyleSheet } from 'react-native' import { USER_AGREEMENT_MARKDOWN } from '@/lib/userAgreement' import { theme } from '@/constants/theme' function renderAgreementBody(md: string) { const lines = md.split('\n') const out: ReactNode[] = [] lines.forEach((line, i) => { if (line.startsWith('# ')) { out.push( {line.slice(2)} ) return } if (line.startsWith('## ')) { out.push( {line.slice(3)} ) return } if (line.startsWith('* ')) { out.push( • {line.slice(2)} ) return } if (line.trim() === '') { out.push() return } out.push( {line} ) }) return out } type Props = { visible: boolean onClose: () => void } const AGREEMENT_BODY = USER_AGREEMENT_MARKDOWN.replace(/^# 用户使用协议\n+/, '') export function UserAgreementModal({ visible, onClose }: Props) { return ( 用户使用协议 {renderAgreementBody(AGREEMENT_BODY)} 关闭 ) } const styles = StyleSheet.create({ backdrop: { flex: 1, backgroundColor: 'rgba(0,0,0,0.55)', justifyContent: 'center', padding: 16, }, sheet: { maxHeight: '88%', borderRadius: 14, backgroundColor: theme.bgCard, borderWidth: 1, borderColor: 'rgba(124,92,255,0.22)', paddingTop: 14, paddingHorizontal: 14, paddingBottom: 12, }, sheetTitle: { fontSize: 17, fontWeight: '700', color: theme.text, marginBottom: 10, textAlign: 'center', }, scroll: { flexGrow: 0 }, scrollInner: { paddingBottom: 8 }, h1: { fontSize: 17, fontWeight: '700', color: theme.text, marginBottom: 8, }, h2: { fontSize: 15, fontWeight: '600', color: theme.text, marginTop: 10, marginBottom: 6, }, p: { fontSize: 13, color: theme.muted, lineHeight: 21, marginBottom: 4, }, li: { fontSize: 13, color: theme.muted, lineHeight: 21, marginBottom: 4, paddingLeft: 4, }, gap: { height: 6 }, closeBtn: { marginTop: 10, paddingVertical: 12, borderRadius: 10, backgroundColor: theme.bgElevated, alignItems: 'center', borderWidth: 1, borderColor: theme.border, }, closeBtnText: { fontSize: 15, fontWeight: '600', color: theme.accent }, })