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
ed8c1cb6
Commit
ed8c1cb6
authored
Sep 02, 2015
by
Hans Muller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable dynamic changes to itemsWrap in PageableList
parent
fc6f91c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
7 deletions
+36
-7
pageable_list.dart
examples/widgets/pageable_list.dart
+16
-3
homogeneous_viewport.dart
packages/flutter/lib/src/widgets/homogeneous_viewport.dart
+4
-0
scrollable.dart
packages/flutter/lib/src/widgets/scrollable.dart
+6
-1
pageable_list_test.dart
packages/unit/test/widget/pageable_list_test.dart
+10
-3
No files found.
examples/widgets/pageable_list.dart
View file @
ed8c1cb6
...
...
@@ -23,6 +23,7 @@ class PageableListApp extends App {
List
<
CardModel
>
cardModels
;
Size
pageSize
=
new
Size
(
200.0
,
200.0
);
ScrollDirection
scrollDirection
=
ScrollDirection
.
horizontal
;
bool
itemsWrap
=
false
;
void
initState
()
{
List
<
Size
>
cardSizes
=
[
...
...
@@ -67,13 +68,18 @@ class PageableListApp extends App {
);
}
EventDisposition
switchScrollDirection
()
{
void
switchScrollDirection
()
{
setState
(()
{
scrollDirection
=
(
scrollDirection
==
ScrollDirection
.
vertical
)
?
ScrollDirection
.
horizontal
:
ScrollDirection
.
vertical
;
});
return
EventDisposition
.
processed
;
}
void
toggleItemsWrap
()
{
setState
(()
{
itemsWrap
=
!
itemsWrap
;
});
}
bool
_drawerShowing
=
false
;
...
...
@@ -113,6 +119,13 @@ class PageableListApp extends App {
selected:
scrollDirection
==
ScrollDirection
.
vertical
,
child:
new
Text
(
'Vertical Layout'
),
onPressed:
switchScrollDirection
),
new
DrawerItem
(
onPressed:
toggleItemsWrap
,
child:
new
Row
([
new
Flexible
(
child:
new
Text
(
'Scrolling wraps around'
)),
new
Checkbox
(
value:
itemsWrap
)
])
)
]
);
...
...
@@ -132,7 +145,7 @@ class PageableListApp extends App {
Widget
buildBody
()
{
Widget
list
=
new
PageableList
<
CardModel
>(
items:
cardModels
,
itemsWrap:
true
,
itemsWrap:
itemsWrap
,
itemBuilder:
buildCard
,
scrollDirection:
scrollDirection
,
itemExtent:
(
scrollDirection
==
ScrollDirection
.
vertical
)
...
...
packages/flutter/lib/src/widgets/homogeneous_viewport.dart
View file @
ed8c1cb6
...
...
@@ -83,6 +83,10 @@ class HomogeneousViewport extends RenderObjectWrapper {
_layoutDirty
=
true
;
itemCount
=
newNode
.
itemCount
;
}
if
(
itemsWrap
!=
newNode
.
itemsWrap
)
{
_layoutDirty
=
true
;
itemsWrap
=
newNode
.
itemsWrap
;
}
if
(
itemExtent
!=
newNode
.
itemExtent
)
{
_layoutDirty
=
true
;
itemExtent
=
newNode
.
itemExtent
;
...
...
packages/flutter/lib/src/widgets/scrollable.dart
View file @
ed8c1cb6
...
...
@@ -371,7 +371,13 @@ abstract class ScrollableWidgetList extends Scrollable {
itemExtent
!=
source
.
itemExtent
||
scrollDirection
!=
source
.
scrollDirection
;
if
(
itemsWrap
!=
source
.
itemsWrap
)
{
_scrollBehavior
=
null
;
scrollBehaviorUpdateNeeded
=
true
;
}
padding
=
source
.
padding
;
itemsWrap
=
source
.
itemsWrap
;
itemExtent
=
source
.
itemExtent
;
super
.
syncConstructorArguments
(
source
);
// update scrollDirection
...
...
@@ -492,7 +498,6 @@ class ScrollableList<T> extends ScrollableWidgetList {
void
syncConstructorArguments
(
ScrollableList
<
T
>
source
)
{
items
=
source
.
items
;
itemBuilder
=
source
.
itemBuilder
;
itemsWrap
=
source
.
itemsWrap
;
super
.
syncConstructorArguments
(
source
);
}
...
...
packages/unit/test/widget/pageable_list_test.dart
View file @
ed8c1cb6
...
...
@@ -7,6 +7,7 @@ import 'widget_tester.dart';
const
Size
pageSize
=
const
Size
(
800.0
,
600.0
);
const
List
<
int
>
pages
=
const
<
int
>[
0
,
1
,
2
,
3
,
4
,
5
];
int
currentPage
=
null
;
bool
itemsWrap
=
false
;
Widget
buildPage
(
int
page
)
{
return
new
Container
(
...
...
@@ -17,7 +18,7 @@ Widget buildPage(int page) {
);
}
Widget
buildFrame
(
{
bool
itemsWrap:
false
}
)
{
Widget
buildFrame
(
)
{
// The test framework forces the frame (and so the PageableList)
// to be 800x600. The pageSize constant reflects as much.
return
new
PageableList
<
int
>(
...
...
@@ -55,6 +56,7 @@ void main() {
test
(
'Scroll left from page 0 to page 1'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
currentPage
=
null
;
itemsWrap
=
false
;
tester
.
pumpFrame
(
buildFrame
);
expect
(
currentPage
,
isNull
);
pageLeft
(
tester
);
...
...
@@ -64,6 +66,7 @@ void main() {
test
(
'Underscroll (scroll right), return to page 0'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
currentPage
=
null
;
itemsWrap
=
false
;
tester
.
pumpFrame
(
buildFrame
);
expect
(
currentPage
,
isNull
);
pageRight
(
tester
);
...
...
@@ -72,10 +75,13 @@ void main() {
// PageableList with itemsWrap: true
itemsWrap
=
true
;
test
(
'Scroll left page 0 to page 1, itemsWrap: true'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
currentPage
=
null
;
tester
.
pumpFrame
(()
{
return
buildFrame
(
itemsWrap:
true
);
});
itemsWrap
=
true
;
tester
.
pumpFrame
(
buildFrame
);
expect
(
currentPage
,
isNull
);
pageLeft
(
tester
);
expect
(
currentPage
,
equals
(
1
));
...
...
@@ -84,7 +90,8 @@ void main() {
test
(
'Scroll right from page 0 to page 5, itemsWrap: true'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
currentPage
=
null
;
tester
.
pumpFrame
(()
{
return
buildFrame
(
itemsWrap:
true
);
});
itemsWrap
=
true
;
tester
.
pumpFrame
(
buildFrame
);
expect
(
currentPage
,
isNull
);
pageRight
(
tester
);
expect
(
currentPage
,
equals
(
5
));
...
...
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