This file contains hidden or 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 AppKit | |
import SwiftUI | |
class PromptWindowController: NSWindowController, NSWindowDelegate { | |
// Essential properties | |
private var promptWindowContext: PromptWindowContext | |
private let finderContext: FinderContext | |
init() { |
This file contains hidden or 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 | |
struct ShellCommand { | |
@discardableResult | |
static func stream(_ command: String) -> Int32 { | |
let outputPipe = Pipe() | |
let task = self.createProcess([command], outputPipe) | |
outputPipe.fileHandleForReading.readabilityHandler = { fileHandle in self.streamOutput(outputPipe, fileHandle) } | |
do { |
This file contains hidden or 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
public struct Tuple<each T> { | |
public private(set) var value: (repeat each T) | |
public init(_ value: repeat each T) { self.value = (repeat each value) } | |
} | |
extension Tuple { | |
public func map<each U>( | |
_ transform: (repeat each T) throws -> (repeat each U) | |
) rethrows -> (repeat each U) { |
This file contains hidden or 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
// Cursed! Do not use! | |
// Supports most, but not all Text initializers. | |
import SwiftUI | |
extension FormatStyle { | |
func format(any value: Any) -> FormatOutput? { | |
if let v = value as? FormatInput { | |
return format(v) |
This file contains hidden or 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 CycledAnimationTimelineView<Content: View>: View { | |
var duration: Double | |
var isAnimating: Bool | |
@ViewBuilder var content: (Double) -> Content | |
@State private var isActuallyAnimating = false | |
@State private var startDate: Date? | |
var body: some View { | |
TimelineView(.animation(paused: !isActuallyAnimating)) { context in |
This file contains hidden or 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 | |
extension View { | |
/// Proposes a percentage of its received proposed size to `self`. | |
/// | |
/// This modifier multiplies the proposed size it receives from its parent | |
/// with the given factors for width and height. | |
/// | |
/// If the parent proposes `nil` or `.infinity` to us in any dimension, | |
/// we’ll forward these values to our child view unchanged. |
This file contains hidden or 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 | |
public struct MouseTrackingView: View { | |
public var callbacks: NSMouseTrackingView.Callbacks | |
public var isEnabled: Bool | |
public var options: NSTrackingArea.Options | |
public var hitEnabled: Bool | |
public var flipYAxis: Bool | |
This file contains hidden or 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
@available(iOS 15.0, *) | |
struct TwinkleView:View { | |
private func position(in proxy: GeometryProxy, sparkle:Sparkle) -> CGPoint { | |
let radius = min(proxy.size.width, proxy.size.height) / 2.0 | |
let drawnRadius = (radius - 5) * sparkle.position.x | |
let angle = Double.pi * 2.0 * sparkle.position.y | |
let x = proxy.size.width * 0.5 + drawnRadius * cos(angle) | |
let y = proxy.size.height * 0.5 + drawnRadius * sin(angle) |
This file contains hidden or 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 PlaygroundSupport | |
import SwiftUI | |
PlaygroundPage.current.setLiveView(ContentView()) | |
struct ContentView: View { | |
var body: some View { | |
Color.white.frame(width: 600, height: 800).touchVisualizer() | |
} | |
} |
This file contains hidden or 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
// TaskMeeting | |
// (c) 2022, Nikolai Ruhe | |
/// A type that synchronizes progress of two tasks. | |
public final actor TaskMeeting: Sendable { | |
private var completion: CheckedContinuation<Void, Error>? = nil | |
/// This method synchronizes two tasks so that both perform the closure at | |
/// the same time. Both tasks need to call `rendezvous`. | |
/// |
NewerOlder