Temporary fix for glitch, TODO: remove push up animation

This commit is contained in:
Hariharan Mudaliar 2025-11-26 22:40:23 +05:30
commit 80d132a85f
5 changed files with 177 additions and 64 deletions

View file

@ -48,7 +48,16 @@ struct ExpandedItem {
class DynamicIslandViewCoordinator: ObservableObject {
static let shared = DynamicIslandViewCoordinator()
@Published var currentView: NotchViews = .home
@Published var currentView: NotchViews = .home {
didSet {
handleStatsTabTransition(from: oldValue, to: currentView)
}
}
@Published var statsSecondRowExpansion: CGFloat = 1
private var statsSecondRowWorkItem: DispatchWorkItem?
private let statsSecondRowRevealDelay: TimeInterval = 0.5
private let statsSecondRowAnimationDuration: TimeInterval = 0.3
@AppStorage("firstLaunch") var firstLaunch: Bool = true
@ -91,6 +100,27 @@ class DynamicIslandViewCoordinator: ObservableObject {
private init() {
selectedScreen = preferredScreen
}
private func handleStatsTabTransition(from oldValue: NotchViews, to newValue: NotchViews) {
guard oldValue != newValue else { return }
statsSecondRowWorkItem?.cancel()
if newValue == .stats && Defaults[.enableStatsFeature] {
statsSecondRowExpansion = 0
let workItem = DispatchWorkItem { [weak self] in
guard let self else { return }
withAnimation(.easeInOut(duration: self.statsSecondRowAnimationDuration)) {
self.statsSecondRowExpansion = 1
}
self.statsSecondRowWorkItem = nil
}
statsSecondRowWorkItem = workItem
DispatchQueue.main.asyncAfter(deadline: .now() + statsSecondRowRevealDelay, execute: workItem)
} else {
withAnimation(.easeInOut(duration: 0.2)) {
statsSecondRowExpansion = 0
}
}
}
func toggleSneakPeek(status: Bool, type: SneakContentType, duration: TimeInterval = 1.5, value: CGFloat = 0, icon: String = "") {
let resolvedDuration: TimeInterval