- 在 CoachScreen 中优化欢迎消息的生成,整合用户配置文件数据,支持选择选项和表情 - 更新欢迎消息生成函数,返回包含内容、选择和交互类型的结构 - 在多个组件中调整样式,提升用户体验和界面一致性 - 在 Statistics 组件中添加记录更新时间,确保数据展示的准确性 - 在 FitnessRingsCard 中修正卡路里和运动时间的显示,确保数值四舍五入
180 lines
4.9 KiB
TypeScript
180 lines
4.9 KiB
TypeScript
import React from 'react';
|
|
import { StyleSheet, Text, View } from 'react-native';
|
|
import { CircularRing } from './CircularRing';
|
|
|
|
type FitnessRingsCardProps = {
|
|
style?: any;
|
|
// 活动卡路里数据
|
|
activeCalories?: number;
|
|
activeCaloriesGoal?: number;
|
|
// 锻炼分钟数据
|
|
exerciseMinutes?: number;
|
|
exerciseMinutesGoal?: number;
|
|
// 站立小时数据
|
|
standHours?: number;
|
|
standHoursGoal?: number;
|
|
// 动画重置令牌
|
|
resetToken?: unknown;
|
|
};
|
|
|
|
/**
|
|
* 健身圆环卡片组件,模仿 Apple Watch 的健身圆环
|
|
*/
|
|
export function FitnessRingsCard({
|
|
style,
|
|
activeCalories = 25,
|
|
activeCaloriesGoal = 350,
|
|
exerciseMinutes = 1,
|
|
exerciseMinutesGoal = 5,
|
|
standHours = 2,
|
|
standHoursGoal = 13,
|
|
resetToken,
|
|
}: FitnessRingsCardProps) {
|
|
// 计算进度百分比
|
|
const caloriesProgress = Math.min(1, Math.max(0, activeCalories / activeCaloriesGoal));
|
|
const exerciseProgress = Math.min(1, Math.max(0, exerciseMinutes / exerciseMinutesGoal));
|
|
const standProgress = Math.min(1, Math.max(0, standHours / standHoursGoal));
|
|
|
|
return (
|
|
<View style={[styles.container, style]}>
|
|
<View style={styles.contentContainer}>
|
|
{/* 左侧圆环 */}
|
|
<View style={styles.ringsContainer}>
|
|
<View style={styles.ringWrapper}>
|
|
{/* 外圈 - 活动卡路里 (红色) */}
|
|
<View style={[styles.ringPosition]}>
|
|
<CircularRing
|
|
size={36}
|
|
strokeWidth={2.5}
|
|
trackColor="rgba(255, 59, 48, 0.15)"
|
|
progressColor="#FF3B30"
|
|
progress={caloriesProgress}
|
|
showCenterText={false}
|
|
resetToken={resetToken}
|
|
startAngleDeg={-90}
|
|
/>
|
|
</View>
|
|
|
|
{/* 中圈 - 锻炼分钟 (橙色) */}
|
|
<View style={[styles.ringPosition]}>
|
|
<CircularRing
|
|
size={26}
|
|
strokeWidth={2}
|
|
trackColor="rgba(255, 149, 0, 0.15)"
|
|
progressColor="#FF9500"
|
|
progress={exerciseProgress}
|
|
showCenterText={false}
|
|
resetToken={resetToken}
|
|
startAngleDeg={-90}
|
|
/>
|
|
</View>
|
|
|
|
{/* 内圈 - 站立小时 (蓝色) */}
|
|
<View style={[styles.ringPosition]}>
|
|
<CircularRing
|
|
size={16}
|
|
strokeWidth={1.5}
|
|
trackColor="rgba(0, 122, 255, 0.15)"
|
|
progressColor="#007AFF"
|
|
progress={standProgress}
|
|
showCenterText={false}
|
|
resetToken={resetToken}
|
|
startAngleDeg={-90}
|
|
/>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
|
|
{/* 右侧数据显示 */}
|
|
<View style={styles.dataContainer}>
|
|
<View style={styles.dataRow}>
|
|
<Text style={styles.dataText}>
|
|
<Text style={styles.dataValue}>{Math.round(activeCalories)}</Text>
|
|
<Text style={styles.dataGoal}>/{activeCaloriesGoal}</Text>
|
|
</Text>
|
|
<Text style={styles.dataUnit}>千卡</Text>
|
|
</View>
|
|
|
|
<View style={styles.dataRow}>
|
|
<Text style={styles.dataText}>
|
|
<Text style={styles.dataValue}>{Math.round(exerciseMinutes)}</Text>
|
|
<Text style={styles.dataGoal}>/{exerciseMinutesGoal}</Text>
|
|
</Text>
|
|
<Text style={styles.dataUnit}>分钟</Text>
|
|
</View>
|
|
|
|
<View style={styles.dataRow}>
|
|
<Text style={styles.dataText}>
|
|
<Text style={styles.dataValue}>{Math.round(standHours)}</Text>
|
|
<Text style={styles.dataGoal}>/{standHoursGoal}</Text>
|
|
</Text>
|
|
<Text style={styles.dataUnit}>小时</Text>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
const styles = StyleSheet.create({
|
|
container: {
|
|
borderRadius: 16,
|
|
shadowColor: '#000',
|
|
shadowOffset: {
|
|
width: 0,
|
|
height: 2,
|
|
},
|
|
shadowOpacity: 0.08,
|
|
shadowRadius: 8,
|
|
elevation: 3,
|
|
},
|
|
contentContainer: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
justifyContent: 'space-between',
|
|
},
|
|
ringsContainer: {
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
marginRight: 12,
|
|
},
|
|
ringWrapper: {
|
|
position: 'relative',
|
|
width: 36,
|
|
height: 36,
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
},
|
|
ringPosition: {
|
|
position: 'absolute',
|
|
alignItems: 'center',
|
|
justifyContent: 'center',
|
|
},
|
|
dataContainer: {
|
|
flex: 1,
|
|
gap: 3,
|
|
},
|
|
dataRow: {
|
|
flexDirection: 'row',
|
|
alignItems: 'center',
|
|
justifyContent: 'space-between',
|
|
},
|
|
dataText: {
|
|
fontSize: 12,
|
|
fontWeight: '700',
|
|
flex: 1,
|
|
},
|
|
dataValue: {
|
|
color: '#192126',
|
|
},
|
|
dataGoal: {
|
|
color: '#9AA3AE',
|
|
},
|
|
dataUnit: {
|
|
fontSize: 10,
|
|
color: '#9AA3AE',
|
|
fontWeight: '500',
|
|
minWidth: 25,
|
|
textAlign: 'right',
|
|
},
|
|
}); |