This SwiftUI code creates a simple food recipe application that displays a list of recipes and their instructions. Users can select a recipe to view its detailed instructions and images for each step.
The main components of the app are the RecipeListView
and RecipeDetailView
structs, which each define a view in the app.
-
struct Recipe: Identifiable
: This struct models a recipe. Each recipe has a unique id, a title, and a list of instructions, each paired with an image name. -
struct RecipeListView: View
: This struct is the main view of the app that displays a list of recipes. It contains a@State
variablerecipes
, which stores the list of recipes. -
struct RecipeDetailView: View
: This struct displays the detailed view of a recipe, including the title and step-by-step instructions with corresponding images. -
The
RecipeListView
uses aNavigationView
andList
to display the recipes. Each row in the list is aNavigationLink
that navigates to the detail view for the tapped recipe. -
The
RecipeDetailView
uses aScrollView
andVStack
to display the recipe title and instructions. Each instruction is paired with anImage
view that displays the corresponding image from the asset catalog.
The RecipeListView
displays a list of recipes. Users can select a recipe to view its details. The RecipeDetailView
shows the recipe title and a scrollable list of instructions with corresponding images.
Feel free to explore and modify the code to enhance the functionality and design of the food recipe app!
This project is licensed under the MIT License - see the LICENSE file for details.
Special thanks to SwiftUI and Apple for providing the framework and tools to build this Food Recipe app.