feat(medications): 优化药品管理功能和登录流程
- 更新默认药品图片为专用图标 - 移除未使用的 loading 状态选择器 - 优化 Apple 登录按钮样式,支持毛玻璃效果和加载状态 - 添加登录成功后返回功能(shouldBack 参数) - 药品详情页添加信息卡片点击交互 - 添加药品添加页面的登录状态检查 - 增强时间选择器错误处理和数据验证 - 修复药品图片显示逻辑,支持网络图片 - 优化药品卡片样式和布局 - 添加图片加载错误处理
This commit is contained in:
@@ -6,7 +6,7 @@ import { Ionicons } from '@expo/vector-icons';
|
||||
import dayjs, { Dayjs } from 'dayjs';
|
||||
import { GlassView, isLiquidGlassAvailable } from 'expo-glass-effect';
|
||||
import { Image } from 'expo-image';
|
||||
import React, { useState } from 'react';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Alert, StyleSheet, TouchableOpacity, View } from 'react-native';
|
||||
|
||||
export type MedicationCardProps = {
|
||||
@@ -19,10 +19,16 @@ export type MedicationCardProps = {
|
||||
export function MedicationCard({ medication, colors, selectedDate, onOpenDetails }: MedicationCardProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [imageError, setImageError] = useState(false);
|
||||
|
||||
const scheduledDate = dayjs(`${selectedDate.format('YYYY-MM-DD')} ${medication.scheduledTime}`);
|
||||
const timeDiffMinutes = scheduledDate.diff(dayjs(), 'minute');
|
||||
|
||||
// 当药品变化时重置图片错误状态
|
||||
useEffect(() => {
|
||||
setImageError(false);
|
||||
}, [medication.id]);
|
||||
|
||||
/**
|
||||
* 处理服药操作
|
||||
*/
|
||||
@@ -166,6 +172,7 @@ export function MedicationCard({ medication, colors, selectedDate, onOpenDetails
|
||||
|
||||
const statusChip = renderStatusBadge();
|
||||
|
||||
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={[styles.card, { shadowColor: colors.text }]}
|
||||
@@ -179,7 +186,12 @@ export function MedicationCard({ medication, colors, selectedDate, onOpenDetails
|
||||
<View style={styles.cardContent}>
|
||||
<View style={styles.thumbnailWrapper}>
|
||||
<View style={styles.thumbnailSurface}>
|
||||
<Image source={medication.image} style={styles.thumbnailImage} />
|
||||
<Image
|
||||
source={medication.image}
|
||||
style={styles.thumbnailImage}
|
||||
onError={() => setImageError(true)}
|
||||
key={medication.id} // 重新渲染时重置状态
|
||||
/>
|
||||
</View>
|
||||
</View>
|
||||
<View style={styles.infoSection}>
|
||||
@@ -211,21 +223,17 @@ export function MedicationCard({ medication, colors, selectedDate, onOpenDetails
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
card: {
|
||||
borderRadius: 26,
|
||||
shadowOpacity: 0.08,
|
||||
shadowOffset: { width: 0, height: 12 },
|
||||
shadowRadius: 24,
|
||||
elevation: 2,
|
||||
borderRadius: 18,
|
||||
position: 'relative',
|
||||
},
|
||||
cardSurface: {
|
||||
borderRadius: 26,
|
||||
borderRadius: 18,
|
||||
overflow: 'hidden',
|
||||
},
|
||||
cardBody: {
|
||||
paddingHorizontal: 20,
|
||||
paddingBottom: 20,
|
||||
paddingTop: 28,
|
||||
paddingHorizontal: 10,
|
||||
paddingBottom: 10,
|
||||
paddingTop: 10,
|
||||
},
|
||||
cardContent: {
|
||||
flexDirection: 'row',
|
||||
@@ -233,20 +241,20 @@ const styles = StyleSheet.create({
|
||||
gap: 20,
|
||||
},
|
||||
thumbnailWrapper: {
|
||||
width: 126,
|
||||
width: 148,
|
||||
height: 110,
|
||||
},
|
||||
thumbnailSurface: {
|
||||
flex: 1,
|
||||
borderRadius: 22,
|
||||
backgroundColor: '#F1F4FF',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
overflow: 'hidden',
|
||||
borderRadius: 18,
|
||||
},
|
||||
thumbnailImage: {
|
||||
width: '80%',
|
||||
height: '80%',
|
||||
width: '70%',
|
||||
height: '70%',
|
||||
resizeMode: 'contain',
|
||||
},
|
||||
infoSection: {
|
||||
@@ -281,7 +289,7 @@ const styles = StyleSheet.create({
|
||||
gap: 6,
|
||||
justifyContent: 'center',
|
||||
height: 38,
|
||||
borderRadius: 24,
|
||||
borderRadius: 10,
|
||||
overflow: 'hidden',
|
||||
},
|
||||
actionButtonUpcoming: {
|
||||
|
||||
Reference in New Issue
Block a user