Skip to content

Conversation

xu-baolin
Copy link
Member

@xu-baolin xu-baolin commented Dec 11, 2020

Description

#71303 let the RefreshIndicator can be pulled out from the non-zero scroll position no matter the overscroll occurs due to drag or inertia.

This change cancel shows the RefreshIndicator when overscroll occurs due to inertia. I think this is intended to make it so that someone who is just scrolling to the top of your list doesn't accidentally start a refresh.

After this change, The indicator will be pulled out in two cases,
// 1, Begin drag when the scrollable widget at the edge with zero scroll position.
// 2, Keep drag before overscroll occurs when the scrollable widget has
// a non-zero scroll position(do not release finger before overscroll).

This behavior is consistent with the Android native app(Test with Microsoft Outlook APP).

@Hixie suggested that this behavior can opt-in and tracked by #9690

Drag form edge

20201211_175624

Keep drag when overscroll occurs from non-zero scroll position

20201211_175836

Release finger before overscroll occurs(OverscrllIndicator is shown instead of RefreshIndicator)

20201211_175931

Related Issues

Fixes #71936
Fixes #9690

Tests

I added the following tests:

See files.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Dec 11, 2020
@google-cla google-cla bot added the cla: yes label Dec 11, 2020
@xu-baolin xu-baolin requested a review from chunhtai December 11, 2020 10:08
// 1, Begin drag when the scrollable widget at the edge with zero scroll position.
// 2, Keep drag before overscroll occurs when the scrollable widget has
// a non-zero scroll position(do not release finger before overscroll).
return (notification is ScrollStartNotification || (notification is ScrollUpdateNotification && notification.dragDetails != null))
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you have refactor out this check, can you also implement the opt in behavior as well? We can have an widget parameter to control whether it can be pull out if it drag from non zero scroll offset?

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, BUT I still want to talk to @Hixie about this behavior. I want to know what he is thinking right now. I don't think the refresh indicator is easily pulled out by misoperation.It must continue to pull down a certain distance before it can be refreshed. What do you think,?

@@ -501,7 +501,7 @@ void main() {
);
});

testWidgets('Top RefreshIndicator showed when dragging from non-zero scroll position', (WidgetTester tester) async {
testWidgets('Top RefreshIndicator be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

neither "showed" nor "be shown" are really correct grammar here, I recommend "shows". :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

(or "is shown")

Copy link
Contributor

Choose a reason for hiding this comment

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

(or "should be shown")

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.
@Hixie Hi, so what's your opinion on this #9690 (comment) now?

Copy link
Contributor

@chunhtai chunhtai Dec 14, 2020

Choose a reason for hiding this comment

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

copied from discord chat

looks like the material design spec doesn't say one way or the other... it seems weird to me to allow pull to refresh when you're just scrolling, since pull to refresh can cost money (it does network traffic) and generally be disruptive. I would not expect it to happen when you're just scrolling, it should be specifically when you're at the top already. I don't have an objection to a flag to enable it when you're just scrolling if that's a common request.

I think this is a valid argument, and I am also agree we should have flag to toggle it on and off.

@xu-baolin xu-baolin requested a review from chunhtai December 17, 2020 12:26
@@ -47,6 +47,17 @@ enum _RefreshIndicatorMode {
canceled, // Animating the indicator's fade-out after not arming.
}

/// Used to configure the [RefreshIndicator] trigger mode.
Copy link
Contributor

Choose a reason for hiding this comment

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

Used to configure how [RefreshIndicator] can be triggered.


/// The indicator can only trigger when the child's [Scrollable] descendant overscrolls
/// by drag and its initial scroll position is on the edge.
strict,
Copy link
Contributor

Choose a reason for hiding this comment

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

strict sounds too generic. we should be specific.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you have any suggestions for this name? :)

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not an expert on this. here is my suggestion.

strict :onEdge, dragStartsAtScrollableEdge
loose: anywhere, dragStartsAtAnyWhere

@xu-baolin xu-baolin requested a review from chunhtai December 23, 2020 09:36
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM, modulo nits

@@ -501,12 +501,13 @@ void main() {
);
});

testWidgets('Top RefreshIndicator showed when dragging from non-zero scroll position', (WidgetTester tester) async {
testWidgets('Top RefreshIndicator(loose mode) should be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

loose mode -> onEdge mode

Copy link
Contributor

Choose a reason for hiding this comment

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

here and anywhere

expect(find.byType(RefreshProgressIndicator), findsNothing);
});

testWidgets('Top RefreshIndicator(strict mode) should not be shown when dragging from non-zero scroll position', (WidgetTester tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

anyWhere

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
4 participants