Skip to content

Instantly share code, notes, and snippets.

@intan1907
Created June 16, 2021 05:05
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/770fbaba79e10450976b8320bf1f3869 to your computer and use it in GitHub Desktop.
Save intan1907/770fbaba79e10450976b8320bf1f3869 to your computer and use it in GitHub Desktop.
Completed HeartyRecipeWidgetView
import Foundation
import SwiftUI
import WidgetKit
import HeartyRecipeHelper
struct HeartyRecipeWidgetView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
VStack(alignment: .leading) {
Image.loadLocalImage(image: recipe?.imageURL ?? "")
.centerCropped()
.frame(height: 64)
.cornerRadius(10)
Text("\(recipe?.getTime() ?? "")\(recipe?.serving ?? "1 portion")")
.font(.system(size: 10, weight: .regular, design: .default))
Text(recipe?.name ?? "")
.font(.system(size: 12, weight: .semibold, design: .default))
.multilineTextAlignment(.leading)
}
.padding()
}
}
}
struct HeartyRecipeWidgetView_Previews: PreviewProvider {
static var previews: some View {
HeartyRecipeWidgetView(recipe: recipeData?[7])
.previewContext(WidgetPreviewContext(family: .systemSmall))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment