-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can we use this library with Swift UI? #107
Comments
There aren't any current plans to support Swift UI from my side, but I'm happy to take a PR! My knowledge of iOS development is close to zero, so I don't know enough about Swift UI to give any pointers. If you have any specific questions about integrating Multiplatform Paging into Swift UI, I'd be happy to help on the Multiplatform Paging side of things! |
I've found a way to use this library in SwiftUI class KotlinViewPresenter {
@Composable
fun body(): State {
//...
val listState: LazyPagingItems<Item> = ///
return State(
listState = listState,
)
}
} in SwiftUI: List {
ForEach(1...state.listState.itemCount) { index in
// using peek instead of get to avoid load the next page too early
let item = state.listState.peek(index - 1)
Text(item).onAppear {
// for loading more items
_ = state.listState.get(index - 1)
}
}
} |
I've integrated it with SwiftUI. You can add this class to your iosMain folder in common code & use it like this. This sample has examples of how to add loading footer, error footer with retry page load functionality. @veyndan Can you please look at it once? If it looks fine then I can raise a PR with the code & sample demo. |
Thanks @Tlaster and @AshuTyagi16 for showing some code samples!
A PR would be lovely and very much appreciated! If possible, a new sample under https://github.com/cashapp/multiplatform-paging/tree/main-3.3.0-alpha02/samples/repo-search named Once that's done, I'll point to that sample as an example usage of Multiplatform Paging with Swift UI. If it then makes sense to create a separate module containing helper classes (like your |
refer to @AshuTyagi16 's sample, I did it like |
As per the examples, it looks like this library only supports traditional UI for iOS (and Compose for iOS), not Swift UI.
Is it planned to be supported? Any workarounds or pointers to make this work on Swift UI would be appreciated.
Thanks!
The text was updated successfully, but these errors were encountered: