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 CarouselView: View { | |
@State private var currentCardIndex = 2 | |
@GestureState private var dragOffset: CGFloat = 0 | |
@State private var sampleArray = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] | |
var body: some View { | |
HStack(spacing: 0) { |
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
// Logger.swift | |
import Foundation | |
import os.log | |
// swiftlint:disable line_length | |
func log(_ messages: Any..., file: String = #fileID, function: String = #function, line: Int = #line) { | |
// actually impossible cases | |
guard let appName = Bundle.main.object(forInfoDictionaryKey: "CFBundleName") as? String else { | |
return print("Unable to get App Name") |
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) { |
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
.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
// 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
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
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
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) | |
} | |
OlderNewer