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 ( {/* 左侧圆环 */} {/* 外圈 - 活动卡路里 (红色) */} {/* 中圈 - 锻炼分钟 (橙色) */} {/* 内圈 - 站立小时 (蓝色) */} {/* 右侧数据显示 */} {Math.round(activeCalories)} /{activeCaloriesGoal} 千卡 {Math.round(exerciseMinutes)} /{exerciseMinutesGoal} 分钟 {Math.round(standHours)} /{standHoursGoal} 小时 ); } 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', }, });