feat(settings): 默认启用短动效并提供独立减弱动画选项
This commit is contained in:
@@ -24,16 +24,19 @@ import Observation
|
||||
private let visibility: (Bool) -> Void
|
||||
private let menuTitle: (String) -> String
|
||||
private let openSettings: () -> Void
|
||||
private let reducedMotion: () -> Bool
|
||||
private var showingStatusMenu = false
|
||||
private var isHiding = false
|
||||
|
||||
init<Content: View>(installStatusItem: Bool = true, visibility: @escaping (Bool) -> Void,
|
||||
menuTitle: @escaping (String) -> String = { $0 },
|
||||
openSettings: @escaping () -> Void = {},
|
||||
reducedMotion: @escaping () -> Bool = { false },
|
||||
@ViewBuilder content: @escaping (PanelPresentation) -> Content) {
|
||||
self.visibility = visibility
|
||||
self.menuTitle = menuTitle
|
||||
self.openSettings = openSettings
|
||||
self.reducedMotion = reducedMotion
|
||||
self.content = {
|
||||
let host = NSHostingView(rootView: content($0))
|
||||
// The controller owns the fixed panel frame; content must not negotiate window limits.
|
||||
@@ -112,7 +115,12 @@ import Observation
|
||||
return window.convertToScreen(button.convert(button.bounds, to: nil)).contains(screenPoint)
|
||||
}
|
||||
|
||||
private func applyWindowMotion() {
|
||||
panel.animationBehavior = reducedMotion() || NSWorkspace.shared.accessibilityDisplayShouldReduceMotion ? .none : .default
|
||||
}
|
||||
|
||||
func show() {
|
||||
applyWindowMotion()
|
||||
guard !panel.isVisible else { panel.makeKeyAndOrderFront(nil); return }
|
||||
place()
|
||||
presentation.isOpen = true
|
||||
@@ -136,6 +144,7 @@ import Observation
|
||||
isHiding = true
|
||||
defer { isHiding = false }
|
||||
presentation.isOpen = false
|
||||
applyWindowMotion()
|
||||
panel.orderOut(nil)
|
||||
#if DEBUG || KYMO_AUDIT
|
||||
if let content = panel.contentView { lastHiddenContent = content }
|
||||
|
||||
Reference in New Issue
Block a user