Add Share Extension for importing recipes via URL
Adds a Share Extension so users can share URLs from Safari (or any app) to open the main app with the ImportURLSheet pre-filled. Uses a custom URL scheme (nextcloud-cookbook://) as the bridge between the extension and the main app. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,8 @@ struct MainView: View {
|
||||
|
||||
@State private var selectedTab: Tab = .recipes
|
||||
|
||||
@Binding var pendingImportURL: String?
|
||||
|
||||
enum Tab {
|
||||
case recipes, search, mealPlan, groceryList
|
||||
}
|
||||
@@ -106,5 +108,19 @@ struct MainView: View {
|
||||
}
|
||||
recipeViewModel.presentLoadingIndicator = false
|
||||
}
|
||||
.onChange(of: pendingImportURL) { _, newURL in
|
||||
guard let url = newURL, !url.isEmpty else { return }
|
||||
selectedTab = .recipes
|
||||
recipeViewModel.pendingImportURL = url
|
||||
// Dismiss any currently open import sheet before re-presenting
|
||||
if recipeViewModel.showImportURLSheet {
|
||||
recipeViewModel.showImportURLSheet = false
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) {
|
||||
recipeViewModel.showImportURLSheet = true
|
||||
}
|
||||
} else {
|
||||
recipeViewModel.showImportURLSheet = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user