Files
ShadowsocksX-NG/ShadowsocksX-NG2/App/CatalogExpansionState.swift
T
Qiu Yuzhou 1c706aa65f feat: redesign home server activation tree
Preserve catalog hierarchy and order, separate selection from activation, and mark active targets and ancestors. Persist independent home expansion preferences and support explicit locate and keyboard navigation.

Show server names only and surface activation eligibility, skipped members, and failures. Refine row status visibility and use semantic selection colors for outlined activation buttons, including hover, pressed, disabled, contrast, and inactive-window states.

Validation: 695 hostless macOS arm64 tests passed for the tree implementation; 7 focused tests and ad-hoc app compilation passed after the semantic button refinement. Format and lint checks passed. Native UI interactions and theme changes remain unverified.
2026-10-01 19:03:48 +08:00

23 lines
798 B
Swift

import Combine
/// 目录树折叠状态(纯窗口呈现状态):组合根持有的长寿命对象。destination 切换
/// 会销毁分区子树里的 `@State`,折叠状态因此必须活在视图层级之外;服务器管理分区
/// 侧栏专用,首页另行持久化自己的状态。语义=收起的分组身份集合,
/// 缺省全部展开;不落盘,进程重启回全展开基线。
@MainActor
final class CatalogExpansionState: ObservableObject {
@Published private(set) var collapsedGroupIDs: Set<NodeID> = []
func isCollapsed(_ id: NodeID) -> Bool {
collapsedGroupIDs.contains(id)
}
func toggleCollapsed(_ id: NodeID) {
if collapsedGroupIDs.contains(id) {
collapsedGroupIDs.remove(id)
} else {
collapsedGroupIDs.insert(id)
}
}
}