app bar: allow tap anywhere in title space to start searching
This commit is contained in:
parent
2bbe652b06
commit
cd9fa1b6c4
1 changed files with 22 additions and 8 deletions
|
@ -84,6 +84,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
return AnimatedBuilder(
|
return AnimatedBuilder(
|
||||||
animation: collection.filterChangeNotifier,
|
animation: collection.filterChangeNotifier,
|
||||||
builder: (context, child) => SliverAppBar(
|
builder: (context, child) => SliverAppBar(
|
||||||
|
titleSpacing: 0,
|
||||||
leading: _buildAppBarLeading(),
|
leading: _buildAppBarLeading(),
|
||||||
title: _buildAppBarTitle(),
|
title: _buildAppBarTitle(),
|
||||||
actions: _buildActions(),
|
actions: _buildActions(),
|
||||||
|
@ -121,7 +122,18 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
Widget _buildAppBarTitle() {
|
Widget _buildAppBarTitle() {
|
||||||
switch (stateNotifier.value) {
|
switch (stateNotifier.value) {
|
||||||
case PageState.browse:
|
case PageState.browse:
|
||||||
return const Text('Aves');
|
return GestureDetector(
|
||||||
|
onTap: _goToSearch,
|
||||||
|
// use a `Container` with a dummy color to make it expand
|
||||||
|
// so that we can also detect taps around the title `Text`
|
||||||
|
child: Container(
|
||||||
|
alignment: AlignmentDirectional.centerStart,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: NavigationToolbar.kMiddleSpacing),
|
||||||
|
color: Colors.transparent,
|
||||||
|
height: kToolbarHeight,
|
||||||
|
child: const Text('Aves'),
|
||||||
|
),
|
||||||
|
);
|
||||||
case PageState.search:
|
case PageState.search:
|
||||||
return SearchField(
|
return SearchField(
|
||||||
stateNotifier: stateNotifier,
|
stateNotifier: stateNotifier,
|
||||||
|
@ -139,13 +151,7 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
case PageState.browse:
|
case PageState.browse:
|
||||||
return IconButton(
|
return IconButton(
|
||||||
icon: Icon(OMIcons.search),
|
icon: Icon(OMIcons.search),
|
||||||
onPressed: () async {
|
onPressed: _goToSearch,
|
||||||
final filter = await showSearch(
|
|
||||||
context: context,
|
|
||||||
delegate: ImageSearchDelegate(collection),
|
|
||||||
);
|
|
||||||
collection.addFilter(filter);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
case PageState.search:
|
case PageState.search:
|
||||||
return IconButton(
|
return IconButton(
|
||||||
|
@ -232,6 +238,14 @@ class _CollectionAppBarState extends State<CollectionAppBar> with SingleTickerPr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _goToSearch() async {
|
||||||
|
final filter = await showSearch(
|
||||||
|
context: context,
|
||||||
|
delegate: ImageSearchDelegate(collection),
|
||||||
|
);
|
||||||
|
collection.addFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _goToStats() {
|
Future<void> _goToStats() {
|
||||||
return Navigator.push(
|
return Navigator.push(
|
||||||
context,
|
context,
|
||||||
|
|
Loading…
Reference in a new issue