CodexBar 是一个 macOS 菜单栏应用,用于查看本机 Codex 账号状态、额度、Token 用量、详细统计信息
Swift appkitcodexcodex-clideveloper-toolsmacosmacos-appmenu-bar-appopenai-codexproductivityswiftswiftuiusage-tracker
fix: 修复任务卡片切换时主面板底边抖动
Bob6b9c11424fbc
diff --git a/CodexBar/Views/Menu/ActivitySection.swift b/CodexBar/Views/Menu/ActivitySection.swiftindex ac1d877..c6abda7 100644--- a/CodexBar/Views/Menu/ActivitySection.swift+++ b/CodexBar/Views/Menu/ActivitySection.swift@@ -93,7 +93,8 @@ private struct ActivitySectionReveal: ViewModifier, Animatable {let visibility = min(1, max(0, progress))content// 卡片按可见高度绘制背景, 内容裁剪由卡片内部负责, 外投影不参与裁剪- .frame(height: height < 0 ? nil : max(0, height), alignment: .topLeading)+ // 在活动区域按窗口精度对齐高度, 让后续卡片和面板底边同步移动+ .frame(height: height < 0 ? nil : max(0, height.rounded(.up)), alignment: .topLeading)// 连同玻璃背景和投影一起淡出, 避免末尾留下被压扁的亮边.opacity(visibility * visibility * (3 - 2 * visibility)).layoutValue(key: MenuSectionVisibilityKey.self, value: visibility)diff --git a/Config/BuildNumber.xcconfig b/Config/BuildNumber.xcconfigindex 7f82ff6..f90879c 100644--- a/Config/BuildNumber.xcconfig+++ b/Config/BuildNumber.xcconfig@@ -1,3 +1,3 @@// 请勿手动修改// Do not modify manually-CURRENT_PROJECT_VERSION = 382\ No newline at end of file+CURRENT_PROJECT_VERSION = 385\ No newline at end of filediff --git a/Tests/App/Presentation/ActivityCardSwipeTests.swift b/Tests/App/Presentation/ActivityCardSwipeTests.swiftindex 251fd27..b0c1bd4 100644--- a/Tests/App/Presentation/ActivityCardSwipeTests.swift+++ b/Tests/App/Presentation/ActivityCardSwipeTests.swift@@ -105,6 +105,54 @@ struct ActivityCardSwipeTests {}}+ @Test(arguments: [-1, 1])+ func resizingKeepsFooterInsetStableAcrossSmallDragSteps(direction: Int) {+ let swipe = ActivityCardSwipe()+ let width: CGFloat = 300+ var footerBottom: CGFloat = 0+ let root = MenuPanelLayout {+ MenuSectionLayout(spacing: 10) {+ ActivitySection(isVisible: true) {+ ActivityCardSwipePages(swipe: swipe, width: width) { step in+ Color.clear.frame(height: [80.5, 100.5, 180.5][step + 1])+ }+ .background {+ GeometryReader { geometry in+ Color.clear.preference(+ key: ActivityCardNaturalHeightKey.self,+ value: .init(height: geometry.size.height, isInteractive: true)+ )+ }+ }+ .frame(minHeight: 0, maxHeight: .infinity, alignment: .topLeading)+ }+ Color.clear.frame(height: 20.5)+ .onGeometryChange(for: CGFloat.self) { $0.frame(in: .global).maxY } action: { footerBottom = $0 }+ }+ .fixedSize(horizontal: false, vertical: true)+ .modifier(MenuContentSizing(loadState: .loaded))+ .frame(width: width)+ .padding(12)+ }+ let host = NSHostingView(rootView: root)+ host.setFrameSize(host.fittingSize)+ host.layoutSubtreeIfNeeded()+ // 初次自然高度反馈完成后再开始手势+ host.setFrameSize(host.fittingSize)+ host.layoutSubtreeIfNeeded()+ let inset = host.frame.height - footerBottom+ _ = swipe.begin(width: width, now: now)++ for _ in 0 ..< 12 {+ swipe.move(by: CGFloat(direction), width: width)+ host.layoutSubtreeIfNeeded()+ host.setFrameSize(host.fittingSize)+ host.layoutSubtreeIfNeeded()+ #expect(abs(host.frame.height - footerBottom - inset) < 0.001, "inset=\(inset), height=\(host.frame.height), footerBottom=\(footerBottom)")+ }+ #expect(host.window == nil)+ }+private func renderedHeight(_ swipe: ActivityCardSwipe, pageHeights: [CGFloat] = [60, 100, 180]) -> CGFloat {let root = ActivityCardSwipePages(swipe: swipe, width: 400) { step inColor.clear.frame(height: pageHeights[step + 1])