Something went wrong. Try again.
An auto tiler for macOS
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940public struct ActivityTotals: Codable, Equatable, Sendable { public private(set) var keyboard: Int public private(set) var mouse: Int public private(set) var other: Int
public init(keyboard: Int = 0, mouse: Int = 0, other: Int = 0) { precondition(keyboard >= 0 && mouse >= 0 && other >= 0) self.keyboard = keyboard self.mouse = mouse self.other = other }
public var placements: Int { keyboard + mouse + other } public var keyboardShare: Double? { let manual = keyboard + mouse return manual == 0 ? nil : Double(keyboard) / Double(manual) } public var estimatedSecondsSaved: Double { Double(placements) * 2 }
mutating func add(_ source: ActivitySource, count: Int) { precondition(count > 0) switch source { case .keyboard: keyboard += count case .mouse: mouse += count case .other: other += count } }
mutating func add(_ totals: Self) { keyboard += totals.keyboard mouse += totals.mouse other += totals.other }
var isValid: Bool { keyboard >= 0 && mouse >= 0 && other >= 0 && keyboard <= Int.max / 3 && mouse <= Int.max / 3 && other <= Int.max / 3 }}