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) {
|
.sheet(isPresented: $showAssistant) {
|
||||||
AssistantSheetView(onFoodAdded: foodAdded)
|
AssistantSheetView(onFoodAdded: foodAdded)
|
||||||
}
|
}
|
||||||
|
.onOpenURL { url in
|
||||||
|
if url.scheme == "platform" && url.host == "add-food" {
|
||||||
|
selectedTab = 1 // Fitness tab
|
||||||
|
showAssistant = true
|
||||||
|
}
|
||||||
|
}
|
||||||
.task {
|
.task {
|
||||||
guard showReader else { return }
|
guard showReader else { return }
|
||||||
let renderer = ArticleRenderer.shared
|
let renderer = ArticleRenderer.shared
|
||||||
|
|||||||
@@ -290,6 +290,7 @@ struct PlatformWidget: Widget {
|
|||||||
var body: some WidgetConfiguration {
|
var body: some WidgetConfiguration {
|
||||||
StaticConfiguration(kind: kind, provider: CalorieProvider()) { entry in
|
StaticConfiguration(kind: kind, provider: CalorieProvider()) { entry in
|
||||||
PlatformWidgetEntryView(entry: entry)
|
PlatformWidgetEntryView(entry: entry)
|
||||||
|
.widgetURL(URL(string: "platform://add-food"))
|
||||||
.containerBackground(.fill.tertiary, for: .widget)
|
.containerBackground(.fill.tertiary, for: .widget)
|
||||||
}
|
}
|
||||||
.configurationDisplayName("Calories")
|
.configurationDisplayName("Calories")
|
||||||
|
|||||||
Reference in New Issue
Block a user