import { Ionicons } from '@expo/vector-icons'; import { Image } from 'expo-image'; import { LinearGradient } from 'expo-linear-gradient'; import React, { useEffect, useRef, useState } from 'react'; import { Animated, Modal, Pressable, StyleSheet, Text, TouchableOpacity, View } from 'react-native'; type Props = { visible: boolean; onClose: () => void; onManualAdd: () => void; onAiRecognize: () => void; }; export function MedicationAddOptionsSheet({ visible, onClose, onManualAdd, onAiRecognize }: Props) { const translateY = useRef(new Animated.Value(300)).current; const opacity = useRef(new Animated.Value(0)).current; const [modalVisible, setModalVisible] = useState(false); useEffect(() => { if (visible) { // 打开时:先显示 Modal,然后执行动画 setModalVisible(true); Animated.parallel([ Animated.spring(translateY, { toValue: 0, tension: 65, friction: 11, useNativeDriver: true, }), Animated.timing(opacity, { toValue: 1, duration: 200, useNativeDriver: true, }), ]).start(); } else if (modalVisible) { // 关闭时:先执行动画,动画完成后隐藏 Modal Animated.parallel([ Animated.timing(translateY, { toValue: 300, duration: 200, useNativeDriver: true, }), Animated.timing(opacity, { toValue: 0, duration: 150, useNativeDriver: true, }), ]).start(({ finished }) => { if (finished) { setModalVisible(false); } }); } }, [visible, modalVisible, opacity, translateY]); const handleClose = () => { // 触发关闭动画 onClose(); }; return ( {/* Header */} 添加药物 选择录入方式 {/* AI 智能识别 - 主推荐 */} {/* 推荐标签 */} 推荐使用 AI 智能识别 拍照识别药品信息{'\n'}自动生成提醒计划 快速识别 智能填充 {/* AI 说明 */} 需会员或 AI 次数 · 拍摄时确保光线充足 {/* 分隔线 */} {/* 手动录入 - 次要选项 */} 手动录入 逐项填写药品信息和服用计划 免费 {/* 底部安全距离 */} ); } const styles = StyleSheet.create({ overlay: { flex: 1, backgroundColor: 'transparent', }, backdrop: { ...StyleSheet.absoluteFillObject, backgroundColor: 'rgba(0,0,0,0.4)', }, sheet: { position: 'absolute', left: 0, right: 0, bottom: 0, backgroundColor: '#fff', borderTopLeftRadius: 32, borderTopRightRadius: 32, paddingTop: 24, paddingHorizontal: 20, shadowColor: '#000', shadowOpacity: 0.15, shadowRadius: 20, shadowOffset: { width: 0, height: -8 }, elevation: 12, }, // Header header: { flexDirection: 'row', alignItems: 'flex-start', justifyContent: 'space-between', marginBottom: 24, }, headerLeft: { flex: 1, }, title: { fontSize: 24, fontWeight: '700', color: '#0f172a', marginBottom: 4, }, subtitle: { fontSize: 14, color: '#64748b', fontWeight: '500', }, closeButton: { width: 36, height: 36, borderRadius: 18, backgroundColor: '#f1f5f9', alignItems: 'center', justifyContent: 'center', marginLeft: 12, }, // AI 卡片 - 主推荐 aiCard: { borderRadius: 24, padding: 20, marginBottom: 20, overflow: 'hidden', shadowColor: '#0ea5e9', shadowOpacity: 0.3, shadowRadius: 16, shadowOffset: { width: 0, height: 8 }, elevation: 8, }, recommendBadge: { position: 'absolute', top: 16, right: 16, flexDirection: 'row', alignItems: 'center', gap: 4, backgroundColor: 'rgba(255,255,255,0.25)', paddingHorizontal: 10, paddingVertical: 6, borderRadius: 16, borderWidth: 1, borderColor: 'rgba(255,255,255,0.3)', }, recommendText: { fontSize: 12, fontWeight: '700', color: '#fff', }, aiContent: { flexDirection: 'row', alignItems: 'center', marginBottom: 16, }, aiLeft: { flex: 1, flexDirection: 'row', gap: 16, }, aiIconWrapper: { width: 56, height: 56, borderRadius: 16, backgroundColor: 'rgba(255,255,255,0.2)', alignItems: 'center', justifyContent: 'center', borderWidth: 2, borderColor: 'rgba(255,255,255,0.3)', }, aiTexts: { flex: 1, gap: 8, }, aiTitle: { fontSize: 20, fontWeight: '700', color: '#fff', }, aiDescription: { fontSize: 14, color: 'rgba(255,255,255,0.9)', lineHeight: 20, }, aiFeatures: { flexDirection: 'row', gap: 12, marginTop: 4, }, featureItem: { flexDirection: 'row', alignItems: 'center', gap: 4, }, featureText: { fontSize: 12, fontWeight: '600', color: '#fff', }, aiImage: { width: 80, height: 80, marginLeft: 12, }, aiFooter: { flexDirection: 'row', alignItems: 'center', gap: 6, paddingTop: 12, borderTopWidth: 1, borderTopColor: 'rgba(255,255,255,0.2)', }, aiFooterText: { fontSize: 12, color: 'rgba(255,255,255,0.8)', fontWeight: '500', }, // 分隔线 divider: { flexDirection: 'row', alignItems: 'center', marginBottom: 20, }, dividerLine: { flex: 1, height: 1, backgroundColor: '#e2e8f0', }, dividerText: { fontSize: 13, color: '#94a3b8', fontWeight: '600', marginHorizontal: 16, }, // 手动录入卡片 - 次要选项 manualCard: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', backgroundColor: '#f8fafc', borderRadius: 20, padding: 16, borderWidth: 1.5, borderColor: '#e2e8f0', }, manualLeft: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: 12, }, manualIconWrapper: { width: 48, height: 48, borderRadius: 14, backgroundColor: '#eef2ff', alignItems: 'center', justifyContent: 'center', }, manualTexts: { flex: 1, gap: 4, }, manualTitle: { fontSize: 16, fontWeight: '700', color: '#0f172a', }, manualDescription: { fontSize: 13, color: '#64748b', lineHeight: 18, }, manualRight: { flexDirection: 'row', alignItems: 'center', gap: 8, marginLeft: 12, }, manualBadge: { backgroundColor: '#dcfce7', paddingHorizontal: 8, paddingVertical: 4, borderRadius: 8, }, manualBadgeText: { fontSize: 11, fontWeight: '700', color: '#16a34a', }, // 底部安全距离 safeArea: { height: 32, }, });