diff --git a/lib/ui/screens/artifact/artifact_search/artifact_search_screen.dart b/lib/ui/screens/artifact/artifact_search/artifact_search_screen.dart index 1204e722..7fd4bec7 100644 --- a/lib/ui/screens/artifact/artifact_search/artifact_search_screen.dart +++ b/lib/ui/screens/artifact/artifact_search/artifact_search_screen.dart @@ -38,7 +38,7 @@ class _ArtifactSearchScreenState extends State with GetItS @override void initState() { - _search(); + _updateResults(); panelController.addListener(() { AppHaptics.lightImpact(); }); @@ -47,16 +47,18 @@ class _ArtifactSearchScreenState extends State with GetItS void _handleSearchSubmitted(String query) { _query = query; - _search(); + _updateResults(); } void _handleTimelineChanged(double start, double end) { _startYear = start; _endYear = end; - _filter(); + _updateFilter(); } - void _search() { + void _handleResultPressed(SearchData o) => context.push(ScreenPaths.artifact(o.id.toString())); + + void _updateResults() { if (_query.isEmpty) { _searchResults = wonder.searchData; } else { @@ -66,10 +68,10 @@ class _ArtifactSearchScreenState extends State with GetItS _searchResults = wonder.searchData.where((o) => o.title.contains(q) || o.keywords.contains(q)).toList(); } vizController.value = _searchResults; - _filter(); + _updateFilter(); } - void _filter() { + void _updateFilter() { _filteredResults = _searchResults.where((o) => o.year >= _startYear && o.year <= _endYear).toList(); setState(() {}); } @@ -79,7 +81,7 @@ class _ArtifactSearchScreenState extends State with GetItS // tone down the orange just a bit: vizController.color = Color.lerp($styles.colors.accent1, $styles.colors.black, 0.2)!; Widget content = GestureDetector( - onTap: () => WidgetsBinding.instance.focusManager.primaryFocus?.unfocus(), + onTap: FocusManager.instance.primaryFocus?.unfocus, child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -101,7 +103,7 @@ class _ArtifactSearchScreenState extends State with GetItS ? _buildEmptyIndicator(context) : _ResultsGrid( searchResults: _filteredResults, - onPressed: (o) => context.push(ScreenPaths.artifact(o.id.toString())), + onPressed: _handleResultPressed, ), ), ), diff --git a/lib/ui/screens/artifact/artifact_search/widgets/_search_input.dart b/lib/ui/screens/artifact/artifact_search/widgets/_search_input.dart index 8d9f4a10..fe77c687 100644 --- a/lib/ui/screens/artifact/artifact_search/widgets/_search_input.dart +++ b/lib/ui/screens/artifact/artifact_search/widgets/_search_input.dart @@ -34,36 +34,46 @@ class _SearchInput extends StatelessWidget { Widget _buildSuggestionsView(BuildContext context, onSelected, Iterable results, BoxConstraints constraints) { List items = results.map((str) => _buildSuggestion(context, str, () => onSelected(str))).toList(); items.insert(0, _buildSuggestionTitle(context)); - - return TopLeft( - child: Container( - margin: EdgeInsets.only(top: $styles.insets.xxs), - width: constraints.maxWidth, - decoration: BoxDecoration( - boxShadow: [ - BoxShadow( - color: $styles.colors.black.withOpacity(0.25), - blurRadius: 4, - offset: Offset(0, 4), - ), - ], - ), - child: Container( - padding: EdgeInsets.all($styles.insets.xs), - decoration: BoxDecoration( - color: $styles.colors.offWhite.withOpacity(0.92), - borderRadius: BorderRadius.circular($styles.insets.xs), + return Stack( + children: [ + ExcludeSemantics( + child: AppBtn.basic( + onPressed: FocusManager.instance.primaryFocus!.unfocus, + semanticLabel: '', + child: SizedBox.expand(), ), - child: ConstrainedBox( - constraints: BoxConstraints(maxHeight: 200), - child: ListView( + ), + TopLeft( + child: Container( + margin: EdgeInsets.only(top: $styles.insets.xxs), + width: constraints.maxWidth, + decoration: BoxDecoration( + boxShadow: [ + BoxShadow( + color: $styles.colors.black.withOpacity(0.25), + blurRadius: 4, + offset: Offset(0, 4), + ), + ], + ), + child: Container( padding: EdgeInsets.all($styles.insets.xs), - shrinkWrap: true, - children: items, + decoration: BoxDecoration( + color: $styles.colors.offWhite.withOpacity(0.92), + borderRadius: BorderRadius.circular($styles.insets.xs), + ), + child: ConstrainedBox( + constraints: BoxConstraints(maxHeight: 200), + child: ListView( + padding: EdgeInsets.all($styles.insets.xs), + shrinkWrap: true, + children: items, + ), + ), ), ), ), - ), + ], ); }