Skip to content

Instantly share code, notes, and snippets.

View jhowlin's full-sized avatar

Jason Howlin jhowlin

View GitHub Profile
class CounterController: ObservableObject {
static let shared = CounterController()
var timer:Timer?
@Published var numTimes = 0
init() {
timer = Timer.scheduledTimer(withTimeInterval: 3, repeats: true) { [weak self] timer in
self?.numTimes += 1
}
}
}
struct ChildSize: PreferenceKey {
typealias Value = CGSize
static var defaultValue: Value {
return .zero
}
static func reduce(value: inout Value, nextValue: () -> Value) {
value = nextValue()
}
}
struct SwipeCell: View {
@State var buttonsWidth: CGFloat = 0
@State var cellContentOffset: CGFloat = 0
@GestureState var dragState:DragGesture.Value? = nil
var body: some View {
GeometryReader { geometry in
HStack {
Rectangle().frame(height:120).foregroundColor(.purple).cornerRadius(7)
import Foundation
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Regular")
Text("*Italics*")
Text("**Bold**")
Text("~Strikethrough~")
import Foundation
protocol StoreKey {
associatedtype Value
static func defaultValue() -> Value
}
struct MyKey: StoreKey {
typealias Value = Int
static func defaultValue() -> Int {