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 Swift | |
public struct Color: Sendable { | |
/// The red component of the color. | |
/// | |
/// This property is not part of the public interface of the testing | |
/// library as we may wish to support non-RGB color spaces in the future. | |
internal var redComponent: UInt8 | |
/// The green component of the color. |
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 | |
public extension View { | |
func pinned<T: Hashable>(id: Binding<T?>) -> some View { | |
modifier(Pinned(pinnedId: .init( | |
get: { id.wrappedValue }, | |
set: { id.wrappedValue = $0 as? T } | |
))) | |
} | |
} |
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
public enum Direction { | |
case forward | |
case backward | |
} | |
internal var player: AVPlayer? | |
private var isSeekInProgress = false | |
private var chaseTime = kCMTimeZero | |
private var preferredFrameRate: Float = 23.98 |
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 | |
extension Optional { | |
public func flatMap<U>(_ transform: (Wrapped) async throws -> U?) async rethrows -> U? { | |
switch self { | |
case .some(let wrapped): | |
return try await transform(wrapped) | |
case .none: | |
return nil | |
} |
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 | |
#if os(macOS) | |
public typealias Font = NSFont | |
public typealias FontDescriptor = NSFontDescriptor | |
#else | |
public typealias Font = UIFont | |
public typealias FontDescriptor = UIFontDescriptor | |
#endif |
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 Swift | |
extension Sequence { | |
/// Returns the number of elements matching the closure predicate. | |
/// | |
/// The `isIncluded` closure is called sequentially comparing each | |
/// element to determine the number of matches found. | |
/// This example shows how to find the number of elements matching | |
/// the given predicate. | |
/// |
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
public extension CGPoint { | |
// The target points after decelerating to 0 velocity at a constant rate | |
func target(initialVelocity: CGPoint, decelerationRate: CGFloat = UIScrollView.DecelerationRate.normal.rawValue) -> CGPoint { | |
let x = self.x + self.x.target(initialVelocity: initialVelocity.x, decelerationRate: decelerationRate) | |
let y = self.y + self.y.target(initialVelocity: initialVelocity.y, decelerationRate: decelerationRate) | |
return CGPoint(x: x, y: y) | |
} | |
} |
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
extension UIFont { | |
// The `rawValue` MUST match the filename (without extension) | |
public enum Graphik: String, FontCacheDescriptor { | |
case regular = "GraphikAltWeb-Regular" | |
case medium = "GraphikAltWeb-Medium" | |
case regularItalic = "GraphikAltWeb-RegularItalic" | |
case mediumItalic = "GraphikAltWeb-MediumItalic" | |
} | |
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 | |
#if os(iOS) || os(macOS) | |
#if os(iOS) | |
typealias PlatformView = UIView | |
typealias PlatformViewController = UIViewController | |
#else | |
typealias PlatformView = NSView | |
typealias PlatformViewController = NSViewController |
NewerOlder