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
5e93756f
Commit
5e93756f
authored
Feb 22, 2017
by
Adam Barth
Committed by
GitHub
Feb 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up flipping of ScrollDirection (#8343)
Makes RenderViewport.layoutOneSide more readable.
parent
34a6e48a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
21 deletions
+42
-21
sliver.dart
packages/flutter/lib/src/rendering/sliver.dart
+22
-1
viewport.dart
packages/flutter/lib/src/rendering/viewport.dart
+3
-20
viewport_offset.dart
packages/flutter/lib/src/rendering/viewport_offset.dart
+17
-0
No files found.
packages/flutter/lib/src/rendering/sliver.dart
View file @
5e93756f
...
...
@@ -131,6 +131,27 @@ AxisDirection applyGrowthDirectionToAxisDirection(AxisDirection axisDirection, G
return
null
;
}
/// Flips the [ScrollDirection] if the [GrowthDirection] is [GrowthDirection.reverse].
///
/// Specifically, returns `scrollDirection` if `scrollDirection` is
/// [GrowthDirection.forward], otherwise returns [flipScrollDirection] applied to
/// `scrollDirection`.
///
/// This function is useful in [RenderSliver] subclasses that are given both an
/// [ScrollDirection] and a [GrowthDirection] and wish to compute the
/// [ScrollDirection] in which growth will occur.
ScrollDirection
applyGrowthDirecitonToScrollDirection
(
ScrollDirection
scrollDirection
,
GrowthDirection
growthDirection
)
{
assert
(
scrollDirection
!=
null
);
assert
(
growthDirection
!=
null
);
switch
(
growthDirection
)
{
case
GrowthDirection
.
forward
:
return
scrollDirection
;
case
GrowthDirection
.
reverse
:
return
flipScrollDirection
(
scrollDirection
);
}
return
null
;
}
/// Immutable layout constraints for [RenderSliver] layout.
///
/// The [SliverConstraints] describe the current scroll state of the viewport
...
...
@@ -524,7 +545,7 @@ class SliverGeometry {
@override
String
toString
()
{
StringBuffer
buffer
=
new
StringBuffer
();
final
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
write
(
'SliverGeometry('
);
buffer
.
write
(
'scrollExtent:
${scrollExtent.toStringAsFixed(1)}
, '
);
if
(
paintExtent
>
0.0
)
{
...
...
packages/flutter/lib/src/rendering/viewport.dart
View file @
5e93756f
...
...
@@ -129,28 +129,11 @@ abstract class RenderViewportBase<ParentDataClass extends ContainerParentDataMix
)
{
assert
(
scrollOffset
.
isFinite
);
assert
(
scrollOffset
>=
0.0
);
ScrollDirection
adjustedUserScrollDirection
;
switch
(
growthDirection
)
{
case
GrowthDirection
.
forward
:
adjustedUserScrollDirection
=
offset
.
userScrollDirection
;
break
;
case
GrowthDirection
.
reverse
:
switch
(
offset
.
userScrollDirection
)
{
case
ScrollDirection
.
forward
:
adjustedUserScrollDirection
=
ScrollDirection
.
reverse
;
break
;
case
ScrollDirection
.
reverse
:
adjustedUserScrollDirection
=
ScrollDirection
.
forward
;
break
;
case
ScrollDirection
.
idle
:
adjustedUserScrollDirection
=
ScrollDirection
.
idle
;
break
;
}
break
;
}
final
ScrollDirection
adjustedUserScrollDirection
=
applyGrowthDirecitonToScrollDirection
(
offset
.
userScrollDirection
,
growthDirection
);
assert
(
adjustedUserScrollDirection
!=
null
);
double
maxPaintOffset
=
layoutOffset
;
double
initialLayoutOffset
=
layoutOffset
;
final
double
initialLayoutOffset
=
layoutOffset
;
while
(
child
!=
null
)
{
assert
(
scrollOffset
>=
0.0
);
child
.
layout
(
new
SliverConstraints
(
...
...
packages/flutter/lib/src/rendering/viewport_offset.dart
View file @
5e93756f
...
...
@@ -33,6 +33,23 @@ enum ScrollDirection {
reverse
,
}
/// Returns the opposite of the given [ScrollDirection].
///
/// Specifically, returns [AxisDirection.reverse] for [AxisDirection.forward]
/// (and vice versa) and returns [ScrollDirection.idle] for
/// [ScrollDirection.idle].
ScrollDirection
flipScrollDirection
(
ScrollDirection
direction
)
{
switch
(
direction
)
{
case
ScrollDirection
.
idle
:
return
ScrollDirection
.
idle
;
case
ScrollDirection
.
forward
:
return
ScrollDirection
.
reverse
;
case
ScrollDirection
.
reverse
:
return
ScrollDirection
.
forward
;
}
return
null
;
}
abstract
class
ViewportOffset
extends
ChangeNotifier
{
ViewportOffset
();
factory
ViewportOffset
.
fixed
(
double
value
)
=
_FixedViewportOffset
;
...
...
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