feat: widget has two tap targets — fitness + add food
Widget background tap → platform://fitness → opens Fitness tab Widget + button tap → platform://add-food → opens Fitness + food assistant Small widget: + button in bottom-right corner (emerald green) Medium widget: + button in bottom-right corner Lock screen widgets: single tap → fitness (no room for + button) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -121,9 +121,15 @@ struct MainTabView: View {
|
||||
AssistantSheetView(onFoodAdded: foodAdded)
|
||||
}
|
||||
.onOpenURL { url in
|
||||
if url.scheme == "platform" && url.host == "add-food" {
|
||||
selectedTab = 1 // Fitness tab
|
||||
guard url.scheme == "platform" else { return }
|
||||
switch url.host {
|
||||
case "fitness":
|
||||
selectedTab = 1
|
||||
case "add-food":
|
||||
selectedTab = 1
|
||||
showAssistant = true
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
.task {
|
||||
|
||||
@@ -184,14 +184,23 @@ struct SmallWidgetView: View {
|
||||
let entry: CalorieEntry
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
VStack(spacing: 8) {
|
||||
CalorieRingView(entry: entry, size: 90, lineWidth: 8)
|
||||
CalorieRingView(entry: entry, size: 80, lineWidth: 7)
|
||||
|
||||
Text("\(Int(entry.remaining)) left")
|
||||
.font(.caption2.weight(.medium))
|
||||
.foregroundStyle(.secondary)
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
|
||||
// + button — separate tap target → opens food assistant
|
||||
Link(destination: URL(string: "platform://add-food")!) {
|
||||
Image(systemName: "plus.circle.fill")
|
||||
.font(.title2)
|
||||
.foregroundStyle(Color(red: 0.020, green: 0.588, blue: 0.412))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +208,7 @@ struct MediumWidgetView: View {
|
||||
let entry: CalorieEntry
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
HStack(spacing: 20) {
|
||||
CalorieRingView(entry: entry, size: 100, lineWidth: 9)
|
||||
|
||||
@@ -217,6 +227,13 @@ struct MediumWidgetView: View {
|
||||
}
|
||||
}
|
||||
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
||||
|
||||
Link(destination: URL(string: "platform://add-food")!) {
|
||||
Image(systemName: "plus.circle.fill")
|
||||
.font(.title2)
|
||||
.foregroundStyle(Color(red: 0.020, green: 0.588, blue: 0.412))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,7 +307,7 @@ struct PlatformWidget: Widget {
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: CalorieProvider()) { entry in
|
||||
PlatformWidgetEntryView(entry: entry)
|
||||
.widgetURL(URL(string: "platform://add-food"))
|
||||
.widgetURL(URL(string: "platform://fitness"))
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
}
|
||||
.configurationDisplayName("Calories")
|
||||
|
||||
Reference in New Issue
Block a user