Created
June 16, 2021 05:05
-
-
Save intan1907/770fbaba79e10450976b8320bf1f3869 to your computer and use it in GitHub Desktop.
Completed HeartyRecipeWidgetView
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
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