feat: 优化步数柱状图显示,增加背景柱体并调整动画逻辑

This commit is contained in:
richarjiang
2025-09-01 18:47:22 +08:00
parent 73ca11e68f
commit ed694f6142

View File

@@ -97,18 +97,33 @@ const StepsCard: React.FC<StepsCardProps> = ({
});
return (
<Animated.View
key={`bar-${index}`}
style={[
styles.chartBar,
{
height: data.height || 2, // 最小高度2px
backgroundColor: isCurrent && isActive ? '#FFC365' : '#FFEBCB',
transform: [{ scaleY: animatedScale }],
opacity: animatedOpacity,
}
]}
/>
<View key={`bar-container-${index}`} style={styles.barContainer}>
{/* 背景柱体 - 始终显示,使用相似色系的淡色 */}
<View
style={[
styles.chartBar,
{
height: 20, // 背景柱体占满整个高度
backgroundColor: isCurrent ? '#FFF4E6' : '#FFF8F0', // 更淡的相似色系
}
]}
/>
{/* 数据柱体 - 只有当有数据时才显示并执行动画 */}
{isActive && (
<Animated.View
style={[
styles.chartBar,
{
height: data.height,
backgroundColor: isCurrent ? '#FFC365' : '#FFEBCB',
transform: [{ scaleY: animatedScale }],
opacity: animatedOpacity,
}
]}
/>
)}
</View>
);
})}
</View>
@@ -171,10 +186,18 @@ const styles = StyleSheet.create({
justifyContent: 'space-between',
paddingHorizontal: 4,
},
barContainer: {
width: 4,
height: 20,
alignItems: 'center',
justifyContent: 'flex-end',
position: 'relative',
},
chartBar: {
width: 4,
borderRadius: 1,
alignSelf: 'flex-end',
position: 'absolute',
bottom: 0,
},
statsContainer: {
alignItems: 'flex-start',