I have a List and I would like to hide a toolbar and tab bar when the List scrolls up.
I've tried to detect movements using the following:
.gesture(
DragGesture()
.onChanged { value in
if value.translation.height > 0 {
print("Scroll down")
} else {
print("Scroll up")
}
}
.onEnded{ value in
print("ended")
}
)
This works intermittently, as in only around 80% of the time, it only seems to detect scrolls when I do it slowly or when I place my finger down straight onto the screen and then scroll. Otherwise nothing. Also, onEnded never fires here.
I also tried this:
.gesture(
DragGesture(minimumDistance: 0, coordinateSpace: .local)
.onChanged { value in
print(value.translation.height)
if value.translation.height > 0 {
print("Scroll down")
} else {
print("Scroll up")
}
}
.onEnded{ value in
print("ended")
print(value.location.y)
}
)
This catches all my scrolling, which is great. onEnded also fires, but the problem is my List doesn't actually scroll.
I'm at a loss here, I want to know when the user scrolls up, scrolls down, by how much, and if possible I would like to know when the user gets to the top of the list.
DragGestureto theList?