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
@main | |
struct HeartyRecipeWidget: Widget { | |
let kind: String = "HeartyRecipeWidget" | |
var body: some WidgetConfiguration { | |
StaticConfiguration(kind: kind, provider: Provider()) { entry in | |
HeartyRecipeWidgetEntryView(entry: entry) | |
} | |
.configurationDisplayName("Hearty Recipe Widget") | |
.description("Display a widget with a random recipe that is updated every 1 hour.") |
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 HeartyRecipeWidgetEntryView: View { | |
var entry: Provider.Entry | |
var body: some View { | |
HeartyRecipeWidgetView(recipe: entry.recipe) | |
} | |
} |
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 WidgetKit | |
import SwiftUI | |
import HeartyRecipeHelper | |
// ... | |
struct SimpleEntry: TimelineEntry { | |
let date: Date | |
let recipe: RecipeBaseClass? | |
} |
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 | |
public var recipeData: [RecipeBaseClass]? = loadJsonFromFile() | |
// load dummy data from json file | |
func loadJsonFromFile(fileName: String = "Recipes") -> [RecipeBaseClass]? { | |
// ... | |
} |
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) { |
NewerOlder