79423e3511
El bug de los pasos 5 y 6 era invisible a los tests unitarios: el contrato de datos estaba bien, lo que fallaba era que la vista se desmontaba antes de pintar el aha moment y el paywall. Hace falta recorrer la UI de verdad. Anade el target MealMoodUITests (solo simulador, sin firma) y un test que hace el onboarding entero en instalacion limpia y comprueba que Week Ready y el paywall aparecen antes de la Home. Los CTA del onboarding llevan ahora accessibilityIdentifier para que el test no dependa de los textos, que estan en 6 idiomas. Validado en los dos sentidos: pasa con el fix, y revirtiendo temporalmente markFinished: false falla en la asercion de Week Ready. Suite completa: 27 tests. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012Ks8uUcMA9mjypVK7F2Pkt
88 lines
3.1 KiB
Swift
88 lines
3.1 KiB
Swift
import SwiftUI
|
|
|
|
struct MealWindowsStepView: View {
|
|
@Binding var selection: Set<MealType>
|
|
var onNext: () -> Void
|
|
|
|
var body: some View {
|
|
VStack(spacing: 24) {
|
|
Text("meal_windows_title")
|
|
.font(.mealMoodH1)
|
|
.foregroundColor(.mealMoodTextPrimary)
|
|
.multilineTextAlignment(.leading)
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(.horizontal, 24)
|
|
.padding(.top, 12)
|
|
|
|
VStack(spacing: 12) {
|
|
ForEach(MealType.allCases, id: \.self) { mealType in
|
|
SelectionCard(
|
|
icon: mealType.icon,
|
|
title: optionTitle(mealType),
|
|
isSelected: selection.contains(mealType)
|
|
) {
|
|
withAnimation(.spring(response: 0.3)) {
|
|
if selection.contains(mealType) {
|
|
// Keep at least one meal selected.
|
|
if selection.count > 1 {
|
|
selection.remove(mealType)
|
|
}
|
|
} else {
|
|
selection.insert(mealType)
|
|
}
|
|
}
|
|
HapticManager.shared.selection()
|
|
}
|
|
}
|
|
}
|
|
.padding(.horizontal, 24)
|
|
|
|
PrimaryButton(title: String(localized: "onboarding_continue"), action: onNext)
|
|
.accessibilityIdentifier("onboarding_cta_meal_windows")
|
|
.padding(.horizontal, 24)
|
|
.padding(.top, 8)
|
|
.padding(.bottom, 40)
|
|
}
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
|
|
}
|
|
|
|
private func optionTitle(_ mealType: MealType) -> String {
|
|
let emoji: String
|
|
switch mealType {
|
|
case .breakfast: emoji = "☕️"
|
|
case .lunch: emoji = "🌞"
|
|
case .snack: emoji = "🍎"
|
|
case .dinner: emoji = "🌙"
|
|
}
|
|
return "\(emoji) \(String(localized: String.LocalizationValue(mealType.localizedKey)))"
|
|
}
|
|
}
|
|
|
|
struct SelectionCard: View {
|
|
let icon: String
|
|
let title: String
|
|
let isSelected: Bool
|
|
let action: () -> Void
|
|
|
|
var body: some View {
|
|
Button(action: action) {
|
|
HStack {
|
|
Text(title)
|
|
.font(.mealMoodBody)
|
|
.foregroundColor(.mealMoodTextPrimary)
|
|
Spacer()
|
|
Image(systemName: isSelected ? "checkmark.circle.fill" : "circle")
|
|
.foregroundColor(isSelected ? .mealMoodCoral : Color(hex: "#C4C4C4"))
|
|
.font(.system(size: 22))
|
|
}
|
|
.padding(16)
|
|
.background(Color.mealMoodSurface)
|
|
.cornerRadius(14)
|
|
.overlay(
|
|
RoundedRectangle(cornerRadius: 14)
|
|
.stroke(isSelected ? Color.mealMoodCoral : Color(hex: "#F0F0F0"), lineWidth: isSelected ? 2 : 1)
|
|
)
|
|
}
|
|
}
|
|
}
|