Type ‘…’ does not conform to protocol ‘ViewModifier’

0
106
Type ‘…’ does not conform to protocol ‘ViewModifier’


Can’t figure out why I’m getting this error. I’ve seen similar questions on the internet, but basically all the examples deal with images, what am I doing wrong?

my code:

struct OffsetModifier: ViewModifier {
    
    @Binding var offset: CGFloat
    var returnFromStart: Bool = true
    @State var startValue: CGFloat = 0
    
    func body(content: Content) -> some View {
        content
            .overlay {
                GeometryReader { proxy in
                    Color.clear
                        .preference(key: OffsetKey.self, value: proxy.frame(in: .named("SCROLL")).midY)
                        .onPreferenceChange(OffsetKey.self) { value in
                            
                            if startValue == 0 {
                                startValue = value
                            }
                            
                            offset = (value - (returnFromStart ? startValue : 0))
                        }
                }
            }
    }
}

struct OffsetKey: PreferenceKey {
    static var defaultValue: CGFloat = 0
    static func reduce(value: inout CGFloat, nextValue: () -> CGFloat) {
        value = nextValue()
    }
}

Type ‘…’ does not conform to protocol ‘ViewModifier’