Use ScrollView in more places (#7746)
Now that ScrollView supports itemExtent, we can use it in a few more places.
This commit is contained in:
@@ -21,8 +21,8 @@ final List<TravelDestination> destinations = <TravelDestination>[
|
||||
description: const <String>[
|
||||
'Number 10',
|
||||
'Whitehaven Beach',
|
||||
'Whitsunday Island, Whitsunday Islands'
|
||||
]
|
||||
'Whitsunday Island, Whitsunday Islands',
|
||||
],
|
||||
),
|
||||
const TravelDestination(
|
||||
assetName: 'packages/flutter_gallery_assets/kangaroo_valley_safari.jpg',
|
||||
@@ -30,8 +30,8 @@ final List<TravelDestination> destinations = <TravelDestination>[
|
||||
description: const <String>[
|
||||
'2031 Moss Vale Road',
|
||||
'Kangaroo Valley 2577',
|
||||
'New South Wales'
|
||||
]
|
||||
'New South Wales',
|
||||
],
|
||||
)
|
||||
];
|
||||
|
||||
@@ -63,8 +63,8 @@ class TravelDestinationItem extends StatelessWidget {
|
||||
new Positioned.fill(
|
||||
child: new Image.asset(
|
||||
destination.assetName,
|
||||
fit: ImageFit.cover
|
||||
)
|
||||
fit: ImageFit.cover,
|
||||
),
|
||||
),
|
||||
new Positioned(
|
||||
bottom: 16.0,
|
||||
@@ -78,8 +78,8 @@ class TravelDestinationItem extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
// description and share/expore buttons
|
||||
new Expanded(
|
||||
@@ -96,10 +96,10 @@ class TravelDestinationItem extends StatelessWidget {
|
||||
new Text(destination.description[0]),
|
||||
new Text(destination.description[1]),
|
||||
new Text(destination.description[2]),
|
||||
]
|
||||
)
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// share, explore buttons
|
||||
// TODO(abarth): The theme and the bar should be part of card.
|
||||
@@ -109,18 +109,18 @@ class TravelDestinationItem extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text('SHARE'),
|
||||
onPressed: () { /* do nothing */ }
|
||||
onPressed: () { /* do nothing */ },
|
||||
),
|
||||
new FlatButton(
|
||||
child: new Text('EXPLORE'),
|
||||
onPressed: () { /* do nothing */ }
|
||||
onPressed: () { /* do nothing */ },
|
||||
),
|
||||
]
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ class CardsDemo extends StatelessWidget {
|
||||
appBar: new AppBar(
|
||||
title: new Text('Travel stream')
|
||||
),
|
||||
body: new ScrollableList(
|
||||
body: new ScrollView(
|
||||
itemExtent: TravelDestinationItem.height,
|
||||
padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0),
|
||||
children: destinations.map((TravelDestination destination) {
|
||||
@@ -142,8 +142,7 @@ class CardsDemo extends StatelessWidget {
|
||||
margin: const EdgeInsets.only(bottom: 8.0),
|
||||
child: new TravelDestinationItem(destination: destination)
|
||||
);
|
||||
})
|
||||
.toList()
|
||||
}).toList()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ final List<ColorSwatch> colorSwatches = <ColorSwatch>[
|
||||
new ColorSwatch(name: 'DEEP ORANGE', colors: Colors.deepOrange, accentColors: Colors.deepOrangeAccent, threshold: 400),
|
||||
new ColorSwatch(name: 'BROWN', colors: Colors.brown, threshold: 200),
|
||||
new ColorSwatch(name: 'GREY', colors: Colors.grey, threshold: 500),
|
||||
new ColorSwatch(name: 'BLUE GREY', colors: Colors.blueGrey, threshold: 500)
|
||||
new ColorSwatch(name: 'BLUE GREY', colors: Colors.blueGrey, threshold: 500),
|
||||
];
|
||||
|
||||
|
||||
@@ -64,9 +64,9 @@ class ColorItem extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
new Text('$prefix$index'),
|
||||
new Text(colorString())
|
||||
]
|
||||
)
|
||||
new Text(colorString()),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -85,24 +85,22 @@ class ColorSwatchTabView extends StatelessWidget {
|
||||
List<Widget> colorItems = swatch.colors.keys.map((int index) {
|
||||
return new DefaultTextStyle(
|
||||
style: index > swatch.threshold ? whiteTextStyle : blackTextStyle,
|
||||
child: new ColorItem(index: index, color: swatch.colors[index])
|
||||
child: new ColorItem(index: index, color: swatch.colors[index]),
|
||||
);
|
||||
})
|
||||
.toList();
|
||||
}).toList();
|
||||
|
||||
if (swatch.accentColors != null) {
|
||||
colorItems.addAll(swatch.accentColors.keys.map((int index) {
|
||||
return new DefaultTextStyle(
|
||||
style: index > swatch.threshold ? whiteTextStyle : blackTextStyle,
|
||||
child: new ColorItem(index: index, color: swatch.accentColors[index], prefix: 'A')
|
||||
child: new ColorItem(index: index, color: swatch.accentColors[index], prefix: 'A'),
|
||||
);
|
||||
})
|
||||
.toList());
|
||||
}).toList());
|
||||
}
|
||||
|
||||
return new ScrollableList(
|
||||
return new ScrollView(
|
||||
itemExtent: kColorItemHeight,
|
||||
children: colorItems
|
||||
children: colorItems,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -121,7 +119,7 @@ class ColorsDemo extends StatelessWidget {
|
||||
bottom: new TabBar(
|
||||
isScrollable: true,
|
||||
tabs: colorSwatches.map((ColorSwatch swatch) => new Tab(text: swatch.name)).toList(),
|
||||
)
|
||||
),
|
||||
),
|
||||
body: new TabBarView(
|
||||
children: colorSwatches.map((ColorSwatch swatch) {
|
||||
|
||||
@@ -23,55 +23,55 @@ final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{
|
||||
new _Page(label: 'LEFT'): <_CardData>[
|
||||
const _CardData(
|
||||
title: 'Vintage Bluetooth Radio',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/radio.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/radio.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Sunglasses',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Clock',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/clock.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/clock.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Red popsicle',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/popsicle.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/popsicle.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Folding Chair',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Green comfort chair',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chair.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chair.png',
|
||||
),
|
||||
],
|
||||
new _Page(label: 'RIGHT'): <_CardData>[
|
||||
const _CardData(
|
||||
title: 'Beachball',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/beachball.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/beachball.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Old Binoculars',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/binoculars.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/binoculars.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Teapot',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/teapot.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/teapot.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Blue suede shoes',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chucks.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chucks.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Dipped Brush',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/brush.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/brush.png',
|
||||
),
|
||||
const _CardData(
|
||||
title: 'Perfect Goldfish Bowl',
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/fish_bowl.png'
|
||||
imageAsset: 'packages/flutter_gallery_assets/shrine/products/fish_bowl.png',
|
||||
),
|
||||
]
|
||||
],
|
||||
};
|
||||
|
||||
class _CardDataItem extends StatelessWidget {
|
||||
@@ -94,19 +94,19 @@ class _CardDataItem extends StatelessWidget {
|
||||
alignment: page.id == 'L'
|
||||
? FractionalOffset.centerLeft
|
||||
: FractionalOffset.centerRight,
|
||||
child: new CircleAvatar(child: new Text('${page.id}'))
|
||||
child: new CircleAvatar(child: new Text('${page.id}')),
|
||||
),
|
||||
new SizedBox(
|
||||
width: 144.0,
|
||||
height: 144.0,
|
||||
child: new Image.asset(data.imageAsset, fit: ImageFit.contain)
|
||||
child: new Image.asset(data.imageAsset, fit: ImageFit.contain),
|
||||
),
|
||||
new Center(
|
||||
child: new Text(data.title, style: Theme.of(context).textTheme.title)
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
child: new Text(data.title, style: Theme.of(context).textTheme.title),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -127,13 +127,13 @@ class TabsDemo extends StatelessWidget {
|
||||
),
|
||||
body: new TabBarView(
|
||||
children: _allPages.keys.map((_Page page) {
|
||||
return new ScrollableList(
|
||||
return new ScrollView(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 16.0),
|
||||
itemExtent: _CardDataItem.height,
|
||||
children: _allPages[page].map((_CardData data) {
|
||||
return new Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: new _CardDataItem(page: page, data: data)
|
||||
child: new _CardDataItem(page: page, data: data),
|
||||
);
|
||||
}).toList(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user