Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
ae9bd5ea
Commit
ae9bd5ea
authored
Feb 15, 2017
by
Ian Hickson
Committed by
GitHub
Feb 15, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the depth of scroll notifications (#8156)
Fixes
https://github.com/flutter/flutter/issues/8017
parent
cdc0f15f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
14 deletions
+16
-14
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+1
-1
page_view.dart
packages/flutter/lib/src/widgets/page_view.dart
+1
-1
scroll_notification.dart
packages/flutter/lib/src/widgets/scroll_notification.dart
+9
-5
scroll_notification_test.dart
packages/flutter/test/widgets/scroll_notification_test.dart
+5
-7
No files found.
packages/flutter/lib/src/material/tabs.dart
View file @
ae9bd5ea
...
...
@@ -726,7 +726,7 @@ class _TabBarViewState extends State<TabBarView> {
if
(
_warpUnderwayCount
>
0
)
return
false
;
if
(
notification
.
depth
!=
1
)
if
(
notification
.
depth
!=
0
)
return
false
;
if
(
notification
is
ScrollStartNotification
)
{
...
...
packages/flutter/lib/src/widgets/page_view.dart
View file @
ae9bd5ea
...
...
@@ -188,7 +188,7 @@ class PageView extends BoxScrollView {
final
Widget
scrollable
=
super
.
build
(
context
);
return
new
NotificationListener
<
ScrollNotification2
>(
onNotification:
(
ScrollNotification2
notification
)
{
if
(
notification
.
depth
==
1
&&
onPageChanged
!=
null
&&
notification
is
ScrollEndNotification
)
{
if
(
notification
.
depth
==
0
&&
onPageChanged
!=
null
&&
notification
is
ScrollEndNotification
)
{
final
ScrollMetrics
metrics
=
notification
.
metrics
;
onPageChanged
(
metrics
.
extentBefore
~/
metrics
.
viewportDimension
);
}
...
...
packages/flutter/lib/src/widgets/scroll_notification.dart
View file @
ae9bd5ea
...
...
@@ -75,15 +75,19 @@ abstract class ScrollNotification2 extends LayoutChangedNotification {
/// size of the viewport, for instance.
final
BuildContext
context
;
/// The number of [Scrollable2] widgets that this notification has bubbled
/// through. Typically listeners only respond to notifications with a [depth]
/// of zero.
/// The number of viewports that this notification has bubbled through.
///
/// Typically listeners only respond to notifications with a [depth] of zero.
///
/// Specifically, this is the number of [Widget]s representing
/// [RenderAbstractViewport] render objects through which this notification
/// has bubbled.
int
get
depth
=>
_depth
;
int
_depth
=
0
;
@override
bool
visitAncestor
(
Element
element
)
{
if
(
element
.
widget
is
Scrollable2
)
if
(
element
is
RenderObjectElement
&&
element
.
renderObject
is
RenderAbstractViewport
)
_depth
+=
1
;
return
super
.
visitAncestor
(
element
);
}
...
...
@@ -93,7 +97,7 @@ abstract class ScrollNotification2 extends LayoutChangedNotification {
super
.
debugFillDescription
(
description
);
description
.
add
(
'
$axisDirection
'
);
description
.
add
(
'metrics:
$metrics
'
);
description
.
add
(
'depth:
$depth
'
);
description
.
add
(
'depth:
$depth
(
${ depth == 0 ? "local" : "remote"}
)
'
);
}
}
...
...
packages/flutter/test/widgets/scroll_notification_test.dart
View file @
ae9bd5ea
...
...
@@ -23,7 +23,7 @@ void main() {
TestGesture
gesture
=
await
tester
.
startGesture
(
const
Point
(
100.0
,
100.0
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
notification
,
const
isInstanceOf
<
ScrollStartNotification
>());
expect
(
notification
.
depth
,
equals
(
1
));
expect
(
notification
.
depth
,
equals
(
0
));
ScrollStartNotification
start
=
notification
;
expect
(
start
.
dragDetails
,
isNotNull
);
expect
(
start
.
dragDetails
.
globalPosition
,
equals
(
const
Point
(
100.0
,
100.0
)));
...
...
@@ -31,7 +31,7 @@ void main() {
await
gesture
.
moveBy
(
const
Offset
(-
10.0
,
-
10.0
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
notification
,
const
isInstanceOf
<
ScrollUpdateNotification
>());
expect
(
notification
.
depth
,
equals
(
1
));
expect
(
notification
.
depth
,
equals
(
0
));
ScrollUpdateNotification
update
=
notification
;
expect
(
update
.
dragDetails
,
isNotNull
);
expect
(
update
.
dragDetails
.
globalPosition
,
equals
(
const
Point
(
90.0
,
90.0
)));
...
...
@@ -40,7 +40,7 @@ void main() {
await
gesture
.
up
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
notification
,
const
isInstanceOf
<
ScrollEndNotification
>());
expect
(
notification
.
depth
,
equals
(
1
));
expect
(
notification
.
depth
,
equals
(
0
));
ScrollEndNotification
end
=
notification
;
expect
(
end
.
dragDetails
,
isNotNull
);
expect
(
end
.
dragDetails
.
velocity
,
equals
(
Velocity
.
zero
));
...
...
@@ -93,9 +93,7 @@ void main() {
expect
(
depth0Types
,
equals
(
types
));
expect
(
depth1Types
,
equals
(
types
));
// These values might not be what we want in the end.
// See <https://github.com/flutter/flutter/issues/8017>.
expect
(
depth0Values
,
equals
(<
int
>[
1
,
1
,
1
,
1
,
1
]));
expect
(
depth1Values
,
equals
(<
int
>[
2
,
2
,
2
,
2
,
2
]));
expect
(
depth0Values
,
equals
(<
int
>[
0
,
0
,
0
,
0
,
0
]));
expect
(
depth1Values
,
equals
(<
int
>[
1
,
1
,
1
,
1
,
1
]));
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment