Created
June 17, 2021 11:08
-
-
Save intan1907/f4b67ce3ba4f4f9b76325abf8b05260c to your computer and use it in GitHub Desktop.
Completed RecipeRow.swift for HeartyRecipe App in Widget Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// RecipeRow.swift | |
// HeartyRecipe | |
// | |
// Created by Intan Nurjanah on 03/06/21. | |
// | |
import SwiftUI | |
import HeartyRecipeHelper | |
struct RecipeRow: View { | |
var recipe: RecipeBaseClass? | |
var body: some View { | |
HStack(alignment: .top) { | |
Image.loadLocalImage(image: recipe?.imageURL ?? "") | |
.centerCropped() | |
.frame(width: 64, height: 48) | |
VStack(alignment: .leading) { | |
Text(recipe?.name ?? "") | |
.font(.system(size: 14, weight: .semibold, design: .default)) | |
.padding(.bottom, 1) | |
Text("Ready in: \(recipe?.getTime() ?? "30 mins")") | |
.font(.system(size: 12, weight: .regular, design: .default)) | |
.foregroundColor(Color.gray) | |
Text("Serves: \(recipe?.serving ?? "1 portion")") | |
.font(.system(size: 12, weight: .regular, design: .default)) | |
.foregroundColor(Color.gray) | |
} | |
} | |
} | |
} | |
struct RecipeRow_Previews: PreviewProvider { | |
static var previews: some View { | |
RecipeRow(recipe: recipeData?[0]).previewLayout(.fixed(width: 300, height: 64)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment