search: fixed leading icon animation
This commit is contained in:
parent
6a3e830d14
commit
9a0334814e
2 changed files with 7 additions and 1 deletions
|
@ -161,6 +161,7 @@ class _HomePageState extends State<HomePage> {
|
||||||
return SearchPageRoute(
|
return SearchPageRoute(
|
||||||
delegate: CollectionSearchDelegate(
|
delegate: CollectionSearchDelegate(
|
||||||
source: source,
|
source: source,
|
||||||
|
canPop: false,
|
||||||
initialQuery: _shortcutSearchQuery,
|
initialQuery: _shortcutSearchQuery,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -28,6 +28,7 @@ class CollectionSearchDelegate {
|
||||||
final CollectionSource source;
|
final CollectionSource source;
|
||||||
final CollectionLens? parentCollection;
|
final CollectionLens? parentCollection;
|
||||||
final ValueNotifier<String?> expandedSectionNotifier = ValueNotifier(null);
|
final ValueNotifier<String?> expandedSectionNotifier = ValueNotifier(null);
|
||||||
|
final bool canPop;
|
||||||
|
|
||||||
static const searchHistoryCount = 10;
|
static const searchHistoryCount = 10;
|
||||||
static final typeFilters = [
|
static final typeFilters = [
|
||||||
|
@ -45,13 +46,17 @@ class CollectionSearchDelegate {
|
||||||
CollectionSearchDelegate({
|
CollectionSearchDelegate({
|
||||||
required this.source,
|
required this.source,
|
||||||
this.parentCollection,
|
this.parentCollection,
|
||||||
|
this.canPop = true,
|
||||||
String? initialQuery,
|
String? initialQuery,
|
||||||
}) {
|
}) {
|
||||||
query = initialQuery ?? '';
|
query = initialQuery ?? '';
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildLeading(BuildContext context) {
|
Widget buildLeading(BuildContext context) {
|
||||||
return Navigator.canPop(context)
|
// use a property instead of checking `Navigator.canPop(context)`
|
||||||
|
// because the navigator state changes as soon as we press back
|
||||||
|
// so the leading may mistakenly switch to the close button
|
||||||
|
return canPop
|
||||||
? IconButton(
|
? IconButton(
|
||||||
icon: AnimatedIcon(
|
icon: AnimatedIcon(
|
||||||
icon: AnimatedIcons.menu_arrow,
|
icon: AnimatedIcons.menu_arrow,
|
||||||
|
|
Loading…
Reference in a new issue