album: fixed app bar to derive from SliverAppBar
This commit is contained in:
parent
7aa711bd69
commit
e3e222c589
1 changed files with 64 additions and 46 deletions
|
@ -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
|
||||
Widget build(BuildContext context) {
|
||||
final collection = Provider.of<ImageCollection>(context);
|
||||
return SliverAppBar(
|
||||
title: const Text('All'),
|
||||
actions: [
|
||||
IconButton(
|
||||
actions: _buildActions(),
|
||||
floating: true,
|
||||
);
|
||||
}
|
||||
|
||||
static List<Widget> _buildActions() {
|
||||
return [
|
||||
Builder(
|
||||
builder: (context) => Consumer<ImageCollection>(
|
||||
builder: (context, collection, child) => IconButton(
|
||||
icon: Icon(OMIcons.search),
|
||||
onPressed: () => showSearch(
|
||||
context: context,
|
||||
delegate: ImageSearchDelegate(collection),
|
||||
),
|
||||
),
|
||||
PopupMenuButton<AlbumAction>(
|
||||
),
|
||||
),
|
||||
Builder(
|
||||
builder: (context) => Consumer<ImageCollection>(
|
||||
builder: (context, collection, child) => PopupMenuButton<AlbumAction>(
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
value: AlbumAction.sortByDate,
|
||||
|
@ -67,12 +85,12 @@ class _AllCollectionAppBar extends StatelessWidget {
|
|||
],
|
||||
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) {
|
||||
case AlbumAction.debug:
|
||||
_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(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
|
|
Loading…
Reference in a new issue