Skip to content

Instantly share code, notes, and snippets.

View DarrenHurst's full-sized avatar

Darren Hurst DarrenHurst

View GitHub Profile
@DarrenHurst
DarrenHurst / Hahable
Created February 14, 2023 15:38
Compare the memory reference of an object. Understand that instance created in array initialization is the same reference as the constant.
struct Device: Hashable {
var iPadSerial: String
var iPadUser: String
// add hash
func hash(into hasher: inout Hasher) {
hasher.combine(iPadSerial)
//hasher.combine(iPadUser)
}
}
@DarrenHurst
DarrenHurst / dragView.swift
Created February 12, 2023 18:21
Drag and Drop Swift UI
import Foundation
import SwiftUI
struct ViewPort : View {
@State var isZoomed: Bool = false
@State var face: String
@State var isFaceShown: Bool = true
@State var boxColor: Color = .clear
@State var playerScore : Int = 0
@State var npc: Bool = true
@DarrenHurst
DarrenHurst / ViewTypeComparison.playground
Created February 11, 2023 17:33
View Type Comparison
import UIKit
import SwiftUI
protocol ViewContainer {
associatedtype view: View
}
struct View1: View, ViewContainer {
typealias view = Self
var title: String? = "Title 1"
@DarrenHurst
DarrenHurst / Hotdog.playground
Created February 11, 2023 17:30
Find the lowest priced hotdog
import UIKit
struct Item: Equatable {
var name: String?
var price: Double?
}
class a : ObservableObject {
@Published var items: [Item] = [
Item(name: "hotdogs", price:3.99),
@DarrenHurst
DarrenHurst / BackButton
Created February 9, 2023 18:49
BackButton Control, installs as modifier .backButton()
import Foundation
import SwiftUI
struct BackButton: View {
var dismissAction: () -> Void
var btnBack : some View { Button(action: {
self.dismissAction()
}) {
@DarrenHurst
DarrenHurst / FlightCenter
Created February 8, 2023 22:49
MVVM Builder Sample Animated background - spring
//
// FlightCenter.swift
// RTSPStreamer
//
// Created by Darren Hurst on 2023-02-07.
//
import Foundation
import SwiftUI
import CoreLocation
@DarrenHurst
DarrenHurst / BurgerBuilder
Created February 7, 2023 12:16
Buttons - Burger Builder - Part 2 passing builder types
//
// CartView.swift
// RTSPStreamer
//
// Created by Darren Hurst on 2023-02-05.
//
import Foundation
import SwiftUI
@DarrenHurst
DarrenHurst / BurgerView
Created February 6, 2023 03:56
Burger Builder Animated
//
// CartView.swift
// RTSPStreamer
//
// Created by Darren Hurst on 2023-02-05.
//
import Foundation
import SwiftUI
@DarrenHurst
DarrenHurst / gist:52e10d91556d4df697a651ee0a9ea5b3
Created February 5, 2023 20:31
SwiftUI Burger Builder Sample - patterns
//
// CartView.swift
// RTSPStreamer
//
// Created by Darren Hurst on 2023-02-05.
//
import Foundation
import SwiftUI
@DarrenHurst
DarrenHurst / StoreFront
Created February 4, 2023 12:04
SwiftUI MVVM Example
//
// Created by Darren Hurst on 2023-02-03.
//
import Foundation
import SwiftUI
struct Storefront: View {
@ObservedObject var view = ViewModel()