Skip to content

Show loading widget at bottom of loading lists#1

Open
DouglasValerio wants to merge 2 commits intoLucazzP:mainfrom
DouglasValerio:dv-main/improvement/show-loader-at-bottom-of-loading-lists
Open

Show loading widget at bottom of loading lists#1
DouglasValerio wants to merge 2 commits intoLucazzP:mainfrom
DouglasValerio:dv-main/improvement/show-loader-at-bottom-of-loading-lists

Conversation

@DouglasValerio
Copy link
Copy Markdown

What is the content type?

  • Improvement

Why is this change necessary?

  • A list of widgets with some kind of 'infinite scroll + load as you go' is a common pattern we encounter when developing mobile apps. Usually, the user expects some sort of indication that more information is loading at the bottom of said list.

How does this address the issue?

  • The package already provided a well-thought implementation of a loading widget, which was shown when the resource state was set to loading, so we took advantage of that and only treated the case for when the Resource is in the loading state, but already has some data from previous data-fetch calls.

  • Firstly, we made sure that if the resource has some data, the length of the rendered list takes that into account, the actual implementation is quite simple, and can be viewed in: e1f5820

  • On the second pass, we made some modifications on the _generateListBuilder(...Args) method, so it can keep rendering the existent data while also showing the loading widget at the bottom.

  • The main change to the aforementioned method was the introduction of the _handleLoadingState(..Args) which takes upon the role of performing some checks on whether the _generatedListBuilder should return a tile with rendered data or the loadingWidget itself.

  • The most sensitive task performed by the _handleLoadingState method is to ensure that we don't run into a range exception, once now, in the loading state we are rendering a list whose length is greater than the one on the Resource itself.

  • The implementation of this method can be checked at: a4d7204

Comment on lines 287 to 294
if (loadingTile != null) {
return loadingTile!;
return _handleLoadingState(index, data, loadingTile!);
}
if (loadingTileBuilder != null) {
return loadingTileBuilder!();
return _handleLoadingState(index, data, loadingTileBuilder!());
}
break;
case Status.success:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, will not be better to return this _handleLoadingState if is with Status.loading or Status.success?
Because you added the success logic on this function, so the correct name for this function should be _mapIndexToTile, or something like that... What you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants