@@ -15,6 +15,10 @@ class SchoolArrangementViewModel: ObservableObject {
1515 @Published var isLoadingDetail : Bool = false
1616 @Published var pdfURL : URL ?
1717
18+ // Animation state management with view ID for persistent tracking
19+ private let animationViewId = " SchoolArrangementView "
20+ @Published var shouldAnimate = false
21+
1822 private let baseURL = " https://www.wflms.cn "
1923 private var currentTask : URLSessionDataTask ?
2024 private var detailTask : URLSessionDataTask ?
@@ -25,6 +29,8 @@ class SchoolArrangementViewModel: ObservableObject {
2529
2630 init ( ) {
2731 fetchArrangements ( )
32+ // Check if animations have already been performed
33+ shouldAnimate = AnimationManager . shared. hasAnimated ( viewId: animationViewId)
2834 }
2935
3036 deinit {
@@ -721,4 +727,32 @@ class SchoolArrangementViewModel: ObservableObject {
721727 }
722728 }
723729 }
730+
731+ // Enhanced animation control method with device-specific behavior
732+ func triggerInitialAnimation( isSmallScreen: Bool = UIDevice . isSmallScreen) {
733+ // Skip if already animated according to the global manager
734+ if AnimationManager . shared. hasAnimated ( viewId: animationViewId) {
735+ // For small screens, instantly set the animation state without animation
736+ if isSmallScreen {
737+ self . shouldAnimate = true
738+ } else {
739+ // For larger screens, we can still animate if needed
740+ withAnimation ( . easeOut( duration: 0.3 ) ) {
741+ self . shouldAnimate = true
742+ }
743+ }
744+ return
745+ }
746+
747+ // First time animation with appropriate timing
748+ let delay = isSmallScreen ? 0.1 : 0.3 // Less delay on small screens
749+
750+ DispatchQueue . main. asyncAfter ( deadline: . now( ) + delay) {
751+ withAnimation ( . easeOut( duration: isSmallScreen ? 0.4 : 0.6 ) ) {
752+ self . shouldAnimate = true
753+ // Mark as animated in the global manager
754+ AnimationManager . shared. markAnimated ( viewId: self . animationViewId)
755+ }
756+ }
757+ }
724758}
0 commit comments