feat: canvas-confetti style celebration + Quick Add callback
Confetti: - 60 particles in 3 layered bursts (like canvas-confetti) - Circles, rectangles, stars in 12 vibrant colors - Physics: drift, spin, gravity, fade, scale - Checkmark + 'Added!' text with spring animation - Haptic feedback Quick Add: - FoodSearchView + AddFoodSheet now have onFoodAdded callback - After adding from Quick Add: dismiss → fitness tab → confetti Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import SwiftUI
|
||||
struct AddFoodSheet: View {
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
let food: Food
|
||||
var onFoodAdded: (() -> Void)?
|
||||
|
||||
@State private var quantity: Double = 1.0
|
||||
@State private var selectedMeal: MealType = .snack
|
||||
@@ -234,6 +235,7 @@ struct AddFoodSheet: View {
|
||||
)
|
||||
_ = try await FitnessRepository.shared.createEntry(request)
|
||||
dismiss()
|
||||
onFoodAdded?()
|
||||
} catch {
|
||||
self.error = error.localizedDescription
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import SwiftUI
|
||||
|
||||
struct FoodSearchView: View {
|
||||
var isSheet: Bool = false
|
||||
var onFoodAdded: (() -> Void)?
|
||||
@State private var vm = FoodSearchViewModel()
|
||||
@State private var selectedFood: Food?
|
||||
|
||||
@@ -48,7 +49,7 @@ struct FoodSearchView: View {
|
||||
vm.search()
|
||||
}
|
||||
.sheet(item: $selectedFood) { food in
|
||||
AddFoodSheet(food: food)
|
||||
AddFoodSheet(food: food, onFoodAdded: onFoodAdded)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user