mirror of
https://github.com/FBukovina/Atoll.git
synced 2026-10-27 15:14:33 +00:00
Improve animation
This commit is contained in:
parent
39673e9130
commit
f782c9d135
2 changed files with 24 additions and 25 deletions
|
|
@ -171,24 +171,27 @@ struct ContentView: View {
|
|||
|
||||
mainLayout
|
||||
.conditionalModifier(!useModernCloseAnimation) { view in
|
||||
let hoverAnimationAnimation = Animation.bouncy.speed(1.2)
|
||||
let notchStateAnimation = Animation.spring.speed(1.2)
|
||||
let viewTransitionAnimation = Animation.easeInOut(duration: 0.4)
|
||||
return view
|
||||
.animation(hoverAnimationAnimation, value: isHovering)
|
||||
.animation(notchStateAnimation, value: vm.notchState)
|
||||
.animation(viewTransitionAnimation, value: coordinator.currentView)
|
||||
.animation(.smooth, value: gestureProgress)
|
||||
.transition(.blurReplace.animation(.interactiveSpring(dampingFraction: 1.2)))
|
||||
}
|
||||
.conditionalModifier(useModernCloseAnimation) { view in
|
||||
let hoverAnimationAnimation = Animation.bouncy.speed(1.2)
|
||||
let hoverAnimation = Animation.bouncy.speed(1.2)
|
||||
let notchStateAnimation = Animation.spring.speed(1.2)
|
||||
let viewTransitionAnimation = Animation.easeInOut(duration: 0.4)
|
||||
return view
|
||||
.animation(hoverAnimationAnimation, value: isHovering)
|
||||
.animation(hoverAnimation, value: isHovering)
|
||||
.animation(notchStateAnimation, value: vm.notchState)
|
||||
.animation(viewTransitionAnimation, value: coordinator.currentView)
|
||||
.animation(.smooth, value: gestureProgress)
|
||||
.transition(.blurReplace.animation(.interactiveSpring(dampingFraction: 1.2)))
|
||||
}
|
||||
.conditionalModifier(useModernCloseAnimation) { view in
|
||||
let hoverAnimation = Animation.bouncy.speed(1.2)
|
||||
let openAnimation = Animation.spring(response: 0.42, dampingFraction: 0.8, blendDuration: 0)
|
||||
let closeAnimation = Animation.spring(response: 0.45, dampingFraction: 1.0, blendDuration: 0)
|
||||
let viewTransitionAnimation = Animation.easeInOut(duration: 0.4)
|
||||
let notchAnimation = vm.notchState == .open ? openAnimation : closeAnimation
|
||||
return view
|
||||
.animation(hoverAnimation, value: isHovering)
|
||||
.animation(notchAnimation, value: vm.notchState)
|
||||
.animation(viewTransitionAnimation, value: coordinator.currentView)
|
||||
.animation(.smooth, value: gestureProgress)
|
||||
}
|
||||
.conditionalModifier(interactionsEnabled) { view in
|
||||
view
|
||||
|
|
|
|||
|
|
@ -234,13 +234,11 @@ class DynamicIslandViewModel: NSObject, ObservableObject {
|
|||
DispatchQueue.main.async(execute: applyWindowResize)
|
||||
}
|
||||
|
||||
withAnimation(.bouncy) {
|
||||
self.notchSize = targetSize
|
||||
self.notchState = .open
|
||||
}
|
||||
|
||||
// Force music information update when notch is opened
|
||||
MusicManager.shared.forceUpdate()
|
||||
notchSize = targetSize
|
||||
notchState = .open
|
||||
|
||||
// Force music information update when notch is opened
|
||||
MusicManager.shared.forceUpdate()
|
||||
}
|
||||
|
||||
private func calculateDynamicNotchSize() -> CGSize {
|
||||
|
|
@ -254,12 +252,10 @@ class DynamicIslandViewModel: NSObject, ObservableObject {
|
|||
}
|
||||
|
||||
func close() {
|
||||
withAnimation(.smooth) { [weak self] in
|
||||
guard let self = self else { return }
|
||||
self.notchSize = getClosedNotchSize(screen: self.screen)
|
||||
self.closedNotchSize = self.notchSize
|
||||
self.notchState = .closed
|
||||
}
|
||||
let targetSize = getClosedNotchSize(screen: screen)
|
||||
notchSize = targetSize
|
||||
closedNotchSize = targetSize
|
||||
notchState = .closed
|
||||
|
||||
// Set the current view to shelf if it contains files and the user enables openShelfByDefault
|
||||
// Otherwise, if the user has not enabled openLastShelfByDefault, set the view to home
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue