Skip to content

Instantly share code, notes, and snippets.

View intan1907's full-sized avatar
🏠
Working from home

Intan Nurjanah intan1907

🏠
Working from home
  • Bandung, Indonesia
  • 22:14 (UTC +07:00)
View GitHub Profile
@intan1907
intan1907 / DetailRecipeView.swift
Created June 17, 2021 11:10
Completed DetailRecipeView.swift for HeartyRecipe App in Widget Tutorial
//
// DetailRecipeView.swift
// HeartyRecipe
//
// Created by Intan Nurjanah on 03/06/21.
//
import SwiftUI
struct DetailRecipeView: View {
@intan1907
intan1907 / RecipeRow.swift
Created June 17, 2021 11:08
Completed RecipeRow.swift for HeartyRecipe App in Widget Tutorial
//
// RecipeRow.swift
// HeartyRecipe
//
// Created by Intan Nurjanah on 03/06/21.
//
import SwiftUI
import HeartyRecipeHelper
import UIKit
import SwiftUI
import HeartyRecipeHelper
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
// ...
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
@intan1907
intan1907 / HeartyRecipeWidgetView.swift
Last active June 16, 2021 09:08
HeartyRecipeWidgetSmallView with widgetURL modifier
// ...
struct HeartyRecipeWidgetSmallView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
VStack(alignment: .leading) {
Image.loadLocalImage(image: recipe?.imageURL ?? "")
@intan1907
intan1907 / RecipeBaseClass.swift
Created June 16, 2021 09:06
RecipeBaseClass with widgetURL property
public struct RecipeBaseClass: Codable, Hashable {
// ...
public var ingredients: [RecipeIngredients]?
public var originalURL: String?
public var imageURL: String?
public var steps: [String]?
public var name: String?
public var time: Int?
@intan1907
intan1907 / HeartyRecipeWidgetView.swift
Created June 16, 2021 09:02
HeartyRecipeWidgetView
import Foundation
import SwiftUI
import WidgetKit
import HeartyRecipeHelper
struct HeartyRecipeWidgetView: View {
var recipe: RecipeBaseClass?
@Environment(\.widgetFamily) var family: WidgetFamily
@intan1907
intan1907 / HeartyRecipeWidgetView.swift
Last active June 16, 2021 08:55
HeartyRecipeWidgetMediumView
// ...
struct HeartyRecipeWidgetMediumView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
GeometryReader {
geometry in
// ...
struct HeartyRecipeWidgetLargeView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
GeometryReader { geometry in
@intan1907
intan1907 / HeartyRecipeWidgetView.swift
Last active June 16, 2021 08:54
HeartyRecipeWidgetSmallView
// ...
struct HeartyRecipeWidgetSmallView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
VStack(alignment: .leading) {
Image.loadLocalImage(image: recipe?.imageURL ?? "")
@intan1907
intan1907 / HeartyRecipeWidget.swift
Created June 16, 2021 08:46
Modify the supportedFamilies in HeartyRecipeWidget
@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.")