feat: tap widget → opens app to food search
Widget: .widgetURL(platform://add-food) on all widget sizes App: .onOpenURL handles platform://add-food → switches to Fitness tab and opens the food assistant sheet Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -120,6 +120,12 @@ struct MainTabView: View {
|
||||
.sheet(isPresented: $showAssistant) {
|
||||
AssistantSheetView(onFoodAdded: foodAdded)
|
||||
}
|
||||
.onOpenURL { url in
|
||||
if url.scheme == "platform" && url.host == "add-food" {
|
||||
selectedTab = 1 // Fitness tab
|
||||
showAssistant = true
|
||||
}
|
||||
}
|
||||
.task {
|
||||
guard showReader else { return }
|
||||
let renderer = ArticleRenderer.shared
|
||||
|
||||
@@ -290,6 +290,7 @@ struct PlatformWidget: Widget {
|
||||
var body: some WidgetConfiguration {
|
||||
StaticConfiguration(kind: kind, provider: CalorieProvider()) { entry in
|
||||
PlatformWidgetEntryView(entry: entry)
|
||||
.widgetURL(URL(string: "platform://add-food"))
|
||||
.containerBackground(.fill.tertiary, for: .widget)
|
||||
}
|
||||
.configurationDisplayName("Calories")
|
||||
|
||||
Reference in New Issue
Block a user