-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[feat] RefreshIndicator.noSpinner
implementation
#133507
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
Conversation
Anyone with iOS devices may test this implementation as well. |
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@danagbemava-nc @HansMuller please look into this pull. |
RefreshIndicator.noSpinner
implementationRefreshIndicator.noSpinner
implementation
I personally would name it |
Making the refresh indicator more flexible, so that you can change the animated "indicator" to something else seems reasonable. I'd expected to see a widget valued callback, something like buildRefreshIndicator(BuildContext, Animation), which would enable one to replace the default animation. The notification approach you've taken seems to work nicely for a situation where the indicator isn't stacked on top of the scrollable the way the default one is, but is just some unrelated part of the UI. Can you find a simple way to satisfy both use cases? |
All checks are green! 🟢 @bernaferrari pointed out that none might be a better option, so I'll be tweaking that toward the end. Regarding @HansMuller's suggestion, yup, we can offer an alternative to the spinner. Thinking of taking in a custom animation (maybe an icon?). I'm considering adding a separate constructor, maybe Let me know your thoughts on how to move forward. Implementation might take a bit as I'm juggling multiple projects. Thanks for understanding! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about the long review delay; I plead the holidays :-)
This is looking good. With a few small tweaks and an API doc (DartPad) example I think we could land this soon.
Hey, sorry for the long disappearance, Had a lot of assignments and tests. I've added an example flutter app, still unsure on how to update https://api.flutter.dev/flutter/material/RefreshIndicator-class.html. Please do guide me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some comments about the example (which is headed in the right direction).
body: RefreshIndicator.noSpinner( | ||
// Callback function used by the app to listen to the | ||
// status of the RefreshIndicator pull-down action. | ||
onStatusChange: (RefreshIndicatorStatus? status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the onStatusChange and onRefresh cases it would be best to do something that affects the UI rather than printing messages to the console. For the onRefresh case you could temporarily change the UI for 3 seconds.
Container( | ||
color: Colors.green[100], | ||
child: ListView.builder( | ||
shrinkWrap: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't want to encourage developers to use shrinkWrap. This can be rewritten with CustomScrollView:
CustomScrollView(
slivers: <Widget>[
SliverToBoxAdapter(
child: Container(
height: 100,
alignment: Alignment.center,
color: Colors.pink[100],
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Pull down here',
style: Theme.of(context).textTheme.headlineMedium,
),
const Text("RefreshIndicator won't trigger"),
],
),
),
),
DecoratedSliver(
decoration: BoxDecoration(color: Colors.green[100]),
sliver: SliverList(
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return const ListTile(
title: Text('Pull down here'),
subtitle: Text('RefreshIndicator will trigger'),
);
},
childCount: 25,
),
),
),
],
)
return Future<void>.delayed(const Duration(seconds: 3)); | ||
}, | ||
|
||
// This check is used to customize listening to scroll notifications |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check?
Better to explain this a little more directly: To ensure that we're notified only when the nested scroll view is scrolled we check the notification's depth. [Now explain what the default is and why we don't want that, etc.]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied part of the sample from another refresh indicator example, maybe I'll just remove this part?
/// Creates [RefreshIndicator] with no spinner and calls `onRefresh` when | ||
/// successfully armed by drag event. Events can be optionally listened | ||
/// by using `onStatusChange` callback | ||
const RefreshIndicator.noSpinner({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need a comment here that links to the example. Something like this (from TextButton):
/// {@tool dartpad}
/// This sample shows various ways to configure TextButtons, from the
/// simplest default appearance to versions that don't resemble
/// Material Design at all.
///
/// ** See code in examples/api/lib/material/text_button/text_button.0.dart **
/// {@end-tool}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for the doc generation part?
@@ -0,0 +1,92 @@ | |||
import 'package:flutter/material.dart'; | |||
|
|||
/// Flutter code sample for [RefreshIndicator.noSpinner]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll also need a test for the example. Put it in examples/api/test/material/refresh_indicator/refresh_indicator.2_test.dart
The test just needs to exercise the example enough to know that the basics are working.
Hi @opxdelwin would you like to continue working on this PR? |
Thank you for your contribution. I'm going to close this PR for now since there are outstanding comments, just to get this off our PR review queue. Please don't hesitate to re-open or submit a new PR if you have the time to address the review comments. Thanks! |
This PR adds a new constructor to the RefreshIndicator's class, which is `noSpinner`. The purpose of this new constructor is to create a RefreshIndicator that doesn't show a spinner when the user arms it by pulling. The work is based on a partial that is here: #133507 I addressed the following issues reported in the PR above: - in the example for `noSpinner`, arming the RefreshIndicator now shows a CircularProgressIndicator, instead of just printing text to the console; - added a test for the new example; - added a doc comment on the new constructor; Fixes #132775
This PR adds a new constructor to the RefreshIndicator's class, which is `noSpinner`. The purpose of this new constructor is to create a RefreshIndicator that doesn't show a spinner when the user arms it by pulling. The work is based on a partial that is here: flutter#133507 I addressed the following issues reported in the PR above: - in the example for `noSpinner`, arming the RefreshIndicator now shows a CircularProgressIndicator, instead of just printing text to the console; - added a test for the new example; - added a doc comment on the new constructor; Fixes flutter#132775
New
RefreshIndicator.noSpinner
constructor to override and disable default spinner for custom handling.New
onModeChange
function to keep a track of events performed byRefreshIndicator
such asdrag
,armed
,refresh
,cancelled
for custom handling by developers.onModeChange
is by default set to null forRefreshIndicator
&RefreshIndicator.adaptive
as UI gets updated as per.Contributions to more (and better) tests would be equally appreciated!
Fixes #132775
Pre-launch Checklist
///
).Minimal Reproducible code