feat: 优化健康数据相关组件及功能

- 在 CoachScreen 中调整键盘高度计算,移除不必要的 insets.bottom
- 更新 Statistics 组件,移除未使用的健康数据相关函数,简化代码
- 修改多个统计卡片,移除不必要的图标属性,提升组件简洁性
- 优化 HealthDataCard 和其他统计卡片的样式,提升视觉一致性
- 更新健康数据获取逻辑,确保数据处理更为准确
- 移除 MoodCard 中的多余元素,简化心情记录展示
- 调整 StressMeter 和其他组件的样式,提升用户体验
This commit is contained in:
richarjiang
2025-08-25 12:44:40 +08:00
parent ee84a801fb
commit be0a8e7393
10 changed files with 83 additions and 197 deletions

View File

@@ -67,20 +67,39 @@ export const DateSelector: React.FC<DateSelectorProps> = ({
const maxScrollOffset = Math.max(0, (days.length * itemWidth) - scrollWidth);
const finalOffset = Math.min(centerOffset, maxScrollOffset);
daysScrollRef.current.scrollTo({ x: finalOffset, animated });
if (animated) {
// 使用原生动画API实现更平滑的滚动
requestAnimationFrame(() => {
daysScrollRef.current?.scrollTo({
x: finalOffset,
animated: true
});
});
} else {
// 非动画情况直接跳转
daysScrollRef.current?.scrollTo({
x: finalOffset,
animated: false
});
}
};
// 初始化时滚动到选中项
useEffect(() => {
if (scrollWidth > 0 && autoScrollToSelected) {
scrollToIndex(selectedIndex, false);
scrollToIndex(selectedIndex, true);
}
}, [scrollWidth, selectedIndex, autoScrollToSelected]);
// 当选中索引变化时,滚动到对应位置
useEffect(() => {
if (scrollWidth > 0 && autoScrollToSelected) {
scrollToIndex(selectedIndex, true);
// 添加微小延迟以确保动画效果更明显
const timer = setTimeout(() => {
scrollToIndex(selectedIndex, true);
}, 50);
return () => clearTimeout(timer);
}
}, [selectedIndex, autoScrollToSelected]);
@@ -94,6 +113,11 @@ export const DateSelector: React.FC<DateSelectorProps> = ({
return;
}
// 先滚动到目标位置,再更新状态
if (autoScrollToSelected) {
scrollToIndex(index, true);
}
// 更新内部状态(如果使用外部控制则不更新)
if (externalSelectedIndex === undefined) {
setInternalSelectedIndex(index);