Skip to content

Instantly share code, notes, and snippets.

View jhowlin's full-sized avatar

Jason Howlin jhowlin

View GitHub Profile
@main
struct SomeApp: App {
@State var path: [Int] = []
var body: some Scene {
return WindowGroup {
NavigationStack(path: $path) {
Button("Push") {
path.append(1)
func postStatus(_ composedStatus: ComposedStatus) async throws -> APIStatus {
let instance = try await currentInstance()
let url = instance.instanceURL.appending(path: "/api/v1/statuses")
var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
var statusPost = EncodableStatus()
statusPost.status = composedStatus.content.text
import Foundation
protocol StoreKey {
associatedtype Value
static func defaultValue() -> Value
}
struct MyKey: StoreKey {
typealias Value = Int
static func defaultValue() -> Int {
import Foundation
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Regular")
Text("*Italics*")
Text("**Bold**")
Text("~Strikethrough~")
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)
struct ChildSize: PreferenceKey {
typealias Value = CGSize
static var defaultValue: Value {
return .zero
}
static func reduce(value: inout Value, nextValue: () -> Value) {
value = nextValue()
}
}
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
}
}
}