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 SwiftUI | |
import MapKit | |
struct ContentView: View { | |
@State var region = MKCoordinateRegion() | |
@State var touching = false | |
var body: some View { | |
MapView( | |
region: $region, |
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
@Observable | |
class VM { | |
var counter = 0 | |
} | |
struct ContentView: View { | |
@State var vm = VM() | |
var body: some View { | |
// doesn't get executed on button tap |
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
final class TaskQueue: Sendable { | |
private actor TaskQueueActor { | |
private var blocks = [() async -> Void]() | |
private var currentTask: Task<Void, Never>? | |
func addBlock(priority: TaskPriority? = nil, block: @escaping @Sendable () async -> Void) { | |
blocks.append(block) | |
next(priority: priority) | |
} | |
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 SwiftUI | |
struct ContentView: View { | |
@State var data: [String] = (0 ..< 25).map { String($0) } | |
@State var dataID: String? | |
var dataIDText: String { | |
dataID.map(String.init(describing:)) ?? "None" | |
} | |
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 Combine | |
import SwiftUI | |
// https://stackoverflow.com/questions/58896661/swiftui-create-image-slider-with-dots-as-indicators | |
struct CarouselView<Content>: View where Content: View { | |
let maxIndex: Int | |
var content: () -> Content | |
@State private var offset = CGFloat.zero | |
@State private var dragging = false |
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
// PublishedAppStorage.swift | |
import Combine | |
import SwiftUI | |
@propertyWrapper | |
struct PublishedAppStorage<Value> { | |
@UserDefault private var storedValue: Value | |
private var publisher: Publisher? |
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
.review-page .file.root .file .wavy.edge { | |
background-image: none; | |
} | |
.review-page .file.root .file .top.wavy.edge { | |
margin-top: 1em; | |
margin-bottom: -0.5em; | |
} | |
.review-page .file.root .file .bottom.wavy.edge { |
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 VisibleKey: PreferenceKey { | |
static var defaultValue: Bool = false | |
static func reduce(value: inout Bool, nextValue: () -> Bool) { } | |
} | |
private struct OnVisible: ViewModifier { | |
@State var action: (() -> Void)? | |
func body(content: Content) -> some View { |
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
// TaskQueue.swift | |
import Foundation | |
class TaskQueue { | |
private actor TaskQueueActor { | |
private var blocks = [() async -> Void]() | |
private var currentTask: Task<Void, Never>? | |
func addBlock(priority: TaskPriority? = nil, block: @escaping () async -> Void) { |
NewerOlder