This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@main | |
struct SomeApp: App { | |
@State var path: [Int] = [] | |
var body: some Scene { | |
return WindowGroup { | |
NavigationStack(path: $path) { | |
Button("Push") { | |
path.append(1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
protocol StoreKey { | |
associatedtype Value | |
static func defaultValue() -> Value | |
} | |
struct MyKey: StoreKey { | |
typealias Value = Int | |
static func defaultValue() -> Int { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftUI | |
struct ContentView: View { | |
var body: some View { | |
VStack { | |
Text("Regular") | |
Text("*Italics*") | |
Text("**Bold**") | |
Text("~Strikethrough~") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ChildSize: PreferenceKey { | |
typealias Value = CGSize | |
static var defaultValue: Value { | |
return .zero | |
} | |
static func reduce(value: inout Value, nextValue: () -> Value) { | |
value = nextValue() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} | |
} | |
} |