Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Intan Nurjanah intan1907

🏠
Working from home
  • Bandung, Indonesia
  • 05:40 (UTC +07:00)
View GitHub Profile
@intan1907
intan1907 / DetailRecipeView.swift
Created Jun 17, 2021
Completed DetailRecipeView.swift for HeartyRecipe App in Widget Tutorial
View DetailRecipeView.swift
//
// DetailRecipeView.swift
// HeartyRecipe
//
// Created by Intan Nurjanah on 03/06/21.
//
import SwiftUI
struct DetailRecipeView: View {
@intan1907
intan1907 / RecipeRow.swift
Created Jun 17, 2021
Completed RecipeRow.swift for HeartyRecipe App in Widget Tutorial
View RecipeRow.swift
//
// RecipeRow.swift
// HeartyRecipe
//
// Created by Intan Nurjanah on 03/06/21.
//
import SwiftUI
import HeartyRecipeHelper
View SceneDelegate.swift
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 Jun 16, 2021
HeartyRecipeWidgetSmallView with widgetURL modifier
View HeartyRecipeWidgetView.swift
// ...
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 Jun 16, 2021
RecipeBaseClass with widgetURL property
View RecipeBaseClass.swift
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?
View HeartyRecipeWidgetView.swift
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 Jun 16, 2021
HeartyRecipeWidgetSmallView
View HeartyRecipeWidgetView.swift
// ...
struct HeartyRecipeWidgetSmallView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
VStack(alignment: .leading) {
Image.loadLocalImage(image: recipe?.imageURL ?? "")
View HeartyRecipeWidgetView.swift
// ...
struct HeartyRecipeWidgetLargeView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
GeometryReader { geometry in
@intan1907
intan1907 / HeartyRecipeWidgetView.swift
Last active Jun 16, 2021
HeartyRecipeWidgetMediumView
View HeartyRecipeWidgetView.swift
// ...
struct HeartyRecipeWidgetMediumView: View {
var recipe: RecipeBaseClass?
var body: some View {
ZStack(alignment: .top) {
Color(.white)
GeometryReader {
geometry in
@intan1907
intan1907 / HeartyRecipeWidget.swift
Created Jun 16, 2021
Modify the supportedFamilies in HeartyRecipeWidget
View HeartyRecipeWidget.swift
@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.")