feat: 添加用户推送通知偏好设置功能,支持开启/关闭推送通知
This commit is contained in:
@@ -54,21 +54,29 @@ const StepsCard: React.FC<StepsCardProps> = ({
|
||||
|
||||
// 触发柱体动画
|
||||
useEffect(() => {
|
||||
if (chartData && chartData.length > 0) {
|
||||
// 检查是否有实际数据(不只是空数组)
|
||||
const hasData = chartData && chartData.length > 0 && chartData.some(data => data.steps > 0);
|
||||
|
||||
if (hasData) {
|
||||
// 重置所有动画值
|
||||
animatedValues.forEach(animValue => animValue.setValue(0));
|
||||
|
||||
// 同时启动所有柱体的弹性动画,有步数的柱体才执行动画
|
||||
chartData.forEach((data, index) => {
|
||||
if (data.steps > 0) {
|
||||
Animated.spring(animatedValues[index], {
|
||||
toValue: 1,
|
||||
tension: 150,
|
||||
friction: 8,
|
||||
useNativeDriver: false,
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
// 使用 setTimeout 确保在下一个事件循环中执行动画,保证组件已完全渲染
|
||||
const timeoutId = setTimeout(() => {
|
||||
// 同时启动所有柱体的弹性动画,有步数的柱体才执行动画
|
||||
chartData.forEach((data, index) => {
|
||||
if (data.steps > 0) {
|
||||
Animated.spring(animatedValues[index], {
|
||||
toValue: 1,
|
||||
tension: 150,
|
||||
friction: 8,
|
||||
useNativeDriver: false,
|
||||
}).start();
|
||||
}
|
||||
});
|
||||
}, 50); // 添加小延迟确保渲染完成
|
||||
|
||||
return () => clearTimeout(timeoutId);
|
||||
}
|
||||
}, [chartData, animatedValues]);
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ const WaterIntakeCard: React.FC<WaterIntakeCardProps> = ({
|
||||
if (process.env.EXPO_OS === 'ios') {
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
|
||||
}
|
||||
|
||||
|
||||
// 使用用户配置的快速添加饮水量
|
||||
const waterAmount = quickWaterAmount;
|
||||
// 如果有选中日期,则为该日期添加记录;否则为今天添加记录
|
||||
@@ -132,7 +132,7 @@ const WaterIntakeCard: React.FC<WaterIntakeCardProps> = ({
|
||||
if (process.env.EXPO_OS === 'ios') {
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
||||
}
|
||||
|
||||
|
||||
setIsModalVisible(true);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user