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
b6f3b298
Commit
b6f3b298
authored
Jan 11, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1187 from abarth/axis
Rename ScrollDirection to Axis
parents
253d6874
b2cef9f2
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
138 additions
and
138 deletions
+138
-138
horizontal_scrolling.dart
examples/widgets/horizontal_scrolling.dart
+1
-1
pageable_list.dart
examples/widgets/pageable_list.dart
+8
-8
input.dart
packages/flutter/lib/src/material/input.dart
+1
-1
material_list.dart
packages/flutter/lib/src/material/material_list.dart
+1
-1
scrollbar_painter.dart
packages/flutter/lib/src/material/scrollbar_painter.dart
+2
-2
tabs.dart
packages/flutter/lib/src/material/tabs.dart
+4
-4
block.dart
packages/flutter/lib/src/rendering/block.dart
+8
-8
box.dart
packages/flutter/lib/src/rendering/box.dart
+9
-0
list.dart
packages/flutter/lib/src/rendering/list.dart
+14
-14
viewport.dart
packages/flutter/lib/src/rendering/viewport.dart
+10
-19
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+6
-6
homogeneous_viewport.dart
packages/flutter/lib/src/widgets/homogeneous_viewport.dart
+5
-5
mixed_viewport.dart
packages/flutter/lib/src/widgets/mixed_viewport.dart
+8
-8
pageable_list.dart
packages/flutter/lib/src/widgets/pageable_list.dart
+6
-6
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+28
-28
scrollable_grid.dart
packages/flutter/lib/src/widgets/scrollable_grid.dart
+2
-2
scrollable_list.dart
packages/flutter/lib/src/widgets/scrollable_list.dart
+5
-5
virtual_viewport.dart
packages/flutter/lib/src/widgets/virtual_viewport.dart
+3
-3
dismissable_test.dart
packages/flutter/test/widget/dismissable_test.dart
+8
-8
homogeneous_viewport_test.dart
packages/flutter/test/widget/homogeneous_viewport_test.dart
+1
-1
mixed_viewport_test.dart
packages/flutter/test/widget/mixed_viewport_test.dart
+1
-1
pageable_list_test.dart
packages/flutter/test/widget/pageable_list_test.dart
+1
-1
scrollable_list_hit_testing_test.dart
...flutter/test/widget/scrollable_list_hit_testing_test.dart
+2
-2
scrollable_list_horizontal_test.dart
.../flutter/test/widget/scrollable_list_horizontal_test.dart
+1
-1
scrollable_list_vertical_test.dart
...es/flutter/test/widget/scrollable_list_vertical_test.dart
+1
-1
snap_scrolling_test.dart
packages/flutter/test/widget/snap_scrolling_test.dart
+2
-2
No files found.
examples/widgets/horizontal_scrolling.dart
View file @
b6f3b298
...
@@ -41,7 +41,7 @@ class HorizontalScrollingApp extends StatelessComponent {
...
@@ -41,7 +41,7 @@ class HorizontalScrollingApp extends StatelessComponent {
return
new
Center
(
return
new
Center
(
child:
new
Container
(
child:
new
Container
(
height:
50.0
,
height:
50.0
,
child:
new
Block
(
circles
,
scrollDirection:
ScrollDirection
.
horizontal
)
child:
new
Block
(
circles
,
scrollDirection:
Axis
.
horizontal
)
)
)
);
);
}
}
...
...
examples/widgets/pageable_list.dart
View file @
b6f3b298
...
@@ -38,7 +38,7 @@ class PageableListAppState extends State<PageableListApp> {
...
@@ -38,7 +38,7 @@ class PageableListAppState extends State<PageableListApp> {
List
<
CardModel
>
cardModels
;
List
<
CardModel
>
cardModels
;
Size
pageSize
=
new
Size
(
200.0
,
200.0
);
Size
pageSize
=
new
Size
(
200.0
,
200.0
);
ScrollDirection
scrollDirection
=
ScrollDirection
.
horizontal
;
Axis
scrollDirection
=
Axis
.
horizontal
;
bool
itemsWrap
=
false
;
bool
itemsWrap
=
false
;
Widget
buildCard
(
CardModel
cardModel
)
{
Widget
buildCard
(
CardModel
cardModel
)
{
...
@@ -52,7 +52,7 @@ class PageableListAppState extends State<PageableListApp> {
...
@@ -52,7 +52,7 @@ class PageableListAppState extends State<PageableListApp> {
)
)
);
);
BoxConstraints
constraints
=
(
scrollDirection
==
ScrollDirection
.
vertical
)
BoxConstraints
constraints
=
(
scrollDirection
==
Axis
.
vertical
)
?
new
BoxConstraints
.
tightFor
(
height:
pageSize
.
height
)
?
new
BoxConstraints
.
tightFor
(
height:
pageSize
.
height
)
:
new
BoxConstraints
.
tightFor
(
width:
pageSize
.
width
);
:
new
BoxConstraints
.
tightFor
(
width:
pageSize
.
width
);
...
@@ -65,9 +65,9 @@ class PageableListAppState extends State<PageableListApp> {
...
@@ -65,9 +65,9 @@ class PageableListAppState extends State<PageableListApp> {
void
switchScrollDirection
()
{
void
switchScrollDirection
()
{
setState
(()
{
setState
(()
{
scrollDirection
=
(
scrollDirection
==
ScrollDirection
.
vertical
)
scrollDirection
=
(
scrollDirection
==
Axis
.
vertical
)
?
ScrollDirection
.
horizontal
?
Axis
.
horizontal
:
ScrollDirection
.
vertical
;
:
Axis
.
vertical
;
});
});
}
}
...
@@ -83,13 +83,13 @@ class PageableListAppState extends State<PageableListApp> {
...
@@ -83,13 +83,13 @@ class PageableListAppState extends State<PageableListApp> {
new
DrawerHeader
(
child:
new
Text
(
'Options'
)),
new
DrawerHeader
(
child:
new
Text
(
'Options'
)),
new
DrawerItem
(
new
DrawerItem
(
icon:
'navigation/more_horiz'
,
icon:
'navigation/more_horiz'
,
selected:
scrollDirection
==
ScrollDirection
.
horizontal
,
selected:
scrollDirection
==
Axis
.
horizontal
,
child:
new
Text
(
'Horizontal Layout'
),
child:
new
Text
(
'Horizontal Layout'
),
onPressed:
switchScrollDirection
onPressed:
switchScrollDirection
),
),
new
DrawerItem
(
new
DrawerItem
(
icon:
'navigation/more_vert'
,
icon:
'navigation/more_vert'
,
selected:
scrollDirection
==
ScrollDirection
.
vertical
,
selected:
scrollDirection
==
Axis
.
vertical
,
child:
new
Text
(
'Vertical Layout'
),
child:
new
Text
(
'Vertical Layout'
),
onPressed:
switchScrollDirection
onPressed:
switchScrollDirection
),
),
...
@@ -108,7 +108,7 @@ class PageableListAppState extends State<PageableListApp> {
...
@@ -108,7 +108,7 @@ class PageableListAppState extends State<PageableListApp> {
return
new
ToolBar
(
return
new
ToolBar
(
center:
new
Text
(
'PageableList'
),
center:
new
Text
(
'PageableList'
),
right:
<
Widget
>[
right:
<
Widget
>[
new
Text
(
scrollDirection
==
ScrollDirection
.
horizontal
?
"horizontal"
:
"vertical"
)
new
Text
(
scrollDirection
==
Axis
.
horizontal
?
"horizontal"
:
"vertical"
)
]
]
);
);
}
}
...
...
packages/flutter/lib/src/material/input.dart
View file @
b6f3b298
...
@@ -26,7 +26,7 @@ class Input extends Scrollable {
...
@@ -26,7 +26,7 @@ class Input extends Scrollable {
})
:
super
(
})
:
super
(
key:
key
,
key:
key
,
initialScrollOffset:
0.0
,
initialScrollOffset:
0.0
,
scrollDirection:
ScrollDirection
.
horizontal
scrollDirection:
Axis
.
horizontal
)
{
)
{
assert
(
key
!=
null
);
assert
(
key
!=
null
);
}
}
...
...
packages/flutter/lib/src/material/material_list.dart
View file @
b6f3b298
...
@@ -44,7 +44,7 @@ class _MaterialListState extends State<MaterialList> {
...
@@ -44,7 +44,7 @@ class _MaterialListState extends State<MaterialList> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
ScrollableList
(
return
new
ScrollableList
(
initialScrollOffset:
config
.
initialScrollOffset
,
initialScrollOffset:
config
.
initialScrollOffset
,
scrollDirection:
ScrollDirection
.
vertical
,
scrollDirection:
Axis
.
vertical
,
onScroll:
config
.
onScroll
,
onScroll:
config
.
onScroll
,
itemExtent:
_kItemExtent
[
config
.
type
],
itemExtent:
_kItemExtent
[
config
.
type
],
padding:
const
EdgeDims
.
symmetric
(
vertical:
8.0
),
padding:
const
EdgeDims
.
symmetric
(
vertical:
8.0
),
...
...
packages/flutter/lib/src/material/scrollbar_painter.dart
View file @
b6f3b298
...
@@ -31,7 +31,7 @@ class ScrollbarPainter extends ScrollableListPainter {
...
@@ -31,7 +31,7 @@ class ScrollbarPainter extends ScrollableListPainter {
Size
thumbSize
;
Size
thumbSize
;
switch
(
scrollDirection
)
{
switch
(
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
double
thumbHeight
=
viewportBounds
.
height
*
viewportBounds
.
height
/
contentExtent
;
double
thumbHeight
=
viewportBounds
.
height
*
viewportBounds
.
height
/
contentExtent
;
thumbHeight
=
thumbHeight
.
clamp
(
_kMinScrollbarThumbLength
,
viewportBounds
.
height
);
thumbHeight
=
thumbHeight
.
clamp
(
_kMinScrollbarThumbLength
,
viewportBounds
.
height
);
final
double
maxThumbTop
=
viewportBounds
.
height
-
thumbHeight
;
final
double
maxThumbTop
=
viewportBounds
.
height
-
thumbHeight
;
...
@@ -40,7 +40,7 @@ class ScrollbarPainter extends ScrollableListPainter {
...
@@ -40,7 +40,7 @@ class ScrollbarPainter extends ScrollableListPainter {
thumbOrigin
=
new
Point
(
viewportBounds
.
right
-
_kScrollbarThumbGirth
,
thumbTop
);
thumbOrigin
=
new
Point
(
viewportBounds
.
right
-
_kScrollbarThumbGirth
,
thumbTop
);
thumbSize
=
new
Size
(
_kScrollbarThumbGirth
,
thumbHeight
);
thumbSize
=
new
Size
(
_kScrollbarThumbGirth
,
thumbHeight
);
break
;
break
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
double
thumbWidth
=
viewportBounds
.
width
*
viewportBounds
.
width
/
contentExtent
;
double
thumbWidth
=
viewportBounds
.
width
*
viewportBounds
.
width
/
contentExtent
;
thumbWidth
=
thumbWidth
.
clamp
(
_kMinScrollbarThumbLength
,
viewportBounds
.
width
);
thumbWidth
=
thumbWidth
.
clamp
(
_kMinScrollbarThumbLength
,
viewportBounds
.
width
);
final
double
maxThumbLeft
=
viewportBounds
.
width
-
thumbWidth
;
final
double
maxThumbLeft
=
viewportBounds
.
width
-
thumbWidth
;
...
...
packages/flutter/lib/src/material/tabs.dart
View file @
b6f3b298
...
@@ -544,7 +544,7 @@ class TabBar<T> extends Scrollable {
...
@@ -544,7 +544,7 @@ class TabBar<T> extends Scrollable {
Key
key
,
Key
key
,
this
.
labels
,
this
.
labels
,
this
.
isScrollable
:
false
this
.
isScrollable
:
false
})
:
super
(
key:
key
,
scrollDirection:
ScrollDirection
.
horizontal
);
})
:
super
(
key:
key
,
scrollDirection:
Axis
.
horizontal
);
final
Map
<
T
,
TabLabel
>
labels
;
final
Map
<
T
,
TabLabel
>
labels
;
final
bool
isScrollable
;
final
bool
isScrollable
;
...
@@ -687,7 +687,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
...
@@ -687,7 +687,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
void
_updateScrollBehavior
()
{
void
_updateScrollBehavior
()
{
scrollBehavior
.
updateExtents
(
scrollBehavior
.
updateExtents
(
containerExtent:
config
.
scrollDirection
==
ScrollDirection
.
vertical
?
_viewportSize
.
height
:
_viewportSize
.
width
,
containerExtent:
config
.
scrollDirection
==
Axis
.
vertical
?
_viewportSize
.
height
:
_viewportSize
.
width
,
contentExtent:
_tabWidths
.
reduce
((
double
sum
,
double
width
)
=>
sum
+
width
)
contentExtent:
_tabWidths
.
reduce
((
double
sum
,
double
width
)
=>
sum
+
width
)
);
);
}
}
...
@@ -753,7 +753,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
...
@@ -753,7 +753,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
contents
=
new
SizeObserver
(
contents
=
new
SizeObserver
(
onSizeChanged:
_handleViewportSizeChanged
,
onSizeChanged:
_handleViewportSizeChanged
,
child:
new
Viewport
(
child:
new
Viewport
(
scrollDirection:
ScrollDirection
.
horizontal
,
scrollDirection:
Axis
.
horizontal
,
scrollOffset:
new
Offset
(
scrollOffset
,
0.0
),
scrollOffset:
new
Offset
(
scrollOffset
,
0.0
),
child:
contents
child:
contents
)
)
...
@@ -770,7 +770,7 @@ class TabBarView extends PageableList {
...
@@ -770,7 +770,7 @@ class TabBarView extends PageableList {
List
<
Widget
>
children
List
<
Widget
>
children
})
:
super
(
})
:
super
(
key:
key
,
key:
key
,
scrollDirection:
ScrollDirection
.
horizontal
,
scrollDirection:
Axis
.
horizontal
,
children:
children
children:
children
)
{
)
{
assert
(
children
!=
null
);
assert
(
children
!=
null
);
...
...
packages/flutter/lib/src/rendering/block.dart
View file @
b6f3b298
...
@@ -32,7 +32,7 @@ abstract class RenderBlockBase extends RenderBox
...
@@ -32,7 +32,7 @@ abstract class RenderBlockBase extends RenderBox
RenderBlockBase
({
RenderBlockBase
({
List
<
RenderBox
>
children
,
List
<
RenderBox
>
children
,
ScrollDirection
direction:
ScrollDirection
.
vertical
,
Axis
direction:
Axis
.
vertical
,
double
itemExtent
,
double
itemExtent
,
double
minExtent:
0.0
double
minExtent:
0.0
})
:
_direction
=
direction
,
_itemExtent
=
itemExtent
,
_minExtent
=
minExtent
{
})
:
_direction
=
direction
,
_itemExtent
=
itemExtent
,
_minExtent
=
minExtent
{
...
@@ -45,9 +45,9 @@ abstract class RenderBlockBase extends RenderBox
...
@@ -45,9 +45,9 @@ abstract class RenderBlockBase extends RenderBox
}
}
/// The direction to use as the main axis.
/// The direction to use as the main axis.
ScrollDirection
get
direction
=>
_direction
;
Axis
get
direction
=>
_direction
;
ScrollDirection
_direction
;
Axis
_direction
;
void
set
direction
(
ScrollDirection
value
)
{
void
set
direction
(
Axis
value
)
{
if
(
_direction
!=
value
)
{
if
(
_direction
!=
value
)
{
_direction
=
value
;
_direction
=
value
;
markNeedsLayout
();
markNeedsLayout
();
...
@@ -75,9 +75,9 @@ abstract class RenderBlockBase extends RenderBox
...
@@ -75,9 +75,9 @@ abstract class RenderBlockBase extends RenderBox
}
}
/// Whether the main axis is vertical.
/// Whether the main axis is vertical.
bool
get
isVertical
=>
_direction
==
ScrollDirection
.
vertical
;
bool
get
isVertical
=>
_direction
==
Axis
.
vertical
;
ScrollDirection
get
scrollDirection
=>
_direction
;
Axis
get
scrollDirection
=>
_direction
;
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
if
(
isVertical
)
if
(
isVertical
)
...
@@ -126,7 +126,7 @@ class RenderBlock extends RenderBlockBase {
...
@@ -126,7 +126,7 @@ class RenderBlock extends RenderBlockBase {
RenderBlock
({
RenderBlock
({
List
<
RenderBox
>
children
,
List
<
RenderBox
>
children
,
ScrollDirection
direction:
ScrollDirection
.
vertical
,
Axis
direction:
Axis
.
vertical
,
double
itemExtent
,
double
itemExtent
,
double
minExtent:
0.0
double
minExtent:
0.0
})
:
super
(
children:
children
,
direction:
direction
,
itemExtent:
itemExtent
,
minExtent:
minExtent
);
})
:
super
(
children:
children
,
direction:
direction
,
itemExtent:
itemExtent
,
minExtent:
minExtent
);
...
@@ -242,7 +242,7 @@ class RenderBlockViewport extends RenderBlockBase {
...
@@ -242,7 +242,7 @@ class RenderBlockViewport extends RenderBlockBase {
ExtentCallback
maxCrossAxisDimensionCallback
,
ExtentCallback
maxCrossAxisDimensionCallback
,
ExtentCallback
minCrossAxisDimensionCallback
,
ExtentCallback
minCrossAxisDimensionCallback
,
Painter
overlayPainter
,
Painter
overlayPainter
,
ScrollDirection
direction:
ScrollDirection
.
vertical
,
Axis
direction:
Axis
.
vertical
,
double
itemExtent
,
double
itemExtent
,
double
minExtent:
0.0
,
double
minExtent:
0.0
,
double
startOffset:
0.0
,
double
startOffset:
0.0
,
...
...
packages/flutter/lib/src/rendering/box.dart
View file @
b6f3b298
...
@@ -23,6 +23,15 @@ class _DebugSize extends Size {
...
@@ -23,6 +23,15 @@ class _DebugSize extends Size {
final
bool
_canBeUsedByParent
;
final
bool
_canBeUsedByParent
;
}
}
/// The two cardinal directions in two dimensions.
enum
Axis
{
/// Left and right
horizontal
,
/// Up and down
vertical
,
}
/// Immutable layout constraints for box layout.
/// Immutable layout constraints for box layout.
///
///
/// A size respects a BoxConstraints if, and only if, all of the following
/// A size respects a BoxConstraints if, and only if, all of the following
...
...
packages/flutter/lib/src/rendering/list.dart
View file @
b6f3b298
...
@@ -18,7 +18,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
...
@@ -18,7 +18,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
EdgeDims
padding
,
EdgeDims
padding
,
int
virtualChildCount
,
int
virtualChildCount
,
Offset
paintOffset:
Offset
.
zero
,
Offset
paintOffset:
Offset
.
zero
,
ScrollDirection
scrollDirection:
ScrollDirection
.
vertical
,
Axis
scrollDirection:
Axis
.
vertical
,
LayoutCallback
callback
LayoutCallback
callback
})
:
_itemExtent
=
itemExtent
,
})
:
_itemExtent
=
itemExtent
,
_padding
=
padding
,
_padding
=
padding
,
...
@@ -50,9 +50,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
...
@@ -50,9 +50,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
markNeedsLayout
();
markNeedsLayout
();
}
}
ScrollDirection
get
scrollDirection
=>
_scrollDirection
;
Axis
get
scrollDirection
=>
_scrollDirection
;
ScrollDirection
_scrollDirection
;
Axis
_scrollDirection
;
void
set
scrollDirection
(
ScrollDirection
newValue
)
{
void
set
scrollDirection
(
Axis
newValue
)
{
if
(
_scrollDirection
==
newValue
)
if
(
_scrollDirection
==
newValue
)
return
;
return
;
_scrollDirection
=
newValue
;
_scrollDirection
=
newValue
;
...
@@ -66,9 +66,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
...
@@ -66,9 +66,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
double
get
_scrollAxisPadding
{
double
get
_scrollAxisPadding
{
switch
(
scrollDirection
)
{
switch
(
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
padding
.
vertical
;
return
padding
.
vertical
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
padding
.
horizontal
;
return
padding
.
horizontal
;
}
}
}
}
...
@@ -85,9 +85,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
...
@@ -85,9 +85,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
double
_getIntrinsicWidth
(
BoxConstraints
constraints
)
{
double
_getIntrinsicWidth
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
assert
(
constraints
.
isNormalized
);
switch
(
scrollDirection
)
{
switch
(
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
constraints
.
constrainWidth
(
0.0
);
return
constraints
.
constrainWidth
(
0.0
);
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
constraints
.
constrainWidth
(
_preferredExtent
);
return
constraints
.
constrainWidth
(
_preferredExtent
);
}
}
}
}
...
@@ -103,9 +103,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
...
@@ -103,9 +103,9 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
double
_getIntrinsicHeight
(
BoxConstraints
constraints
)
{
double
_getIntrinsicHeight
(
BoxConstraints
constraints
)
{
assert
(
constraints
.
isNormalized
);
assert
(
constraints
.
isNormalized
);
switch
(
scrollDirection
)
{
switch
(
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
constraints
.
constrainHeight
(
_preferredExtent
);
return
constraints
.
constrainHeight
(
_preferredExtent
);
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
constraints
.
constrainHeight
(
0.0
);
return
constraints
.
constrainHeight
(
0.0
);
}
}
}
}
...
@@ -120,11 +120,11 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
...
@@ -120,11 +120,11 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
void
performLayout
()
{
void
performLayout
()
{
switch
(
scrollDirection
)
{
switch
(
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
size
=
new
Size
(
constraints
.
maxWidth
,
size
=
new
Size
(
constraints
.
maxWidth
,
constraints
.
constrainHeight
(
_preferredExtent
));
constraints
.
constrainHeight
(
_preferredExtent
));
break
;
break
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
size
=
new
Size
(
constraints
.
constrainWidth
(
_preferredExtent
),
size
=
new
Size
(
constraints
.
constrainWidth
(
_preferredExtent
),
constraints
.
maxHeight
);
constraints
.
maxHeight
);
break
;
break
;
...
@@ -143,13 +143,13 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
...
@@ -143,13 +143,13 @@ class RenderList extends RenderVirtualViewport<ListParentData> implements HasScr
double
dy
=
0.0
;
double
dy
=
0.0
;
switch
(
scrollDirection
)
{
switch
(
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
itemWidth
=
math
.
max
(
0
,
size
.
width
-
(
padding
==
null
?
0.0
:
padding
.
horizontal
));
itemWidth
=
math
.
max
(
0
,
size
.
width
-
(
padding
==
null
?
0.0
:
padding
.
horizontal
));
itemHeight
=
itemExtent
??
size
.
height
;
itemHeight
=
itemExtent
??
size
.
height
;
y
=
padding
!=
null
?
padding
.
top
:
0.0
;
y
=
padding
!=
null
?
padding
.
top
:
0.0
;
dy
=
itemHeight
;
dy
=
itemHeight
;
break
;
break
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
itemWidth
=
itemExtent
??
size
.
width
;
itemWidth
=
itemExtent
??
size
.
width
;
itemHeight
=
math
.
max
(
0
,
size
.
height
-
(
padding
==
null
?
0.0
:
padding
.
vertical
));
itemHeight
=
math
.
max
(
0
,
size
.
height
-
(
padding
==
null
?
0.0
:
padding
.
vertical
));
x
=
padding
!=
null
?
padding
.
left
:
0.0
;
x
=
padding
!=
null
?
padding
.
left
:
0.0
;
...
...
packages/flutter/lib/src/rendering/viewport.dart
View file @
b6f3b298
...
@@ -9,17 +9,8 @@ import 'package:vector_math/vector_math_64.dart';
...
@@ -9,17 +9,8 @@ import 'package:vector_math/vector_math_64.dart';
import
'box.dart'
;
import
'box.dart'
;
import
'object.dart'
;
import
'object.dart'
;
/// The direction in which to scroll
enum
ScrollDirection
{
/// Scroll left and right
horizontal
,
/// Scroll up and down
vertical
,
}
abstract
class
HasScrollDirection
{
abstract
class
HasScrollDirection
{
ScrollDirection
get
scrollDirection
;
Axis
get
scrollDirection
;
}
}
/// A render object that's bigger on the inside.
/// A render object that's bigger on the inside.
...
@@ -37,18 +28,18 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
...
@@ -37,18 +28,18 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
RenderViewport
({
RenderViewport
({
RenderBox
child
,
RenderBox
child
,
Offset
scrollOffset:
Offset
.
zero
,
Offset
scrollOffset:
Offset
.
zero
,
ScrollDirection
scrollDirection:
ScrollDirection
.
vertical
Axis
scrollDirection:
Axis
.
vertical
})
:
_scrollOffset
=
scrollOffset
,
})
:
_scrollOffset
=
scrollOffset
,
_scrollDirection
=
scrollDirection
{
_scrollDirection
=
scrollDirection
{
assert
(
_offsetIsSane
(
scrollOffset
,
scrollDirection
));
assert
(
_offsetIsSane
(
scrollOffset
,
scrollDirection
));
this
.
child
=
child
;
this
.
child
=
child
;
}
}
bool
_offsetIsSane
(
Offset
offset
,
ScrollDirection
direction
)
{
bool
_offsetIsSane
(
Offset
offset
,
Axis
direction
)
{
switch
(
direction
)
{
switch
(
direction
)
{
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
offset
.
dy
==
0.0
;
return
offset
.
dy
==
0.0
;
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
offset
.
dx
==
0.0
;
return
offset
.
dx
==
0.0
;
}
}
}
}
...
@@ -71,9 +62,9 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
...
@@ -71,9 +62,9 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
/// If the viewport is scrollable in a particular direction (e.g., vertically),
/// If the viewport is scrollable in a particular direction (e.g., vertically),
/// the child is given layout constraints that are fully unconstrainted in
/// the child is given layout constraints that are fully unconstrainted in
/// that direction (e.g., the child can be as tall as it wants).
/// that direction (e.g., the child can be as tall as it wants).
ScrollDirection
get
scrollDirection
=>
_scrollDirection
;
Axis
get
scrollDirection
=>
_scrollDirection
;
ScrollDirection
_scrollDirection
;
Axis
_scrollDirection
;
void
set
scrollDirection
(
ScrollDirection
value
)
{
void
set
scrollDirection
(
Axis
value
)
{
if
(
value
==
_scrollDirection
)
if
(
value
==
_scrollDirection
)
return
;
return
;
assert
(
_offsetIsSane
(
scrollOffset
,
value
));
assert
(
_offsetIsSane
(
scrollOffset
,
value
));
...
@@ -84,10 +75,10 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
...
@@ -84,10 +75,10 @@ class RenderViewport extends RenderBox with RenderObjectWithChildMixin<RenderBox
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
BoxConstraints
innerConstraints
;
BoxConstraints
innerConstraints
;
switch
(
scrollDirection
)
{
switch
(
scrollDirection
)
{
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
innerConstraints
=
constraints
.
heightConstraints
();
innerConstraints
=
constraints
.
heightConstraints
();
break
;
break
;
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
innerConstraints
=
constraints
.
widthConstraints
();
innerConstraints
=
constraints
.
widthConstraints
();
break
;
break
;
}
}
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
b6f3b298
...
@@ -54,7 +54,7 @@ export 'package:flutter/rendering.dart' show
...
@@ -54,7 +54,7 @@ export 'package:flutter/rendering.dart' show
PointerUpEvent
,
PointerUpEvent
,
RadialGradient
,
RadialGradient
,
Rect
,
Rect
,
ScrollDirection
,
Axis
,
Size
,
Size
,
StyledTextSpan
,
StyledTextSpan
,
TextAlign
,
TextAlign
,
...
@@ -755,7 +755,7 @@ class Baseline extends OneChildRenderObjectWidget {
...
@@ -755,7 +755,7 @@ class Baseline extends OneChildRenderObjectWidget {
class
Viewport
extends
OneChildRenderObjectWidget
{
class
Viewport
extends
OneChildRenderObjectWidget
{
Viewport
({
Viewport
({
Key
key
,
Key
key
,
this
.
scrollDirection
:
ScrollDirection
.
vertical
,
this
.
scrollDirection
:
Axis
.
vertical
,
this
.
scrollOffset
:
Offset
.
zero
,
this
.
scrollOffset
:
Offset
.
zero
,
Widget
child
Widget
child
})
:
super
(
key:
key
,
child:
child
)
{
})
:
super
(
key:
key
,
child:
child
)
{
...
@@ -768,7 +768,7 @@ class Viewport extends OneChildRenderObjectWidget {
...
@@ -768,7 +768,7 @@ class Viewport extends OneChildRenderObjectWidget {
/// If the viewport is scrollable in a particular direction (e.g., vertically),
/// If the viewport is scrollable in a particular direction (e.g., vertically),
/// the child is given layout constraints that are fully unconstrainted in
/// the child is given layout constraints that are fully unconstrainted in
/// that direction (e.g., the child can be as tall as it wants).
/// that direction (e.g., the child can be as tall as it wants).
final
ScrollDirection
scrollDirection
;
final
Axis
scrollDirection
;
/// The offset at which to paint the child.
/// The offset at which to paint the child.
///
///
...
@@ -929,13 +929,13 @@ class Container extends StatelessComponent {
...
@@ -929,13 +929,13 @@ class Container extends StatelessComponent {
class
BlockBody
extends
MultiChildRenderObjectWidget
{
class
BlockBody
extends
MultiChildRenderObjectWidget
{
BlockBody
(
List
<
Widget
>
children
,
{
BlockBody
(
List
<
Widget
>
children
,
{
Key
key
,
Key
key
,
this
.
direction
:
ScrollDirection
.
vertical
this
.
direction
:
Axis
.
vertical
})
:
super
(
key:
key
,
children:
children
)
{
})
:
super
(
key:
key
,
children:
children
)
{
assert
(
direction
!=
null
);
assert
(
direction
!=
null
);
}
}
/// The direction to use as the main axis.
/// The direction to use as the main axis.
final
ScrollDirection
direction
;
final
Axis
direction
;
RenderBlock
createRenderObject
()
=>
new
RenderBlock
(
direction:
direction
);
RenderBlock
createRenderObject
()
=>
new
RenderBlock
(
direction:
direction
);
...
...
packages/flutter/lib/src/widgets/homogeneous_viewport.dart
View file @
b6f3b298
...
@@ -17,7 +17,7 @@ abstract class _ViewportBase extends RenderObjectWidget {
...
@@ -17,7 +17,7 @@ abstract class _ViewportBase extends RenderObjectWidget {
this
.
builder
,
this
.
builder
,
this
.
itemsWrap
:
false
,
this
.
itemsWrap
:
false
,
this
.
itemCount
,
this
.
itemCount
,
this
.
direction
:
ScrollDirection
.
vertical
,
this
.
direction
:
Axis
.
vertical
,
this
.
startOffset
:
0.0
,
this
.
startOffset
:
0.0
,
this
.
overlayPainter
this
.
overlayPainter
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
...
@@ -25,7 +25,7 @@ abstract class _ViewportBase extends RenderObjectWidget {
...
@@ -25,7 +25,7 @@ abstract class _ViewportBase extends RenderObjectWidget {
final
ListBuilder
builder
;
final
ListBuilder
builder
;
final
bool
itemsWrap
;
final
bool
itemsWrap
;
final
int
itemCount
;
final
int
itemCount
;
final
ScrollDirection
direction
;
final
Axis
direction
;
final
double
startOffset
;
final
double
startOffset
;
final
Painter
overlayPainter
;
final
Painter
overlayPainter
;
...
@@ -112,7 +112,7 @@ abstract class _ViewportBaseElement<T extends _ViewportBase> extends RenderObjec
...
@@ -112,7 +112,7 @@ abstract class _ViewportBaseElement<T extends _ViewportBase> extends RenderObjec
}
}
double
getMaxCrossAxisExtent
(
BoxConstraints
constraints
)
{
double
getMaxCrossAxisExtent
(
BoxConstraints
constraints
)
{
if
(
widget
.
direction
==
ScrollDirection
.
vertical
)
if
(
widget
.
direction
==
Axis
.
vertical
)
return
constraints
.
maxWidth
;
return
constraints
.
maxWidth
;
return
constraints
.
maxHeight
;
return
constraints
.
maxHeight
;
}
}
...
@@ -141,7 +141,7 @@ class HomogeneousViewport extends _ViewportBase {
...
@@ -141,7 +141,7 @@ class HomogeneousViewport extends _ViewportBase {
ListBuilder
builder
,
ListBuilder
builder
,
bool
itemsWrap:
false
,
bool
itemsWrap:
false
,
int
itemCount
,
// optional, but you cannot shrink-wrap this class or otherwise use its intrinsic dimensions if you don't specify it
int
itemCount
,
// optional, but you cannot shrink-wrap this class or otherwise use its intrinsic dimensions if you don't specify it
ScrollDirection
direction:
ScrollDirection
.
vertical
,
Axis
direction:
Axis
.
vertical
,
double
startOffset:
0.0
,
double
startOffset:
0.0
,
Painter
overlayPainter
,
Painter
overlayPainter
,
this
.
itemExtent
// required, must be non-zero
this
.
itemExtent
// required, must be non-zero
...
@@ -180,7 +180,7 @@ class _HomogeneousViewportElement extends _ViewportBaseElement<HomogeneousViewpo
...
@@ -180,7 +180,7 @@ class _HomogeneousViewportElement extends _ViewportBaseElement<HomogeneousViewpo
// be ok because we are exempt from that assert since we are still actively
// be ok because we are exempt from that assert since we are still actively
// doing our own layout.)
// doing our own layout.)
BuildableElement
.
lockState
(()
{
BuildableElement
.
lockState
(()
{
double
mainAxisExtent
=
widget
.
direction
==
ScrollDirection
.
vertical
?
constraints
.
maxHeight
:
constraints
.
maxWidth
;
double
mainAxisExtent
=
widget
.
direction
==
Axis
.
vertical
?
constraints
.
maxHeight
:
constraints
.
maxWidth
;
double
offset
;
double
offset
;
if
(
widget
.
startOffset
<=
0.0
&&
!
widget
.
itemsWrap
)
{
if
(
widget
.
startOffset
<=
0.0
&&
!
widget
.
itemsWrap
)
{
_layoutFirstIndex
=
0
;
_layoutFirstIndex
=
0
;
...
...
packages/flutter/lib/src/widgets/mixed_viewport.dart
View file @
b6f3b298
...
@@ -18,7 +18,7 @@ class MixedViewport extends RenderObjectWidget {
...
@@ -18,7 +18,7 @@ class MixedViewport extends RenderObjectWidget {
MixedViewport
({
MixedViewport
({
Key
key
,
Key
key
,
this
.
startOffset
:
0.0
,
this
.
startOffset
:
0.0
,
this
.
direction
:
ScrollDirection
.
vertical
,
this
.
direction
:
Axis
.
vertical
,
this
.
builder
,
this
.
builder
,
this
.
token
,
this
.
token
,
this
.
onExtentsUpdate
,
this
.
onExtentsUpdate
,
...
@@ -26,7 +26,7 @@ class MixedViewport extends RenderObjectWidget {
...
@@ -26,7 +26,7 @@ class MixedViewport extends RenderObjectWidget {
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
double
startOffset
;
final
double
startOffset
;
final
ScrollDirection
direction
;
final
Axis
direction
;
final
IndexedBuilder
builder
;
final
IndexedBuilder
builder
;
final
Object
token
;
// change this if the list changed (i.e. there are added, removed, or resorted items)
final
Object
token
;
// change this if the list changed (i.e. there are added, removed, or resorted items)
final
ExtentsUpdateCallback
onExtentsUpdate
;
final
ExtentsUpdateCallback
onExtentsUpdate
;
...
@@ -315,18 +315,18 @@ class _MixedViewportElement extends RenderObjectElement<MixedViewport> {
...
@@ -315,18 +315,18 @@ class _MixedViewportElement extends RenderObjectElement<MixedViewport> {
double
_getElementExtent
(
Element
element
,
BoxConstraints
innerConstraints
)
{
double
_getElementExtent
(
Element
element
,
BoxConstraints
innerConstraints
)
{
final
RenderBox
childRenderObject
=
element
.
renderObject
;
final
RenderBox
childRenderObject
=
element
.
renderObject
;
switch
(
widget
.
direction
)
{
switch
(
widget
.
direction
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
childRenderObject
.
getMaxIntrinsicHeight
(
innerConstraints
);
return
childRenderObject
.
getMaxIntrinsicHeight
(
innerConstraints
);
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
childRenderObject
.
getMaxIntrinsicWidth
(
innerConstraints
);
return
childRenderObject
.
getMaxIntrinsicWidth
(
innerConstraints
);
}
}
}
}
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
BoxConstraints
_getInnerConstraints
(
BoxConstraints
constraints
)
{
switch
(
widget
.
direction
)
{
switch
(
widget
.
direction
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
new
BoxConstraints
.
tightFor
(
width:
constraints
.
constrainWidth
());
return
new
BoxConstraints
.
tightFor
(
width:
constraints
.
constrainWidth
());
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
new
BoxConstraints
.
tightFor
(
height:
constraints
.
constrainHeight
());
return
new
BoxConstraints
.
tightFor
(
height:
constraints
.
constrainHeight
());
}
}
}
}
...
@@ -353,14 +353,14 @@ class _MixedViewportElement extends RenderObjectElement<MixedViewport> {
...
@@ -353,14 +353,14 @@ class _MixedViewportElement extends RenderObjectElement<MixedViewport> {
// Establish the start and end offsets based on our current constraints.
// Establish the start and end offsets based on our current constraints.
double
extent
;
double
extent
;
switch
(
widget
.
direction
)
{
switch
(
widget
.
direction
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
extent
=
constraints
.
maxHeight
;
extent
=
constraints
.
maxHeight
;
assert
(
extent
<
double
.
INFINITY
&&
assert
(
extent
<
double
.
INFINITY
&&
'There is no point putting a lazily-built vertical MixedViewport inside a box with infinite internal '
+
'There is no point putting a lazily-built vertical MixedViewport inside a box with infinite internal '
+
'height (e.g. inside something else that scrolls vertically), because it would then just eagerly build '
+
'height (e.g. inside something else that scrolls vertically), because it would then just eagerly build '
+
'all the children. You probably want to put the MixedViewport inside a Container with a fixed height.'
is
String
);
'all the children. You probably want to put the MixedViewport inside a Container with a fixed height.'
is
String
);
break
;
break
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
extent
=
constraints
.
maxWidth
;
extent
=
constraints
.
maxWidth
;
assert
(
extent
<
double
.
INFINITY
&&
assert
(
extent
<
double
.
INFINITY
&&
'There is no point putting a lazily-built horizontal MixedViewport inside a box with infinite internal '
+
'There is no point putting a lazily-built horizontal MixedViewport inside a box with infinite internal '
+
...
...
packages/flutter/lib/src/widgets/pageable_list.dart
View file @
b6f3b298
...
@@ -25,7 +25,7 @@ class PageableList extends Scrollable {
...
@@ -25,7 +25,7 @@ class PageableList extends Scrollable {
PageableList
({
PageableList
({
Key
key
,
Key
key
,
initialScrollOffset
,
initialScrollOffset
,
ScrollDirection
scrollDirection:
ScrollDirection
.
vertical
,
Axis
scrollDirection:
Axis
.
vertical
,
ScrollListener
onScrollStart
,
ScrollListener
onScrollStart
,
ScrollListener
onScroll
,
ScrollListener
onScroll
,
ScrollListener
onScrollEnd
,
ScrollListener
onScrollEnd
,
...
@@ -68,7 +68,7 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
...
@@ -68,7 +68,7 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
final
RenderBox
box
=
context
.
findRenderObject
();
final
RenderBox
box
=
context
.
findRenderObject
();
if
(
box
==
null
||
!
box
.
hasSize
)
if
(
box
==
null
||
!
box
.
hasSize
)
return
0.0
;
return
0.0
;
final
double
pixelScrollExtent
=
config
.
scrollDirection
==
ScrollDirection
.
vertical
?
box
.
size
.
height
:
box
.
size
.
width
;
final
double
pixelScrollExtent
=
config
.
scrollDirection
==
Axis
.
vertical
?
box
.
size
.
height
:
box
.
size
.
width
;
return
pixelScrollExtent
==
0.0
?
0.0
:
value
/
pixelScrollExtent
;
return
pixelScrollExtent
==
0.0
?
0.0
:
value
/
pixelScrollExtent
;
}
}
...
@@ -183,7 +183,7 @@ class PageViewport extends VirtualViewport {
...
@@ -183,7 +183,7 @@ class PageViewport extends VirtualViewport {
PageViewport
({
PageViewport
({
Key
key
,
Key
key
,
this
.
startOffset
:
0.0
,
this
.
startOffset
:
0.0
,
this
.
scrollDirection
:
ScrollDirection
.
vertical
,
this
.
scrollDirection
:
Axis
.
vertical
,
this
.
itemsWrap
:
false
,
this
.
itemsWrap
:
false
,
this
.
overlayPainter
,
this
.
overlayPainter
,
this
.
children
this
.
children
...
@@ -192,7 +192,7 @@ class PageViewport extends VirtualViewport {
...
@@ -192,7 +192,7 @@ class PageViewport extends VirtualViewport {
}
}
final
double
startOffset
;
final
double
startOffset
;
final
ScrollDirection
scrollDirection
;
final
Axis
scrollDirection
;
final
bool
itemsWrap
;
final
bool
itemsWrap
;
final
Painter
overlayPainter
;
final
Painter
overlayPainter
;
final
Iterable
<
Widget
>
children
;
final
Iterable
<
Widget
>
children
;
...
@@ -235,9 +235,9 @@ class _PageViewportElement extends VirtualViewportElement<PageViewport> {
...
@@ -235,9 +235,9 @@ class _PageViewportElement extends VirtualViewportElement<PageViewport> {
double
_getContainerExtentFromRenderObject
()
{
double
_getContainerExtentFromRenderObject
()
{
switch
(
widget
.
scrollDirection
)
{
switch
(
widget
.
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
renderObject
.
size
.
height
;
return
renderObject
.
size
.
height
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
renderObject
.
size
.
width
;
return
renderObject
.
size
.
width
;
}
}
}
}
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
b6f3b298
...
@@ -38,19 +38,19 @@ abstract class Scrollable extends StatefulComponent {
...
@@ -38,19 +38,19 @@ abstract class Scrollable extends StatefulComponent {
Scrollable
({
Scrollable
({
Key
key
,
Key
key
,
this
.
initialScrollOffset
,
this
.
initialScrollOffset
,
this
.
scrollDirection
:
ScrollDirection
.
vertical
,
this
.
scrollDirection
:
Axis
.
vertical
,
this
.
onScrollStart
,
this
.
onScrollStart
,
this
.
onScroll
,
this
.
onScroll
,
this
.
onScrollEnd
,
this
.
onScrollEnd
,
this
.
snapOffsetCallback
,
this
.
snapOffsetCallback
,
this
.
snapAlignmentOffset
:
0.0
this
.
snapAlignmentOffset
:
0.0
})
:
super
(
key:
key
)
{
})
:
super
(
key:
key
)
{
assert
(
scrollDirection
==
ScrollDirection
.
vertical
||
assert
(
scrollDirection
==
Axis
.
vertical
||
scrollDirection
==
ScrollDirection
.
horizontal
);
scrollDirection
==
Axis
.
horizontal
);
}
}
final
double
initialScrollOffset
;
final
double
initialScrollOffset
;
final
ScrollDirection
scrollDirection
;
final
Axis
scrollDirection
;
final
ScrollListener
onScrollStart
;
final
ScrollListener
onScrollStart
;
final
ScrollListener
onScroll
;
final
ScrollListener
onScroll
;
final
ScrollListener
onScrollEnd
;
final
ScrollListener
onScrollEnd
;
...
@@ -81,12 +81,12 @@ abstract class Scrollable extends StatefulComponent {
...
@@ -81,12 +81,12 @@ abstract class Scrollable extends StatefulComponent {
double
scrollOffsetDelta
;
double
scrollOffsetDelta
;
switch
(
scrollable
.
config
.
scrollDirection
)
{
switch
(
scrollable
.
config
.
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
0.0
,
targetSize
.
height
/
2.0
));
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
0.0
,
targetSize
.
height
/
2.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
0.0
,
scrollableSize
.
height
/
2.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
0.0
,
scrollableSize
.
height
/
2.0
));
scrollOffsetDelta
=
targetCenter
.
y
-
scrollableCenter
.
y
;
scrollOffsetDelta
=
targetCenter
.
y
-
scrollableCenter
.
y
;
break
;
break
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
targetSize
.
width
/
2.0
,
0.0
));
Point
targetCenter
=
targetBox
.
localToGlobal
(
new
Point
(
targetSize
.
width
/
2.0
,
0.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
scrollableSize
.
width
/
2.0
,
0.0
));
Point
scrollableCenter
=
scrollableBox
.
localToGlobal
(
new
Point
(
scrollableSize
.
width
/
2.0
,
0.0
));
scrollOffsetDelta
=
targetCenter
.
x
-
scrollableCenter
.
x
;
scrollOffsetDelta
=
targetCenter
.
x
-
scrollableCenter
.
x
;
...
@@ -119,7 +119,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
...
@@ -119,7 +119,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
double
_scrollOffset
;
double
_scrollOffset
;
Offset
get
scrollOffsetVector
{
Offset
get
scrollOffsetVector
{
if
(
config
.
scrollDirection
==
ScrollDirection
.
horizontal
)
if
(
config
.
scrollDirection
==
Axis
.
horizontal
)
return
new
Offset
(
scrollOffset
,
0.0
);
return
new
Offset
(
scrollOffset
,
0.0
);
return
new
Offset
(
0.0
,
scrollOffset
);
return
new
Offset
(
0.0
,
scrollOffset
);
}
}
...
@@ -131,7 +131,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
...
@@ -131,7 +131,7 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
double
pixelToScrollOffset
(
double
pixelValue
)
=>
pixelValue
;
double
pixelToScrollOffset
(
double
pixelValue
)
=>
pixelValue
;
double
scrollDirectionVelocity
(
Offset
scrollVelocity
)
{
double
scrollDirectionVelocity
(
Offset
scrollVelocity
)
{
return
config
.
scrollDirection
==
ScrollDirection
.
horizontal
return
config
.
scrollDirection
==
Axis
.
horizontal
?
-
scrollVelocity
.
dx
?
-
scrollVelocity
.
dx
:
-
scrollVelocity
.
dy
;
:
-
scrollVelocity
.
dy
;
}
}
...
@@ -144,19 +144,19 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
...
@@ -144,19 +144,19 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
return
_scrollBehavior
;
return
_scrollBehavior
;
}
}
GestureDragStartCallback
_getDragStartHandler
(
ScrollDirection
direction
)
{
GestureDragStartCallback
_getDragStartHandler
(
Axis
direction
)
{
if
(
config
.
scrollDirection
!=
direction
||
!
scrollBehavior
.
isScrollable
)
if
(
config
.
scrollDirection
!=
direction
||
!
scrollBehavior
.
isScrollable
)
return
null
;
return
null
;
return
_handleDragStart
;
return
_handleDragStart
;
}
}
GestureDragUpdateCallback
_getDragUpdateHandler
(
ScrollDirection
direction
)
{
GestureDragUpdateCallback
_getDragUpdateHandler
(
Axis
direction
)
{
if
(
config
.
scrollDirection
!=
direction
||
!
scrollBehavior
.
isScrollable
)
if
(
config
.
scrollDirection
!=
direction
||
!
scrollBehavior
.
isScrollable
)
return
null
;
return
null
;
return
_handleDragUpdate
;
return
_handleDragUpdate
;
}
}
GestureDragEndCallback
_getDragEndHandler
(
ScrollDirection
direction
)
{
GestureDragEndCallback
_getDragEndHandler
(
Axis
direction
)
{
if
(
config
.
scrollDirection
!=
direction
||
!
scrollBehavior
.
isScrollable
)
if
(
config
.
scrollDirection
!=
direction
||
!
scrollBehavior
.
isScrollable
)
return
null
;
return
null
;
return
_handleDragEnd
;
return
_handleDragEnd
;
...
@@ -164,12 +164,12 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
...
@@ -164,12 +164,12 @@ abstract class ScrollableState<T extends Scrollable> extends State<T> {
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
new
GestureDetector
(
return
new
GestureDetector
(
onVerticalDragStart:
_getDragStartHandler
(
ScrollDirection
.
vertical
),
onVerticalDragStart:
_getDragStartHandler
(
Axis
.
vertical
),
onVerticalDragUpdate:
_getDragUpdateHandler
(
ScrollDirection
.
vertical
),
onVerticalDragUpdate:
_getDragUpdateHandler
(
Axis
.
vertical
),
onVerticalDragEnd:
_getDragEndHandler
(
ScrollDirection
.
vertical
),
onVerticalDragEnd:
_getDragEndHandler
(
Axis
.
vertical
),
onHorizontalDragStart:
_getDragStartHandler
(
ScrollDirection
.
horizontal
),
onHorizontalDragStart:
_getDragStartHandler
(
Axis
.
horizontal
),
onHorizontalDragUpdate:
_getDragUpdateHandler
(
ScrollDirection
.
horizontal
),
onHorizontalDragUpdate:
_getDragUpdateHandler
(
Axis
.
horizontal
),
onHorizontalDragEnd:
_getDragEndHandler
(
ScrollDirection
.
horizontal
),
onHorizontalDragEnd:
_getDragEndHandler
(
Axis
.
horizontal
),
behavior:
HitTestBehavior
.
opaque
,
behavior:
HitTestBehavior
.
opaque
,
child:
new
Listener
(
child:
new
Listener
(
child:
buildContent
(
context
),
child:
buildContent
(
context
),
...
@@ -348,7 +348,7 @@ class ScrollableViewport extends Scrollable {
...
@@ -348,7 +348,7 @@ class ScrollableViewport extends Scrollable {
Key
key
,
Key
key
,
this
.
child
,
this
.
child
,
double
initialScrollOffset
,
double
initialScrollOffset
,
ScrollDirection
scrollDirection:
ScrollDirection
.
vertical
,
Axis
scrollDirection:
Axis
.
vertical
,
ScrollListener
onScroll
ScrollListener
onScroll
})
:
super
(
})
:
super
(
key:
key
,
key:
key
,
...
@@ -369,13 +369,13 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> {
...
@@ -369,13 +369,13 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> {
double
_viewportSize
=
0.0
;
double
_viewportSize
=
0.0
;
double
_childSize
=
0.0
;
double
_childSize
=
0.0
;
void
_handleViewportSizeChanged
(
Size
newSize
)
{
void
_handleViewportSizeChanged
(
Size
newSize
)
{
_viewportSize
=
config
.
scrollDirection
==
ScrollDirection
.
vertical
?
newSize
.
height
:
newSize
.
width
;
_viewportSize
=
config
.
scrollDirection
==
Axis
.
vertical
?
newSize
.
height
:
newSize
.
width
;
setState
(()
{
setState
(()
{
_updateScrollBehavior
();
_updateScrollBehavior
();
});
});
}
}
void
_handleChildSizeChanged
(
Size
newSize
)
{
void
_handleChildSizeChanged
(
Size
newSize
)
{
_childSize
=
config
.
scrollDirection
==
ScrollDirection
.
vertical
?
newSize
.
height
:
newSize
.
width
;
_childSize
=
config
.
scrollDirection
==
Axis
.
vertical
?
newSize
.
height
:
newSize
.
width
;
setState
(()
{
setState
(()
{
_updateScrollBehavior
();
_updateScrollBehavior
();
});
});
...
@@ -412,7 +412,7 @@ class Block extends StatelessComponent {
...
@@ -412,7 +412,7 @@ class Block extends StatelessComponent {
Key
key
,
Key
key
,
this
.
padding
,
this
.
padding
,
this
.
initialScrollOffset
,
this
.
initialScrollOffset
,
this
.
scrollDirection
:
ScrollDirection
.
vertical
,
this
.
scrollDirection
:
Axis
.
vertical
,
this
.
onScroll
this
.
onScroll
})
:
super
(
key:
key
)
{
})
:
super
(
key:
key
)
{
assert
(!
children
.
any
((
Widget
child
)
=>
child
==
null
));
assert
(!
children
.
any
((
Widget
child
)
=>
child
==
null
));
...
@@ -421,7 +421,7 @@ class Block extends StatelessComponent {
...
@@ -421,7 +421,7 @@ class Block extends StatelessComponent {
final
List
<
Widget
>
children
;
final
List
<
Widget
>
children
;
final
EdgeDims
padding
;
final
EdgeDims
padding
;
final
double
initialScrollOffset
;
final
double
initialScrollOffset
;
final
ScrollDirection
scrollDirection
;
final
Axis
scrollDirection
;
final
ScrollListener
onScroll
;
final
ScrollListener
onScroll
;
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
@@ -446,7 +446,7 @@ abstract class ScrollableListPainter extends Painter {
...
@@ -446,7 +446,7 @@ abstract class ScrollableListPainter extends Painter {
RenderBox
get
renderObject
=>
super
.
renderObject
;
RenderBox
get
renderObject
=>
super
.
renderObject
;
ScrollDirection
get
scrollDirection
{
Axis
get
scrollDirection
{
HasScrollDirection
scrollable
=
renderObject
as
dynamic
;
HasScrollDirection
scrollable
=
renderObject
as
dynamic
;
return
scrollable
?.
scrollDirection
;
return
scrollable
?.
scrollDirection
;
}
}
...
@@ -495,7 +495,7 @@ abstract class ScrollableWidgetList extends Scrollable {
...
@@ -495,7 +495,7 @@ abstract class ScrollableWidgetList extends Scrollable {
ScrollableWidgetList
({
ScrollableWidgetList
({
Key
key
,
Key
key
,
double
initialScrollOffset
,
double
initialScrollOffset
,
ScrollDirection
scrollDirection:
ScrollDirection
.
vertical
,
Axis
scrollDirection:
Axis
.
vertical
,
ScrollListener
onScroll
,
ScrollListener
onScroll
,
SnapOffsetCallback
snapOffsetCallback
,
SnapOffsetCallback
snapOffsetCallback
,
double
snapAlignmentOffset:
0.0
,
double
snapAlignmentOffset:
0.0
,
...
@@ -554,7 +554,7 @@ abstract class ScrollableWidgetListState<T extends ScrollableWidgetList> extends
...
@@ -554,7 +554,7 @@ abstract class ScrollableWidgetListState<T extends ScrollableWidgetList> extends
ExtentScrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
ExtentScrollBehavior
get
scrollBehavior
=>
super
.
scrollBehavior
;
double
get
_containerExtent
{
double
get
_containerExtent
{
return
config
.
scrollDirection
==
ScrollDirection
.
vertical
return
config
.
scrollDirection
==
Axis
.
vertical
?
_containerSize
.
height
?
_containerSize
.
height
:
_containerSize
.
width
;
:
_containerSize
.
width
;
}
}
...
@@ -568,14 +568,14 @@ abstract class ScrollableWidgetListState<T extends ScrollableWidgetList> extends
...
@@ -568,14 +568,14 @@ abstract class ScrollableWidgetListState<T extends ScrollableWidgetList> extends
double
get
_leadingPadding
{
double
get
_leadingPadding
{
EdgeDims
padding
=
config
.
padding
;
EdgeDims
padding
=
config
.
padding
;
if
(
config
.
scrollDirection
==
ScrollDirection
.
vertical
)
if
(
config
.
scrollDirection
==
Axis
.
vertical
)
return
padding
!=
null
?
padding
.
top
:
0.0
;
return
padding
!=
null
?
padding
.
top
:
0.0
;
return
padding
!=
null
?
padding
.
left
:
-.
0
;
return
padding
!=
null
?
padding
.
left
:
-.
0
;
}
}
double
get
_trailingPadding
{
double
get
_trailingPadding
{
EdgeDims
padding
=
config
.
padding
;
EdgeDims
padding
=
config
.
padding
;
if
(
config
.
scrollDirection
==
ScrollDirection
.
vertical
)
if
(
config
.
scrollDirection
==
Axis
.
vertical
)
return
padding
!=
null
?
padding
.
bottom
:
0.0
;
return
padding
!=
null
?
padding
.
bottom
:
0.0
;
return
padding
!=
null
?
padding
.
right
:
0.0
;
return
padding
!=
null
?
padding
.
right
:
0.0
;
}
}
...
@@ -584,7 +584,7 @@ abstract class ScrollableWidgetListState<T extends ScrollableWidgetList> extends
...
@@ -584,7 +584,7 @@ abstract class ScrollableWidgetListState<T extends ScrollableWidgetList> extends
EdgeDims
padding
=
config
.
padding
;
EdgeDims
padding
=
config
.
padding
;
if
(
padding
==
null
)
if
(
padding
==
null
)
return
null
;
return
null
;
if
(
config
.
scrollDirection
==
ScrollDirection
.
vertical
)
if
(
config
.
scrollDirection
==
Axis
.
vertical
)
return
new
EdgeDims
.
only
(
left:
padding
.
left
,
right:
padding
.
right
);
return
new
EdgeDims
.
only
(
left:
padding
.
left
,
right:
padding
.
right
);
return
new
EdgeDims
.
only
(
top:
padding
.
top
,
bottom:
padding
.
bottom
);
return
new
EdgeDims
.
only
(
top:
padding
.
top
,
bottom:
padding
.
bottom
);
}
}
...
...
packages/flutter/lib/src/widgets/scrollable_grid.dart
View file @
b6f3b298
...
@@ -29,7 +29,7 @@ class ScrollableGrid extends Scrollable {
...
@@ -29,7 +29,7 @@ class ScrollableGrid extends Scrollable {
// TODO(abarth): Support horizontal offsets. For horizontally scrolling
// TODO(abarth): Support horizontal offsets. For horizontally scrolling
// grids. For horizontally scrolling grids, we'll probably need to use a
// grids. For horizontally scrolling grids, we'll probably need to use a
// delegate that places children in column-major order.
// delegate that places children in column-major order.
scrollDirection:
ScrollDirection
.
vertical
,
scrollDirection:
Axis
.
vertical
,
onScroll:
onScroll
,
onScroll:
onScroll
,
snapOffsetCallback:
snapOffsetCallback
,
snapOffsetCallback:
snapOffsetCallback
,
snapAlignmentOffset:
snapAlignmentOffset
snapAlignmentOffset:
snapAlignmentOffset
...
@@ -80,7 +80,7 @@ class GridViewport extends VirtualViewport {
...
@@ -80,7 +80,7 @@ class GridViewport extends VirtualViewport {
final
Iterable
<
Widget
>
children
;
final
Iterable
<
Widget
>
children
;
// TODO(abarth): Support horizontal scrolling;
// TODO(abarth): Support horizontal scrolling;
ScrollDirection
get
scrollDirection
=>
ScrollDirection
.
vertical
;
Axis
get
scrollDirection
=>
Axis
.
vertical
;
RenderGrid
createRenderObject
()
=>
new
RenderGrid
(
delegate:
delegate
);
RenderGrid
createRenderObject
()
=>
new
RenderGrid
(
delegate:
delegate
);
...
...
packages/flutter/lib/src/widgets/scrollable_list.dart
View file @
b6f3b298
...
@@ -15,7 +15,7 @@ class ScrollableList extends Scrollable {
...
@@ -15,7 +15,7 @@ class ScrollableList extends Scrollable {
ScrollableList
({
ScrollableList
({
Key
key
,
Key
key
,
double
initialScrollOffset
,
double
initialScrollOffset
,
ScrollDirection
scrollDirection:
ScrollDirection
.
vertical
,
Axis
scrollDirection:
Axis
.
vertical
,
ScrollListener
onScroll
,
ScrollListener
onScroll
,
SnapOffsetCallback
snapOffsetCallback
,
SnapOffsetCallback
snapOffsetCallback
,
double
snapAlignmentOffset:
0.0
,
double
snapAlignmentOffset:
0.0
,
...
@@ -93,7 +93,7 @@ class ListViewport extends VirtualViewport {
...
@@ -93,7 +93,7 @@ class ListViewport extends VirtualViewport {
Key
key
,
Key
key
,
this
.
onExtentsChanged
,
this
.
onExtentsChanged
,
this
.
startOffset
:
0.0
,
this
.
startOffset
:
0.0
,
this
.
scrollDirection
:
ScrollDirection
.
vertical
,
this
.
scrollDirection
:
Axis
.
vertical
,
this
.
itemExtent
,
this
.
itemExtent
,
this
.
itemsWrap
:
false
,
this
.
itemsWrap
:
false
,
this
.
padding
,
this
.
padding
,
...
@@ -106,7 +106,7 @@ class ListViewport extends VirtualViewport {
...
@@ -106,7 +106,7 @@ class ListViewport extends VirtualViewport {
final
ExtentsChangedCallback
onExtentsChanged
;
final
ExtentsChangedCallback
onExtentsChanged
;
final
double
startOffset
;
final
double
startOffset
;
final
ScrollDirection
scrollDirection
;
final
Axis
scrollDirection
;
final
double
itemExtent
;
final
double
itemExtent
;
final
bool
itemsWrap
;
final
bool
itemsWrap
;
final
EdgeDims
padding
;
final
EdgeDims
padding
;
...
@@ -148,9 +148,9 @@ class _ListViewportElement extends VirtualViewportElement<ListViewport> {
...
@@ -148,9 +148,9 @@ class _ListViewportElement extends VirtualViewportElement<ListViewport> {
double
_getContainerExtentFromRenderObject
()
{
double
_getContainerExtentFromRenderObject
()
{
switch
(
widget
.
scrollDirection
)
{
switch
(
widget
.
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
return
renderObject
.
size
.
height
;
return
renderObject
.
size
.
height
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
return
renderObject
.
size
.
width
;
return
renderObject
.
size
.
width
;
}
}
}
}
...
...
packages/flutter/lib/src/widgets/virtual_viewport.dart
View file @
b6f3b298
...
@@ -13,7 +13,7 @@ typedef void ExtentsChangedCallback(double contentExtent, double containerExtent
...
@@ -13,7 +13,7 @@ typedef void ExtentsChangedCallback(double contentExtent, double containerExtent
abstract
class
VirtualViewport
extends
RenderObjectWidget
{
abstract
class
VirtualViewport
extends
RenderObjectWidget
{
double
get
startOffset
;
double
get
startOffset
;
ScrollDirection
get
scrollDirection
;
Axis
get
scrollDirection
;
Iterable
<
Widget
>
get
children
;
Iterable
<
Widget
>
get
children
;
}
}
...
@@ -64,10 +64,10 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
...
@@ -64,10 +64,10 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
void
_updatePaintOffset
()
{
void
_updatePaintOffset
()
{
switch
(
widget
.
scrollDirection
)
{
switch
(
widget
.
scrollDirection
)
{
case
ScrollDirection
.
vertical
:
case
Axis
.
vertical
:
renderObject
.
paintOffset
=
new
Offset
(
0.0
,
paintOffset
);
renderObject
.
paintOffset
=
new
Offset
(
0.0
,
paintOffset
);
break
;
break
;
case
ScrollDirection
.
horizontal
:
case
Axis
.
horizontal
:
renderObject
.
paintOffset
=
new
Offset
(
paintOffset
,
0.0
);
renderObject
.
paintOffset
=
new
Offset
(
paintOffset
,
0.0
);
break
;
break
;
}
}
...
...
packages/flutter/test/widget/dismissable_test.dart
View file @
b6f3b298
...
@@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
...
@@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart';
import
'package:test/test.dart'
;
import
'package:test/test.dart'
;
const
double
itemExtent
=
100.0
;
const
double
itemExtent
=
100.0
;
ScrollDirection
scrollDirection
=
ScrollDirection
.
vertical
;
Axis
scrollDirection
=
Axis
.
vertical
;
DismissDirection
dismissDirection
=
DismissDirection
.
horizontal
;
DismissDirection
dismissDirection
=
DismissDirection
.
horizontal
;
List
<
int
>
dismissedItems
=
<
int
>[];
List
<
int
>
dismissedItems
=
<
int
>[];
...
@@ -120,7 +120,7 @@ class Test1215DismissableComponent extends StatelessComponent {
...
@@ -120,7 +120,7 @@ class Test1215DismissableComponent extends StatelessComponent {
void
main
(
)
{
void
main
(
)
{
test
(
'Horizontal drag triggers dismiss scrollDirection=vertical'
,
()
{
test
(
'Horizontal drag triggers dismiss scrollDirection=vertical'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
testWidgets
((
WidgetTester
tester
)
{
scrollDirection
=
ScrollDirection
.
vertical
;
scrollDirection
=
Axis
.
vertical
;
dismissDirection
=
DismissDirection
.
horizontal
;
dismissDirection
=
DismissDirection
.
horizontal
;
dismissedItems
=
<
int
>[];
dismissedItems
=
<
int
>[];
...
@@ -139,7 +139,7 @@ void main() {
...
@@ -139,7 +139,7 @@ void main() {
test
(
'Vertical drag triggers dismiss scrollDirection=horizontal'
,
()
{
test
(
'Vertical drag triggers dismiss scrollDirection=horizontal'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
testWidgets
((
WidgetTester
tester
)
{
scrollDirection
=
ScrollDirection
.
horizontal
;
scrollDirection
=
Axis
.
horizontal
;
dismissDirection
=
DismissDirection
.
vertical
;
dismissDirection
=
DismissDirection
.
vertical
;
dismissedItems
=
<
int
>[];
dismissedItems
=
<
int
>[];
...
@@ -158,7 +158,7 @@ void main() {
...
@@ -158,7 +158,7 @@ void main() {
test
(
'drag-left with DismissDirection.left triggers dismiss'
,
()
{
test
(
'drag-left with DismissDirection.left triggers dismiss'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
testWidgets
((
WidgetTester
tester
)
{
scrollDirection
=
ScrollDirection
.
vertical
;
scrollDirection
=
Axis
.
vertical
;
dismissDirection
=
DismissDirection
.
left
;
dismissDirection
=
DismissDirection
.
left
;
dismissedItems
=
<
int
>[];
dismissedItems
=
<
int
>[];
...
@@ -177,7 +177,7 @@ void main() {
...
@@ -177,7 +177,7 @@ void main() {
test
(
'drag-right with DismissDirection.right triggers dismiss'
,
()
{
test
(
'drag-right with DismissDirection.right triggers dismiss'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
testWidgets
((
WidgetTester
tester
)
{
scrollDirection
=
ScrollDirection
.
vertical
;
scrollDirection
=
Axis
.
vertical
;
dismissDirection
=
DismissDirection
.
right
;
dismissDirection
=
DismissDirection
.
right
;
dismissedItems
=
<
int
>[];
dismissedItems
=
<
int
>[];
...
@@ -196,7 +196,7 @@ void main() {
...
@@ -196,7 +196,7 @@ void main() {
test
(
'drag-up with DismissDirection.up triggers dismiss'
,
()
{
test
(
'drag-up with DismissDirection.up triggers dismiss'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
testWidgets
((
WidgetTester
tester
)
{
scrollDirection
=
ScrollDirection
.
horizontal
;
scrollDirection
=
Axis
.
horizontal
;
dismissDirection
=
DismissDirection
.
up
;
dismissDirection
=
DismissDirection
.
up
;
dismissedItems
=
<
int
>[];
dismissedItems
=
<
int
>[];
...
@@ -215,7 +215,7 @@ void main() {
...
@@ -215,7 +215,7 @@ void main() {
test
(
'drag-down with DismissDirection.down triggers dismiss'
,
()
{
test
(
'drag-down with DismissDirection.down triggers dismiss'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
testWidgets
((
WidgetTester
tester
)
{
scrollDirection
=
ScrollDirection
.
horizontal
;
scrollDirection
=
Axis
.
horizontal
;
dismissDirection
=
DismissDirection
.
down
;
dismissDirection
=
DismissDirection
.
down
;
dismissedItems
=
<
int
>[];
dismissedItems
=
<
int
>[];
...
@@ -240,7 +240,7 @@ void main() {
...
@@ -240,7 +240,7 @@ void main() {
// irrelevant by fn3, but just in case...
// irrelevant by fn3, but just in case...
test
(
'Verify that drag-move events do not assert'
,
()
{
test
(
'Verify that drag-move events do not assert'
,
()
{
testWidgets
((
WidgetTester
tester
)
{
testWidgets
((
WidgetTester
tester
)
{
scrollDirection
=
ScrollDirection
.
horizontal
;
scrollDirection
=
Axis
.
horizontal
;
dismissDirection
=
DismissDirection
.
down
;
dismissDirection
=
DismissDirection
.
down
;
dismissedItems
=
<
int
>[];
dismissedItems
=
<
int
>[];
...
...
packages/flutter/test/widget/homogeneous_viewport_test.dart
View file @
b6f3b298
...
@@ -143,7 +143,7 @@ void main() {
...
@@ -143,7 +143,7 @@ void main() {
builder:
itemBuilder
,
builder:
itemBuilder
,
startOffset:
offset
,
startOffset:
offset
,
itemExtent:
200.0
,
itemExtent:
200.0
,
direction:
ScrollDirection
.
horizontal
direction:
Axis
.
horizontal
),
),
right:
new
Text
(
'Not Today'
)
right:
new
Text
(
'Not Today'
)
);
);
...
...
packages/flutter/test/widget/mixed_viewport_test.dart
View file @
b6f3b298
...
@@ -127,7 +127,7 @@ void main() {
...
@@ -127,7 +127,7 @@ void main() {
left:
new
MixedViewport
(
left:
new
MixedViewport
(
builder:
itemBuilder
,
builder:
itemBuilder
,
startOffset:
offset
,
startOffset:
offset
,
direction:
ScrollDirection
.
horizontal
direction:
Axis
.
horizontal
),
),
right:
new
Text
(
'Not Today'
)
right:
new
Text
(
'Not Today'
)
);
);
...
...
packages/flutter/test/widget/pageable_list_test.dart
View file @
b6f3b298
...
@@ -26,7 +26,7 @@ Widget buildFrame({ List<int> pages: defaultPages }) {
...
@@ -26,7 +26,7 @@ Widget buildFrame({ List<int> pages: defaultPages }) {
final
list
=
new
PageableList
(
final
list
=
new
PageableList
(
children:
pages
.
map
(
buildPage
),
children:
pages
.
map
(
buildPage
),
itemsWrap:
itemsWrap
,
itemsWrap:
itemsWrap
,
scrollDirection:
ScrollDirection
.
horizontal
,
scrollDirection:
Axis
.
horizontal
,
onPageChanged:
(
int
page
)
{
currentPage
=
page
;
}
onPageChanged:
(
int
page
)
{
currentPage
=
page
;
}
);
);
...
...
packages/flutter/test/widget/scrollable_list_hit_testing_test.dart
View file @
b6f3b298
...
@@ -20,7 +20,7 @@ void main() {
...
@@ -20,7 +20,7 @@ void main() {
child:
new
ScrollableList
(
child:
new
ScrollableList
(
key:
new
GlobalKey
(),
key:
new
GlobalKey
(),
itemExtent:
290.0
,
itemExtent:
290.0
,
scrollDirection:
ScrollDirection
.
horizontal
,
scrollDirection:
Axis
.
horizontal
,
children:
items
.
map
((
int
item
)
{
children:
items
.
map
((
int
item
)
{
return
new
Container
(
return
new
Container
(
child:
new
GestureDetector
(
child:
new
GestureDetector
(
...
@@ -60,7 +60,7 @@ void main() {
...
@@ -60,7 +60,7 @@ void main() {
child:
new
ScrollableList
(
child:
new
ScrollableList
(
key:
new
GlobalKey
(),
key:
new
GlobalKey
(),
itemExtent:
290.0
,
itemExtent:
290.0
,
scrollDirection:
ScrollDirection
.
vertical
,
scrollDirection:
Axis
.
vertical
,
children:
items
.
map
((
int
item
)
{
children:
items
.
map
((
int
item
)
{
return
new
Container
(
return
new
Container
(
child:
new
GestureDetector
(
child:
new
GestureDetector
(
...
...
packages/flutter/test/widget/scrollable_list_horizontal_test.dart
View file @
b6f3b298
...
@@ -15,7 +15,7 @@ Widget buildFrame() {
...
@@ -15,7 +15,7 @@ Widget buildFrame() {
height:
50.0
,
height:
50.0
,
child:
new
ScrollableList
(
child:
new
ScrollableList
(
itemExtent:
290.0
,
itemExtent:
290.0
,
scrollDirection:
ScrollDirection
.
horizontal
,
scrollDirection:
Axis
.
horizontal
,
children:
items
.
map
((
int
item
)
{
children:
items
.
map
((
int
item
)
{
return
new
Container
(
return
new
Container
(
child:
new
Text
(
'
$item
'
)
child:
new
Text
(
'
$item
'
)
...
...
packages/flutter/test/widget/scrollable_list_vertical_test.dart
View file @
b6f3b298
...
@@ -11,7 +11,7 @@ const List<int> items = const <int>[0, 1, 2, 3, 4, 5];
...
@@ -11,7 +11,7 @@ const List<int> items = const <int>[0, 1, 2, 3, 4, 5];
Widget
buildFrame
(
)
{
Widget
buildFrame
(
)
{
return
new
ScrollableList
(
return
new
ScrollableList
(
itemExtent:
290.0
,
itemExtent:
290.0
,
scrollDirection:
ScrollDirection
.
vertical
,
scrollDirection:
Axis
.
vertical
,
children:
items
.
map
((
int
item
)
{
children:
items
.
map
((
int
item
)
{
return
new
Container
(
return
new
Container
(
child:
new
Text
(
'
$item
'
)
child:
new
Text
(
'
$item
'
)
...
...
packages/flutter/test/widget/snap_scrolling_test.dart
View file @
b6f3b298
...
@@ -9,7 +9,7 @@ import 'package:flutter/widgets.dart';
...
@@ -9,7 +9,7 @@ import 'package:flutter/widgets.dart';
import
'package:test/test.dart'
;
import
'package:test/test.dart'
;
const
double
itemExtent
=
200.0
;
const
double
itemExtent
=
200.0
;
ScrollDirection
scrollDirection
=
ScrollDirection
.
vertical
;
Axis
scrollDirection
=
Axis
.
vertical
;
GlobalKey
scrollableListKey
;
GlobalKey
scrollableListKey
;
Widget
buildItem
(
int
item
)
{
Widget
buildItem
(
int
item
)
{
...
@@ -48,7 +48,7 @@ void set scrollOffset(double value) {
...
@@ -48,7 +48,7 @@ void set scrollOffset(double value) {
}
}
Future
fling
(
double
velocity
)
{
Future
fling
(
double
velocity
)
{
Offset
velocityOffset
=
scrollDirection
==
ScrollDirection
.
vertical
Offset
velocityOffset
=
scrollDirection
==
Axis
.
vertical
?
new
Offset
(
0.0
,
velocity
)
?
new
Offset
(
0.0
,
velocity
)
:
new
Offset
(
velocity
,
0.0
);
:
new
Offset
(
velocity
,
0.0
);
return
scrollableState
.
fling
(
velocityOffset
);
return
scrollableState
.
fling
(
velocityOffset
);
...
...
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