Advertisement
Xaniasty

Untitled

May 24th, 2024
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 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. }
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. import SwiftUI
  35.  
  36. struct RecipeDetailView: View {
  37. var recipe: Recipe
  38.  
  39. var body: some View {
  40. VStack {
  41. Image(recipe.filename)
  42. .resizable()
  43. .aspectRatio(contentMode: .fit)
  44. .frame(height: 200)
  45.  
  46. Text(recipe.name)
  47. .font(.title)
  48. .padding()
  49.  
  50. Text(recipe.description)
  51. .font(.body)
  52. .padding()
  53. }
  54. .navigationTitle(recipe.name)
  55. }
  56. }
  57.  
  58. struct RecipeDetailView_Previews: PreviewProvider {
  59. static var previews: some View {
  60. let sampleRecipe = Recipe(id: 1, name: "Sample Recipe", filename: "sample.jpg", description: "This is a sample recipe description", estimatedTime: "30 mins")
  61. return RecipeDetailView(recipe: sampleRecipe)
  62. }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement