import SwiftUI struct ScrollPositionPreferenceKey: PreferenceKey { typealias Value = ScrollPositionPreference? static var defaultValue: Value = nil static func reduce(value: inout Value, nextValue: () -> Value) { guard let next = nextValue() else { return } if let current = value { if abs(next.yPosition) < abs(current.yPosition) { value = next } } else { value = next } } }