Allow details and slideshow to load in background#645
Conversation
|
Note: so far i've only tested the linux build, i haven't set up/installed the tools to test on my phone. |
|
Infinite mode looks good but pagination is buggy, if you swipe and switch to next page, then you go back then tap on one of the image, it will back to previous page again. |
|
I think for paginated mode, we should have a same UX as the listing page where switching page is a dedicated user action not auto switch, like swiping on the last item will pull out an load next indicator then if user release, we switch page. |
|
Hey, as you can see i've not updated this. Feel free to take the code and change it how you wish, or not at all if you don't want to. It'd still be cool to see this feature but i honestly haven't been using boorusama that much |
|
Thanks for the update, i'm planning to add this changes together with your blacklist redesign in the next version. |
Goal: allow background fetching of more pages of posts while scrolling through
Solution: To avoid redesigning the entire way posts are managed, i've implemented a "lazy list" class,
DetailsPostsListing<T> extends ListBase<T>which replaces the simpleList<T extends Post>which was passed around before. It still supports storing a simple List for cases where a controller isn't available (i haven't tried very hard).To make the UI work with dynamic updates, i introduced multiple new
ValueListenableBuilderlistening to theDetailsPostsListing.dynlenwhich is aValueNotifier<int>for changes in the length of available items.Notes:
lib/core/posts/details/src/routes/details_route_context.dartas the main class,DetailsPostsListing<T>is a field on theDetailsRouteContextclass.List<dynamic>/PostGridController<dynamic>to avoid having to specify 2 generics. The output type T is able to be changed bylistingMap((i) => i as SpecificPost)to replicate thecontroller.items.map((i) => i as SpecificPost).toList()behaviour which was used in a few places.DetailsPostsListingdelegates the handling of infinite/pagination modes to a corresponding_ListingStrategy_InfiniteStrategyis pretty straightforward: fetch new posts when near the end, and update the length_PaginatedStrategyessentially implements a kind of "infinite scrolling" on top of the underlying paginated nature ofPostGridController. For this it stores all seen posts, both forwards and backwards, adding to them whenever approaching one of the edges of the loaded state. Because this means that it has to add posts before the current ones, i calls out toPostDetailsPageViewControllerto jump to the correct post (previous post index + new items length) so the UI visually stays on the post the user was looking at while extending to the left.SlideshowControllerhas gotten a_handleTotalPagesChangedwhich calls a new methodwithUpdatedTotalPagesonSlideshowState. This is implemented by updating thetotalPages, the currentPage if necessary (fewer posts), and therandomSequenceif its used. TherandomSequenceis kept as-is, with the new pages posts added on top. That means in effect it will randomize each page internally but it won't randomize across pages.Status: