Rename manual_tests/pageable_list.dart to page_view.dart (#7986)
This manual test has used the PageView widget for a while already.
This commit is contained in:
parent
761cf15c2b
commit
b4ec00c2d4
@ -9,28 +9,26 @@ class CardModel {
|
|||||||
int value;
|
int value;
|
||||||
Size size;
|
Size size;
|
||||||
Color color;
|
Color color;
|
||||||
String get label => "Card $value";
|
String get label => 'Card $value';
|
||||||
Key get key => new ObjectKey(this);
|
Key get key => new ObjectKey(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
class PageableListApp extends StatefulWidget {
|
class PageViewApp extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
PageableListAppState createState() => new PageableListAppState();
|
PageViewAppState createState() => new PageViewAppState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class PageableListAppState extends State<PageableListApp> {
|
class PageViewAppState extends State<PageViewApp> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
List<Size> cardSizes = <List<double>>[
|
const List<Size> cardSizes = const <Size>[
|
||||||
<double>[100.0, 300.0],
|
const Size(100.0, 300.0),
|
||||||
<double>[300.0, 100.0],
|
const Size(300.0, 100.0),
|
||||||
<double>[200.0, 400.0],
|
const Size(200.0, 400.0),
|
||||||
<double>[400.0, 400.0],
|
const Size(400.0, 400.0),
|
||||||
<double>[300.0, 400.0]
|
const Size(300.0, 400.0),
|
||||||
]
|
];
|
||||||
.map((List<double> args) => new Size(args[0], args[1]))
|
|
||||||
.toList();
|
|
||||||
|
|
||||||
cardModels = new List<CardModel>.generate(cardSizes.length, (int i) {
|
cardModels = new List<CardModel>.generate(cardSizes.length, (int i) {
|
||||||
Color color = Color.lerp(Colors.red[300], Colors.blue[900], i / cardSizes.length);
|
Color color = Color.lerp(Colors.red[300], Colors.blue[900], i / cardSizes.length);
|
||||||
@ -53,8 +51,8 @@ class PageableListAppState extends State<PageableListApp> {
|
|||||||
width: cardModel.size.width,
|
width: cardModel.size.width,
|
||||||
height: cardModel.size.height,
|
height: cardModel.size.height,
|
||||||
padding: const EdgeInsets.all(8.0),
|
padding: const EdgeInsets.all(8.0),
|
||||||
child: new Center(child: new Text(cardModel.label, style: cardLabelStyle))
|
child: new Center(child: new Text(cardModel.label, style: cardLabelStyle)),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
BoxConstraints constraints = (scrollDirection == Axis.vertical)
|
BoxConstraints constraints = (scrollDirection == Axis.vertical)
|
||||||
@ -64,7 +62,7 @@ class PageableListAppState extends State<PageableListApp> {
|
|||||||
return new Container(
|
return new Container(
|
||||||
key: cardModel.key,
|
key: cardModel.key,
|
||||||
constraints: constraints,
|
constraints: constraints,
|
||||||
child: new Center(child: card)
|
child: new Center(child: card),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,13 +89,13 @@ class PageableListAppState extends State<PageableListApp> {
|
|||||||
icon: new Icon(Icons.more_horiz),
|
icon: new Icon(Icons.more_horiz),
|
||||||
selected: scrollDirection == Axis.horizontal,
|
selected: scrollDirection == Axis.horizontal,
|
||||||
child: new Text('Horizontal Layout'),
|
child: new Text('Horizontal Layout'),
|
||||||
onPressed: switchScrollDirection
|
onPressed: switchScrollDirection,
|
||||||
),
|
),
|
||||||
new DrawerItem(
|
new DrawerItem(
|
||||||
icon: new Icon(Icons.more_vert),
|
icon: new Icon(Icons.more_vert),
|
||||||
selected: scrollDirection == Axis.vertical,
|
selected: scrollDirection == Axis.vertical,
|
||||||
child: new Text('Vertical Layout'),
|
child: new Text('Vertical Layout'),
|
||||||
onPressed: switchScrollDirection
|
onPressed: switchScrollDirection,
|
||||||
),
|
),
|
||||||
new DrawerItem(
|
new DrawerItem(
|
||||||
onPressed: toggleItemsWrap,
|
onPressed: toggleItemsWrap,
|
||||||
@ -105,21 +103,21 @@ class PageableListAppState extends State<PageableListApp> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
new Expanded(child: new Text('Scrolling wraps around')),
|
new Expanded(child: new Text('Scrolling wraps around')),
|
||||||
// TODO(abarth): Actually make this checkbox change this value.
|
// TODO(abarth): Actually make this checkbox change this value.
|
||||||
new Checkbox(value: itemsWrap, onChanged: null)
|
new Checkbox(value: itemsWrap, onChanged: null),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
]
|
],
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildAppBar() {
|
Widget _buildAppBar() {
|
||||||
return new AppBar(
|
return new AppBar(
|
||||||
title: new Text('PageableList'),
|
title: new Text('PageView'),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
new Text(scrollDirection == Axis.horizontal ? "horizontal" : "vertical")
|
new Text(scrollDirection == Axis.horizontal ? "horizontal" : "vertical"),
|
||||||
]
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +125,7 @@ class PageableListAppState extends State<PageableListApp> {
|
|||||||
return new PageView(
|
return new PageView(
|
||||||
children: cardModels.map(buildCard).toList(),
|
children: cardModels.map(buildCard).toList(),
|
||||||
// TODO(abarth): itemsWrap: itemsWrap,
|
// TODO(abarth): itemsWrap: itemsWrap,
|
||||||
scrollDirection: scrollDirection
|
scrollDirection: scrollDirection,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,20 +136,20 @@ class PageableListAppState extends State<PageableListApp> {
|
|||||||
child: new Scaffold(
|
child: new Scaffold(
|
||||||
appBar: _buildAppBar(),
|
appBar: _buildAppBar(),
|
||||||
drawer: _buildDrawer(),
|
drawer: _buildDrawer(),
|
||||||
body: _buildBody(context)
|
body: _buildBody(context),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(new MaterialApp(
|
runApp(new MaterialApp(
|
||||||
title: 'PageableList',
|
title: 'PageView',
|
||||||
theme: new ThemeData(
|
theme: new ThemeData(
|
||||||
brightness: Brightness.light,
|
brightness: Brightness.light,
|
||||||
primarySwatch: Colors.blue,
|
primarySwatch: Colors.blue,
|
||||||
accentColor: Colors.redAccent[200],
|
accentColor: Colors.redAccent[200],
|
||||||
),
|
),
|
||||||
home: new PageableListApp()
|
home: new PageViewApp(),
|
||||||
));
|
));
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user