SwiftUIPager
SwiftUIPager copied to clipboard
[BUG] List inside Pager
Describe the bug Lists inside the Pager can't be dragged, or two finger swiped on mac
To Reproduce
Place a List inside a Pager
Pager(page: page,
data: items,
id: \.self) { item in
List {
Text("List\(item)")
Text("List\(item)")
}
}
Expected behavior
- Swipeable with two fingers (ideal for Mac)
- Press and drag to the next page (matches iOS)
Additional context Surprisingly arrow keys work pretty nicely (currently the only way to change pages)
Hi @smotched , there are two things here:
- Trackpad events are not natively supported in SwiftUI as far as I can see. Check out #286 for more info
Listinside aPagerisn't working iniOS. For this, have you tried using.pagingPriority(.simultaneous)? The scenario is tricky because there are two elements here expecting a drag.
Btw, the keys do work because those are implemented differently, onMoveCommand if I remember correctly.
Hey @fermoya , I think you meant macOS but yeah even with .pagingPriority(.simultaneous) it unfortunately doesn't work. Could it be a macOS 13 thing maybe? are you getting anything on your side with the basic example above?
sidenote: ScrollView works nicely as well.
@smotched I see what you mean. Not sure why but in iOS works fine. I'll investigate to solve it.
In any case, it seems to me you're more interested in the trackpad option. It doesn't seem there's SwifUI natively built-in option to listen to this kind of event, all I find follows this approach. I'm not interested in anything that's not native. One option would be to create a view that uses that approach and then moves Pager when desired by using pageOffset modifier
Thanks @fermoya we may have to file a feedback with Apple since like you said it works fine on iOS. I don't see why it shouldn't work if it works with ScrollView unless there's an underlying issue in how List is implemented on mac that's breaking your implementation.
Nevertheless thanks for looking into it!