Add celebration animations when voting on mood
- Create 10 full-view celebration animations (vortex, explosion, flip, shatter, pulse wave, fireworks, confetti, morph, tunnel, gravity) - Play random animation when user votes in-app - Add Animation Lab debug view to preview and test animations - Animations complete before saving mood to prevent view flash 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,12 @@ struct AddMoodHeaderView: View {
|
||||
|
||||
@State var onboardingData = OnboardingDataDataManager.shared.savedOnboardingData
|
||||
|
||||
// Celebration animation state
|
||||
@State private var showCelebration = false
|
||||
@State private var celebrationMood: Mood = .great
|
||||
@State private var celebrationAnimation: CelebrationAnimationType = .pulseWave
|
||||
@State private var celebrationDate: Date = Date()
|
||||
|
||||
let addItemHeaderClosure: ((Mood, Date) -> Void)
|
||||
|
||||
init(addItemHeaderClosure: @escaping ((Mood, Date) -> Void)) {
|
||||
@@ -46,6 +52,18 @@ struct AddMoodHeaderView: View {
|
||||
.padding(.bottom)
|
||||
}
|
||||
.padding(.horizontal)
|
||||
.opacity(showCelebration ? 0 : 1)
|
||||
|
||||
// Celebration animation overlay
|
||||
if showCelebration {
|
||||
CelebrationOverlayView(
|
||||
animationType: celebrationAnimation,
|
||||
mood: celebrationMood
|
||||
) {
|
||||
// Animation complete - save the mood (parent will remove this view)
|
||||
addItemHeaderClosure(celebrationMood, celebrationDate)
|
||||
}
|
||||
}
|
||||
}
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
@@ -71,8 +89,15 @@ struct AddMoodHeaderView: View {
|
||||
let impactFeedback = UIImpactFeedbackGenerator(style: .medium)
|
||||
impactFeedback.impactOccurred()
|
||||
|
||||
let date = ShowBasedOnVoteLogics.getCurrentVotingDate(onboardingData: onboardingData)
|
||||
addItemHeaderClosure(mood, date)
|
||||
// Store mood, date, and pick random animation
|
||||
celebrationMood = mood
|
||||
celebrationDate = ShowBasedOnVoteLogics.getCurrentVotingDate(onboardingData: onboardingData)
|
||||
celebrationAnimation = .random
|
||||
|
||||
// Show celebration - mood will be saved when animation completes
|
||||
withAnimation(.easeInOut(duration: 0.3)) {
|
||||
showCelebration = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user