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 AbbreviatedIntegerStyle: FormatStyle { | |
typealias FormatInput = Int | |
typealias FormatOutput = String | |
func format(_ value: Int) -> String { | |
let absolute = abs(value) | |
let number = Double(value) | |
func rnd(_ number: Double) -> String { |
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
/// Provides a task modifier with an optional binding that will run the task if the binding is set to a | |
/// non-nil value and reset it to nil once the task is done. | |
/// | |
/// The purpose of this is to bind a one-shot task to the view, i.e. the cancellation is automatically | |
/// performed if the view should be dismissed. | |
struct TaskViewModifier<T: Equatable>: ViewModifier { | |
@Binding var taskId: T? | |
let action: @Sendable (_: T) 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
import SwiftUI | |
struct TaskTrigger<T: Equatable>: Equatable { | |
fileprivate enum TaskState<S: Equatable>: Equatable { | |
case inactive | |
case active(value: S, uniqueId: UUID? = nil) | |
} | |
fileprivate var state: TaskState<T> = .inactive |