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
// Specify the decimal place to round to using an enum | |
public enum RoundingPrecision { | |
case ones | |
case tenths | |
case hundredths | |
} | |
// Round to the specific decimal place | |
public func preciseRound( | |
_ value: Double, |
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 { | |
var body: some View { | |
VStack { | |
Text("Hello, world!") | |
.dynamicColor((.blue, .red)) | |
} | |
.padding() | |
} |
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 Network | |
class PathMonitor: ObservableObject { | |
@Published private(set) var status: NWPath.Status | |
private let pathMonitor = NWPathMonitor() | |
private let pathMonitorQueue = DispatchQueue(label: "NWPathMonitor") | |
init(status: NWPath.Status = .unsatisfied, active: Bool = true) { | |
self.status = status |
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
@propertyWrapper | |
public struct IgnoreEquatable<Wrapped>: Equatable { | |
public var wrappedValue: Wrapped | |
public static func == ( | |
lhs: IgnoreEquatable<Wrapped>, | |
rhs: IgnoreEquatable<Wrapped> | |
) -> 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
@propertyWrapper | |
struct Versioned<Value> { | |
private var currentValue: Value | |
private(set) var history: [Value] = [] | |
init(wrappedValue: Value) { | |
self.currentValue = wrappedValue | |
} | |
var wrappedValue: Value { |
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 | |
/// API's out of our control can sometimes callback more than once, causing the continuation to crash | |
/// This class is a wrapper that should avoid this crash | |
/// Not recommended to be used largely, but it can help if really needed to use the problematic API | |
public class NullableContinuation<T, E> where E : Error { | |
private var checkedContinuation: CheckedContinuation<T,E>? | |
public init(checkedContinuation: CheckedContinuation<T,E>) { |