rename collection to album in example app

This commit is contained in:
Wenqi Li 2020-09-20 16:04:55 +08:00
parent 4548239b7b
commit c70dd411dc

View File

@ -18,7 +18,7 @@ class MyApp extends StatefulWidget {
} }
class _MyAppState extends State<MyApp> { class _MyAppState extends State<MyApp> {
List _collections; List _albums;
bool _loading = false; bool _loading = false;
@override @override
@ -30,10 +30,10 @@ class _MyAppState extends State<MyApp> {
Future<void> initAsync() async { Future<void> initAsync() async {
if (await _promptPermissionSetting()) { if (await _promptPermissionSetting()) {
List<Album> collections = List<Album> albums =
await PhotoGallery.listAlbums(mediumType: MediumType.image); await PhotoGallery.listAlbums(mediumType: MediumType.image);
setState(() { setState(() {
_collections = collections; _albums = albums;
_loading = false; _loading = false;
}); });
} }
@ -76,12 +76,11 @@ class _MyAppState extends State<MyApp> {
mainAxisSpacing: 5.0, mainAxisSpacing: 5.0,
crossAxisSpacing: 5.0, crossAxisSpacing: 5.0,
children: <Widget>[ children: <Widget>[
...?_collections?.map( ...?_albums?.map(
(collection) => GestureDetector( (album) => GestureDetector(
onTap: () => Navigator.of(context).push( onTap: () => Navigator.of(context).push(
MaterialPageRoute( MaterialPageRoute(
builder: (context) => builder: (context) => AlbumPage(album))),
CollectionPage(collection))),
child: Column( child: Column(
children: <Widget>[ children: <Widget>[
ClipRRect( ClipRRect(
@ -95,7 +94,7 @@ class _MyAppState extends State<MyApp> {
placeholder: placeholder:
MemoryImage(kTransparentImage), MemoryImage(kTransparentImage),
image: AlbumThumbnailProvider( image: AlbumThumbnailProvider(
albumId: collection.id, albumId: album.id,
highQuality: true, highQuality: true,
), ),
), ),
@ -105,7 +104,7 @@ class _MyAppState extends State<MyApp> {
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: 2.0), padding: EdgeInsets.only(left: 2.0),
child: Text( child: Text(
collection.name, album.name,
maxLines: 1, maxLines: 1,
textAlign: TextAlign.start, textAlign: TextAlign.start,
style: TextStyle( style: TextStyle(
@ -118,7 +117,7 @@ class _MyAppState extends State<MyApp> {
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
padding: EdgeInsets.only(left: 2.0), padding: EdgeInsets.only(left: 2.0),
child: Text( child: Text(
collection.count.toString(), album.count.toString(),
textAlign: TextAlign.start, textAlign: TextAlign.start,
style: TextStyle( style: TextStyle(
height: 1.2, height: 1.2,
@ -140,16 +139,16 @@ class _MyAppState extends State<MyApp> {
} }
} }
class CollectionPage extends StatefulWidget { class AlbumPage extends StatefulWidget {
final Album collection; final Album album;
CollectionPage(Album collection) : collection = collection; AlbumPage(Album album) : album = album;
@override @override
State<StatefulWidget> createState() => CollectionPageState(); State<StatefulWidget> createState() => AlbumPageState();
} }
class CollectionPageState extends State<CollectionPage> { class AlbumPageState extends State<AlbumPage> {
List<Medium> _media; List<Medium> _media;
@override @override
@ -159,7 +158,7 @@ class CollectionPageState extends State<CollectionPage> {
} }
void initAsync() async { void initAsync() async {
MediaPage mediaPage = await widget.collection.listMedia(); MediaPage mediaPage = await widget.album.listMedia();
setState(() { setState(() {
_media = mediaPage.items; _media = mediaPage.items;
}); });
@ -174,7 +173,7 @@ class CollectionPageState extends State<CollectionPage> {
icon: Icon(Icons.arrow_back_ios), icon: Icon(Icons.arrow_back_ios),
onPressed: () => Navigator.of(context).pop(), onPressed: () => Navigator.of(context).pop(),
), ),
title: Text(widget.collection.name), title: Text(widget.album.name),
), ),
body: GridView.count( body: GridView.count(
crossAxisCount: 3, crossAxisCount: 3,