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(
|
||||
delegate: CollectionSearchDelegate(
|
||||
source: source,
|
||||
canPop: false,
|
||||
initialQuery: _shortcutSearchQuery,
|
||||
),
|
||||
);
|
||||
|
|
|
@ -28,6 +28,7 @@ class CollectionSearchDelegate {
|
|||
final CollectionSource source;
|
||||
final CollectionLens? parentCollection;
|
||||
final ValueNotifier<String?> expandedSectionNotifier = ValueNotifier(null);
|
||||
final bool canPop;
|
||||
|
||||
static const searchHistoryCount = 10;
|
||||
static final typeFilters = [
|
||||
|
@ -45,13 +46,17 @@ class CollectionSearchDelegate {
|
|||
CollectionSearchDelegate({
|
||||
required this.source,
|
||||
this.parentCollection,
|
||||
this.canPop = true,
|
||||
String? initialQuery,
|
||||
}) {
|
||||
query = initialQuery ?? '';
|
||||
}
|
||||
|
||||
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(
|
||||
icon: AnimatedIcon(
|
||||
icon: AnimatedIcons.menu_arrow,
|
||||
|
|
Loading…
Reference in a new issue