- 在 CoachScreen 中调整键盘高度计算,移除不必要的 insets.bottom - 更新 Statistics 组件,移除未使用的健康数据相关函数,简化代码 - 修改多个统计卡片,移除不必要的图标属性,提升组件简洁性 - 优化 HealthDataCard 和其他统计卡片的样式,提升视觉一致性 - 更新健康数据获取逻辑,确保数据处理更为准确 - 移除 MoodCard 中的多余元素,简化心情记录展示 - 调整 StressMeter 和其他组件的样式,提升用户体验
149 lines
3.4 KiB
TypeScript
149 lines
3.4 KiB
TypeScript
import { AnimatedNumber } from '@/components/AnimatedNumber';
|
|
import React from 'react';
|
|
import { StyleSheet, Text, View } from 'react-native';
|
|
|
|
interface BasalMetabolismCardProps {
|
|
value: number | null;
|
|
resetToken?: number;
|
|
style?: any;
|
|
}
|
|
|
|
export function BasalMetabolismCard({ value, resetToken, style }: BasalMetabolismCardProps) {
|
|
// 获取基础代谢状态描述
|
|
const getMetabolismStatus = () => {
|
|
if (value === null || value === 0) {
|
|
return { text: '未知', color: '#9AA3AE' };
|
|
}
|
|
|
|
// 基于常见的基础代谢范围来判断状态
|
|
if (value >= 1800) {
|
|
return { text: '高代谢', color: '#10B981' };
|
|
} else if (value >= 1400) {
|
|
return { text: '正常', color: '#3B82F6' };
|
|
} else if (value >= 1000) {
|
|
return { text: '偏低', color: '#F59E0B' };
|
|
} else {
|
|
return { text: '较低', color: '#EF4444' };
|
|
}
|
|
};
|
|
|
|
const status = getMetabolismStatus();
|
|
|
|
return (
|
|
<View style={[styles.container, style]}>
|
|
|
|
{/* 头部区域 */}
|
|
<View style={styles.header}>
|
|
<View style={styles.leftSection}>
|
|
<Text style={styles.title}>基础代谢</Text>
|
|
</View>
|
|
<View style={[styles.statusBadge, { backgroundColor: status.color + '20' }]}>
|
|
<Text style={[styles.statusText, { color: status.color }]}>{status.text}</Text>
|
|
</View>
|
|
</View>
|
|
|
|
{/* 数值显示区域 */}
|
|
<View style={styles.valueSection}>
|
|
{value != null && value > 0 ? (
|
|
<AnimatedNumber
|
|
value={value}
|
|
resetToken={resetToken}
|
|
style={styles.value}
|
|
format={(v) => Math.round(v).toString()}
|
|
/>
|
|
) : (
|
|
<Text style={styles.value}>--</Text>
|
|
)}
|
|
<Text style={styles.unit}>千卡/日</Text>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
backgroundColor: '#FFFFFF',
|
|
borderRadius: 20,
|
|
padding: 16,
|
|
shadowColor: '#000',
|
|
shadowOffset: {
|
|
width: 0,
|
|
height: 4,
|
|
},
|
|
shadowOpacity: 0.08,
|
|
shadowRadius: 12,
|
|
elevation: 4,
|
|
position: 'relative',
|
|
overflow: 'hidden',
|
|
},
|
|
|
|
header: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
justifyContent: 'space-between',
|
|
marginBottom: 16,
|
|
zIndex: 1,
|
|
},
|
|
leftSection: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
},
|
|
iconContainer: {
|
|
width: 32,
|
|
height: 32,
|
|
borderRadius: 10,
|
|
backgroundColor: '#FFFFFF',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
marginRight: 8,
|
|
shadowColor: '#000',
|
|
shadowOffset: {
|
|
width: 0,
|
|
height: 1,
|
|
},
|
|
shadowOpacity: 0.1,
|
|
shadowRadius: 2,
|
|
elevation: 1,
|
|
},
|
|
fireIcon: {
|
|
width: 14,
|
|
height: 18,
|
|
backgroundColor: '#EF4444',
|
|
borderTopLeftRadius: 7,
|
|
borderTopRightRadius: 7,
|
|
borderBottomLeftRadius: 2,
|
|
borderBottomRightRadius: 2,
|
|
},
|
|
title: {
|
|
fontSize: 16,
|
|
fontWeight: '700',
|
|
color: '#0F172A',
|
|
},
|
|
statusBadge: {
|
|
paddingHorizontal: 8,
|
|
paddingVertical: 4,
|
|
borderRadius: 12,
|
|
},
|
|
statusText: {
|
|
fontSize: 11,
|
|
fontWeight: '600',
|
|
},
|
|
valueSection: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
zIndex: 1,
|
|
},
|
|
value: {
|
|
fontSize: 24,
|
|
fontWeight: '800',
|
|
color: '#0F172A',
|
|
lineHeight: 28,
|
|
},
|
|
unit: {
|
|
fontSize: 14,
|
|
fontWeight: '500',
|
|
color: '#64748B',
|
|
marginLeft: 6,
|
|
},
|
|
});
|