codeburn/mac/Sources/CodeBurnMenubar/Data/CapacityDockInteractionState.swift
Aditya Vikram Singh 84fea9d550
feat(menubar): add native Capacity Dock (#1167)
* feat(menubar): add native capacity dock

* fix(menubar): harden dock interaction boundaries

* feat(menubar): polish native Capacity Dock for launch

- Flush top-edge docking via NSHostingView safe-area opt-out; shielding
  window level so the rail necks into the physical top like the system notch
- Liquid Glass legibility scrim so labels stay readable on light wallpapers
- Weekly-else-monthly headline window; unified severity colour bands
  (green <50 / yellow / orange / red) across rings and detail bars
- Squircle gauge + graphite theme defaults; auto-show connected
  subscriptions (up to 5) until the user edits the set, then respect it
- Capacity Dock Settings menu item; re-centre the settings window; info
  glyph for the About row
- Trim dead provider-credential override fields down to apiKey only
- Reconcile and extend tests for all of the above

---------

Co-authored-by: iamtoruk <hello@agentseal.org>
2026-08-29 00:37:30 -07:00

71 lines
1.9 KiB
Swift

import Foundation
/// Immediate interaction truth for Capacity Dock. Hover/collapse delays are
/// scheduled by the controller; this value only decides whether a delayed
/// action is still valid when it fires.
struct CapacityDockInteractionState: Equatable, Sendable {
private(set) var isRailHovered = false
private(set) var isDetailHovered = false
private(set) var isPinned = false
private(set) var isCollapseGraceActive = false
private(set) var isDragging = false
init(
isRailHovered: Bool = false,
isDetailHovered: Bool = false,
isPinned: Bool = false
) {
self.isRailHovered = isRailHovered
self.isDetailHovered = isDetailHovered
self.isPinned = isPinned
}
var isExpanded: Bool {
isPinned || isRailHovered || isDetailHovered || isCollapseGraceActive
}
var canCollapse: Bool {
!isPinned && !isRailHovered && !isDetailHovered && !isCollapseGraceActive && !isDragging
}
var acceptsHoverTransitions: Bool { !isDragging }
mutating func setRailHovered(_ hovered: Bool) {
isRailHovered = hovered
if hovered { isCollapseGraceActive = false }
}
mutating func beginRailExitGrace() {
isRailHovered = false
isCollapseGraceActive = true
}
mutating func completeCollapseGrace() {
isCollapseGraceActive = false
}
mutating func beginDragging() {
isDragging = true
}
mutating func endDragging() {
isDragging = false
}
mutating func setDetailHovered(_ hovered: Bool) {
isDetailHovered = hovered
}
mutating func togglePinned() {
isPinned.toggle()
}
mutating func dismiss() {
self = CapacityDockInteractionState()
}
@discardableResult
mutating func handleEscape() -> Bool {
guard isExpanded else { return false }
dismiss()
return true
}
}