feat: add nutrition and mood reminder settings

- Implemented nutrition and mood reminder toggles in notification settings screen.
- Added corresponding utility functions for managing nutrition and mood reminder preferences.
- Updated user preferences interface to include nutrition and mood reminder states.
- Enhanced localization for new reminder settings and alerts.
- Incremented iOS app version to 1.0.30.
This commit is contained in:
2025-11-23 22:47:54 +08:00
parent bcb910140e
commit 8cbf6be50a
7 changed files with 359 additions and 151 deletions

View File

@@ -29,6 +29,7 @@ const WORKOUT_TYPES = [
{ key: 'walking', label: '步行' },
{ key: 'other', label: '其他运动' },
];
const WORKOUT_TYPE_KEYS = WORKOUT_TYPES.map(type => type.key);
export default function WorkoutNotificationSettingsScreen() {
const safeAreaTop = useSafeAreaTop()
@@ -80,16 +81,18 @@ export default function WorkoutNotificationSettingsScreen() {
};
const handleWorkoutTypeToggle = (workoutType: string) => {
const currentTypes = preferences.enabledWorkoutTypes;
let newTypes: string[];
const currentTypes = preferences.enabledWorkoutTypes.length === 0
? [...WORKOUT_TYPE_KEYS] // 空数组表示全部启用,先展开成完整列表,避免影响其他开关的当前状态
: [...preferences.enabledWorkoutTypes];
if (currentTypes.includes(workoutType)) {
newTypes = currentTypes.filter(type => type !== workoutType);
} else {
newTypes = [...currentTypes, workoutType];
}
const nextTypes = currentTypes.includes(workoutType)
? currentTypes.filter(type => type !== workoutType)
: [...currentTypes, workoutType];
savePreferences({ enabledWorkoutTypes: newTypes });
// 如果全部类型都开启,回退为空数组表示“全部启用”,以保持原有存储约定
const normalizedTypes = nextTypes.length === WORKOUT_TYPE_KEYS.length ? [] : nextTypes;
savePreferences({ enabledWorkoutTypes: normalizedTypes });
};
const handleReset = () => {
@@ -345,4 +348,4 @@ const styles = StyleSheet.create({
fontSize: 16,
fontWeight: '600',
},
});
});