album: fixed app bar to derive from SliverAppBar

This commit is contained in:
Thibault Deckers 2020-01-01 20:20:51 +09:00
parent 7aa711bd69
commit e3e222c589

View file

@ -20,21 +20,39 @@ class AllCollectionPage extends StatelessWidget {
} }
} }
class _AllCollectionAppBar extends StatelessWidget { class _AllCollectionAppBar extends SliverAppBar {
_AllCollectionAppBar()
: super(
title: const Text('All'),
actions: _buildActions(),
floating: true,
);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final collection = Provider.of<ImageCollection>(context);
return SliverAppBar( return SliverAppBar(
title: const Text('All'), title: const Text('All'),
actions: [ actions: _buildActions(),
IconButton( floating: true,
);
}
static List<Widget> _buildActions() {
return [
Builder(
builder: (context) => Consumer<ImageCollection>(
builder: (context, collection, child) => IconButton(
icon: Icon(OMIcons.search), icon: Icon(OMIcons.search),
onPressed: () => showSearch( onPressed: () => showSearch(
context: context, context: context,
delegate: ImageSearchDelegate(collection), delegate: ImageSearchDelegate(collection),
), ),
), ),
PopupMenuButton<AlbumAction>( ),
),
Builder(
builder: (context) => Consumer<ImageCollection>(
builder: (context, collection, child) => PopupMenuButton<AlbumAction>(
itemBuilder: (context) => [ itemBuilder: (context) => [
PopupMenuItem( PopupMenuItem(
value: AlbumAction.sortByDate, value: AlbumAction.sortByDate,
@ -67,12 +85,12 @@ class _AllCollectionAppBar extends StatelessWidget {
], ],
onSelected: (action) => _onActionSelected(context, collection, action), onSelected: (action) => _onActionSelected(context, collection, action),
), ),
], ),
floating: true, ),
); ];
} }
void _onActionSelected(BuildContext context, ImageCollection collection, AlbumAction action) { static void _onActionSelected(BuildContext context, ImageCollection collection, AlbumAction action) {
switch (action) { switch (action) {
case AlbumAction.debug: case AlbumAction.debug:
_goToDebug(context, collection); _goToDebug(context, collection);
@ -100,7 +118,7 @@ class _AllCollectionAppBar extends StatelessWidget {
} }
} }
Future _goToDebug(BuildContext context, ImageCollection collection) { static Future _goToDebug(BuildContext context, ImageCollection collection) {
return Navigator.push( return Navigator.push(
context, context,
MaterialPageRoute( MaterialPageRoute(