watch: fix del sync que nunca llegaba y rediseno estilo Calendar/Weather

- El primer push se descartaba: updateApplicationContext se llamaba antes
  de que WCSession terminara de activarse (activacion asincrona). Ahora
  la sesion se activa al arrancar la app (ContentView), el payload
  pendiente se envia al completarse la activacion, y ademas el reloj
  PIDE los datos al abrirse (sendMessage despierta al iPhone en segundo
  plano y responde con el snapshot del app group)
- Rediseno: Hoy con cabecera del dia en coral y tarjetas degradadas por
  comida (estilo Weather); Semana con circulo de dia a la izquierda y
  hoy relleno en coral (estilo Calendar); complicacion con iconos
  tintados por comida y widgetAccentable
- Verificado con capturas en simulador de Watch sembrando el app group

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013H6bXqGX1ygwib1Dm3n3UG
This commit is contained in:
alexandrev-tibco
2026-09-08 23:32:55 +02:00
parent db36054df0
commit bd8090c845
8 changed files with 216 additions and 55 deletions
+17 -4
View File
@@ -84,17 +84,20 @@ struct TodayComplicationView: View {
VStack(alignment: .leading, spacing: 2) {
if let day = entry.day {
ForEach(Array(day.meals.prefix(3).enumerated()), id: \.offset) { _, meal in
HStack(spacing: 3) {
HStack(spacing: 4) {
Image(systemName: WatchWeekPayload.icon(for: meal.type))
.font(.system(size: 9))
.font(.system(size: 9, weight: .bold))
.foregroundStyle(accent(for: meal.type))
.widgetAccentable()
.frame(width: 11)
Text(meal.name ?? "")
.font(.system(size: 12, weight: .medium))
.font(.system(size: 12, weight: .semibold, design: .rounded))
.lineLimit(1)
}
}
} else {
Text(verbatim: "MealMood")
.font(.system(size: 12, weight: .semibold))
.font(.system(size: 12, weight: .semibold, design: .rounded))
Image(systemName: "iphone.and.arrow.forward")
.font(.system(size: 10))
.foregroundStyle(.secondary)
@@ -104,6 +107,16 @@ struct TodayComplicationView: View {
}
}
private func accent(for mealType: String) -> Color {
switch mealType {
case "breakfast": return Color(red: 0.95, green: 0.68, blue: 0.25)
case "lunch": return Color(red: 0.98, green: 0.55, blue: 0.30)
case "snack": return Color(red: 0.62, green: 0.50, blue: 0.83)
case "dinner": return Color(red: 0.28, green: 0.62, blue: 0.55)
default: return Color(red: 1.0, green: 0.45, blue: 0.35)
}
}
/// Lunch until 16:00 local, dinner after simple heuristic for the small families.
private var nextMeal: WatchWeekPayload.Meal? {
guard let meals = entry.day?.meals, !meals.isEmpty else { return nil }