feat(medications): 添加药品详情页面和删除功能
新增药品详情页面,支持查看药品信息、编辑备注、切换提醒状态和删除药品 - 创建动态路由页面 /medications/[medicationId].tsx 展示药品详细信息 - 添加语音输入备注功能,支持 iOS 语音识别 - 实现药品删除确认对话框和删除操作 - 优化药品卡片点击跳转详情页面的交互 - 添加删除操作的加载状态和错误处理 - 改进药品管理页面的开关状态显示和加载指示器
This commit is contained in:
@@ -13,9 +13,10 @@ export type MedicationCardProps = {
|
||||
medication: MedicationDisplayItem;
|
||||
colors: (typeof import('@/constants/Colors').Colors)[keyof typeof import('@/constants/Colors').Colors];
|
||||
selectedDate: Dayjs;
|
||||
onOpenDetails?: (medication: MedicationDisplayItem) => void;
|
||||
};
|
||||
|
||||
export function MedicationCard({ medication, colors, selectedDate }: MedicationCardProps) {
|
||||
export function MedicationCard({ medication, colors, selectedDate, onOpenDetails }: MedicationCardProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
@@ -134,34 +135,7 @@ export function MedicationCard({ medication, colors, selectedDate }: MedicationC
|
||||
);
|
||||
}
|
||||
|
||||
if (medication.status === 'missed') {
|
||||
return (
|
||||
<TouchableOpacity
|
||||
activeOpacity={1}
|
||||
disabled={true}
|
||||
onPress={() => {
|
||||
// 已错过的药物不能服用
|
||||
console.log('已错过的药物不能服用');
|
||||
}}
|
||||
>
|
||||
{isLiquidGlassAvailable() ? (
|
||||
<GlassView
|
||||
style={[styles.actionButton, styles.actionButtonMissed]}
|
||||
glassEffectStyle="clear"
|
||||
tintColor="rgba(156, 163, 175, 0.3)"
|
||||
isInteractive={false}
|
||||
>
|
||||
<ThemedText style={styles.actionButtonTextMissed}>已错过</ThemedText>
|
||||
</GlassView>
|
||||
) : (
|
||||
<View style={[styles.actionButton, styles.actionButtonMissed, styles.fallbackActionButtonMissed]}>
|
||||
<ThemedText style={styles.actionButtonTextMissed}>已错过</ThemedText>
|
||||
</View>
|
||||
)}
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
// 只要没有服药,都可以显示立即服用
|
||||
return (
|
||||
<TouchableOpacity
|
||||
activeOpacity={0.7}
|
||||
@@ -193,7 +167,12 @@ export function MedicationCard({ medication, colors, selectedDate }: MedicationC
|
||||
const statusChip = renderStatusBadge();
|
||||
|
||||
return (
|
||||
<View style={[styles.card, { shadowColor: colors.text }]}>
|
||||
<TouchableOpacity
|
||||
style={[styles.card, { shadowColor: colors.text }]}
|
||||
activeOpacity={onOpenDetails ? 0.92 : 1}
|
||||
onPress={() => onOpenDetails?.(medication)}
|
||||
disabled={!onOpenDetails}
|
||||
>
|
||||
<View style={[styles.cardSurface, { backgroundColor: colors.surface }]}>
|
||||
{statusChip ? <View style={styles.statusChipWrapper}>{statusChip}</View> : null}
|
||||
<View style={styles.cardBody}>
|
||||
@@ -226,7 +205,7 @@ export function MedicationCard({ medication, colors, selectedDate }: MedicationC
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -361,4 +340,4 @@ const styles = StyleSheet.create({
|
||||
fontWeight: '600',
|
||||
color: '#fff',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user