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 View { | |
func font<T: BinaryFloatingPoint>(_ scaled: Scaled<T>) -> some View { | |
modifier(ScaledFontModifier(metric: scaled.value)) | |
} | |
} | |
public struct Scaled<T: BinaryFloatingPoint> { | |
fileprivate let value: T | |
public static func scaled(size: T) -> Self { | |
.init(value: size) |
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
/* Box sizing rules */ | |
*, | |
*::before, | |
*::after { | |
box-sizing: border-box; | |
} | |
/* Remove default margin */ | |
html, | |
body, |
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 | |
struct ScopeError: LocalizedError { | |
let url: URL | |
var errorDescription: String? { | |
"Unabled to gain scoped access to the url: \(url)" | |
} | |
} | |
extension URL { |
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 | |
extension EnvironmentValues { | |
var dump: String { | |
let keys = asTextualRepresentationWithNonReaptingKeys | |
return """ | |
--- Environment Values - BEGIN --- | |
\(keys.map { $0 }.joined(separator: "\n")) | |
--- Environment Values - END --- |
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 SwifUI | |
public struct Geometry: Equatable { | |
fileprivate var proxy: GeometryProxy? | |
public var size: CGSize = .init(width: 10, height: 10) | |
public var safeAreaInsets: EdgeInsets = .init() | |
public func frame(in coordinateSpace: CoordinateSpaceProtocol) -> CGRect { | |
proxy?.frame(in: coordinateSpace) ?? .init(origin: .zero, size: size) | |
} |
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 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Alpha Component</key> | |
<real>1</real> | |
<key>Blue Component</key> | |
<real>0.10980392247438431</real> |
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
xcrun simctl spawn booted defaults write -g SBChamoisWindowingEnabled -bool true |
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
extension Binding { | |
public init(wrappedValue: Binding<Value?>, defaultValue: Value) { | |
self = Binding<Value>( | |
get: { wrappedValue.wrappedValue ?? defaultValue }, | |
set: { wrappedValue.wrappedValue = $0 } | |
) | |
} | |
public func defaultValue<T>(_ value: T) -> Binding<T> where Value == T? { | |
Binding<T>( |