Last active
June 16, 2021 08:55
-
-
Save intan1907/3ccbe30aeac62284032c312186de1dd2 to your computer and use it in GitHub Desktop.
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
// ... | |
struct HeartyRecipeWidgetLargeView: View { | |
var recipe: RecipeBaseClass? | |
var body: some View { | |
ZStack(alignment: .top) { | |
Color(.white) | |
GeometryReader { geometry in | |
VStack(alignment: .leading) { | |
Text(recipe?.name ?? "") | |
.font(.system(size: 16, weight: .semibold, design: .default)) | |
.multilineTextAlignment(.leading) | |
Image.loadLocalImage(image: recipe?.imageURL ?? "") | |
.centerCropped() | |
.frame(height: geometry.size.width/2) | |
.cornerRadius(10) | |
VStack(alignment: .leading, spacing: 2) { | |
HStack(alignment: .top, spacing: 2) { | |
Text("Ready in: ") | |
.font(.system(size: 12, weight: .semibold, design: .default)) | |
.fontWeight(.semibold) | |
Text("\(recipe?.getTime() ?? "30 mins")") | |
.font(.system(size: 12, weight: .regular, design: .default)) | |
} | |
HStack(alignment: .top, spacing: 2) { | |
Text("Serves: ") | |
.font(.system(size: 12, weight: .semibold, design: .default)) | |
.fontWeight(.semibold) | |
Text("\(recipe?.serving ?? "1 portion")") | |
.font(.system(size: 12, weight: .regular, design: .default)) | |
} | |
} | |
// ingredients string | |
let array: [String] = recipe?.ingredients?.map({ | |
$0.name ?? "" | |
}) ?? [] | |
let ingredients = array.joined(separator: "; ") | |
(Text("Ingredients: ").fontWeight(.bold) + Text("\(ingredients)")) | |
.font(.system(size: 12, weight: .regular, design: .default)) | |
.padding(.top, 2) | |
// instruction string | |
let steps = (recipe?.steps ?? []).joined(separator: " • ") | |
(Text("Instructions: ").fontWeight(.bold) + Text("\(steps)")) | |
.font(.system(size: 12, weight: .regular, design: .default)) | |
.padding(.top, 2) | |
} | |
} | |
.padding() | |
} | |
} | |
} | |
// ... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment