fermoya / SwiftUIPager

Native Pager in SwiftUI
MIT License
1.29k stars 171 forks source link

[FEAT] Dynamic filter feature #275

Closed fred-bowker closed 2 years ago

fred-bowker commented 2 years ago

It would be great if the Pager allowed you to filter in place, the pager could have a property with a filter function on it, then when we modify the filter the pager would update in place.

An Example would be we: We have 20 pages some with cards representing women some representing men. A user then changes a settings view to say they only want to see men. The filter is applied in place.

At the moment you could call the server and then get back your filtered data and reset the pager however I feel like this isn't nearly as good a solution as having the pager support filtering functionality.

At the moment if I try to performa filtering on the data after it's initial setup I get ContiguousArrayBuffer.swift:575: Fatal error: Index out of range. I suspect this is because the data behind the pager has been refreshed.

I could have a look at how to implement this myself if you point me in the right direction but I suspect this will be beyond my swiftui abilities :(

Thanks once again for creating the pager, it's a much needed project

fermoya commented 2 years ago

problem is that the page isn't updated. You have items:

1  2  3  4  5  6

if you're on item 4 and filter even numbers, then there's a crash because you haven't updated the page accordingly. This related to #279 , I'll be making a quick fix there but ideally this would be handled by the client

fred-bowker commented 2 years ago

Thanks, that makes sense will handle this issue on the client side