Advertisement
Xaniasty

Untitled

May 24th, 2024
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import SwiftUI
  2.  
  3. struct RecipeGridItem: View {
  4. var recipe: Recipe
  5.  
  6. var body: some View {
  7. VStack {
  8. if let uiImage = UIImage(named: recipe.filename) {
  9. Image(uiImage: uiImage)
  10. .resizable()
  11. .aspectRatio(contentMode: .fill)
  12. .frame(width: 150, height: 150)
  13. .clipped()
  14. }
  15. Text(recipe.name)
  16. .font(.headline)
  17. .padding(.top, 5)
  18. }
  19. }
  20. }
  21.  
  22. struct RecipeGridItem_Previews: PreviewProvider {
  23. static var previews: some View {
  24. let sampleRecipe = Recipe(id: 1, name: "Sample Recipe", filename: "sample.jpg", description: "This is a sample recipe description", estimatedTime: "30 mins")
  25. return RecipeGridItem(recipe: sampleRecipe)
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement