Skip to content

Instantly share code, notes, and snippets.

@intan1907
Last active June 16, 2021 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intan1907/3ccbe30aeac62284032c312186de1dd2 to your computer and use it in GitHub Desktop.
Save intan1907/3ccbe30aeac62284032c312186de1dd2 to your computer and use it in GitHub Desktop.
// ...
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