Improve animations and resizing again. Add option for animation speed.

This commit is contained in:
2026-03-13 00:14:00 +11:00
parent 256998eb9f
commit e4719cb9f4
6 changed files with 135 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ class NotchViewModel: ObservableObject {
@Published var isCloseTransitionActive: Bool = false
@Published var suppressHoverOpenUntilHoverExit: Bool = false
@Published var isUserResizing: Bool = false
@Published var isPresetResizing: Bool = false
let terminalManager = TerminalManager.shared
@@ -36,6 +37,7 @@ class NotchViewModel: ObservableObject {
@AppStorage(NotchSettings.Keys.openSpringDamping) private var openSpringDamping = NotchSettings.Defaults.openSpringDamping
@AppStorage(NotchSettings.Keys.closeSpringResponse) private var closeSpringResponse = NotchSettings.Defaults.closeSpringResponse
@AppStorage(NotchSettings.Keys.closeSpringDamping) private var closeSpringDamping = NotchSettings.Defaults.closeSpringDamping
@AppStorage(NotchSettings.Keys.resizeAnimationDuration) private var resizeAnimationDurationSetting = NotchSettings.Defaults.resizeAnimationDuration
private var closeTransitionTask: Task<Void, Never>?
@@ -45,6 +47,9 @@ class NotchViewModel: ObservableObject {
var closeAnimation: Animation {
.spring(response: closeSpringResponse, dampingFraction: closeSpringDamping)
}
var openAnimationDuration: TimeInterval {
max(0.05, resizeAnimationDurationSetting)
}
init(screenUUID: String) {
self.screenUUID = screenUUID
@@ -94,10 +99,16 @@ class NotchViewModel: ObservableObject {
}
@discardableResult
func setOpenSize(_ proposedSize: CGSize, notifyWindowResize: Bool) -> CGSize {
func setStoredOpenSize(_ proposedSize: CGSize) -> CGSize {
let clampedSize = clampedOpenSize(proposedSize)
openWidth = clampedSize.width
openHeight = clampedSize.height
return clampedSize
}
@discardableResult
func setOpenSize(_ proposedSize: CGSize, notifyWindowResize: Bool) -> CGSize {
let clampedSize = setStoredOpenSize(proposedSize)
if notchState == .open {
notchSize = clampedSize
}