diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c6141eae..efb89fd00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +## Added +- Add search to Bottomsheet [#4456](https://github.com/rokwire/illinois-app/issues/4456) ## [6.0.56] - 2024-11-04 ### Fixed - Bug fixes on the stories sites bottomsheet [#4454](https://github.com/rokwire/illinois-app/issues/4454) diff --git a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart index 2d47ba45a..2d821373e 100644 --- a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart +++ b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart @@ -34,12 +34,14 @@ class ExploreStoriedSightsBottomSheetState extends State _allPlaces = []; ScrollController? _scrollController; + final FocusNode _searchFocusNode = FocusNode(); Map> _mainFilters = {}; Set _regularFilters = {}; Set _expandedMainTags = {}; List? _customPlaces; - + TextEditingController _searchController = TextEditingController(); + bool _isSearchExpanded = false; static final String _customSelectionFilterKey = 'CustomSelection'; @@ -49,6 +51,28 @@ class ExploreStoriedSightsBottomSheetState extends State _buildPlaceListView() { @@ -312,7 +343,7 @@ class ExploreStoriedSightsBottomSheetState extends State filterButtons = []; + filterButtons.add(_buildSearchButton()); // Add Custom Selection Filter Button if (_customPlaces != null) { String label = '${_customPlaces!.length} Places'; @@ -368,12 +400,108 @@ class ExploreStoriedSightsBottomSheetState extends State filteredPlaces = List.from(_allPlaces); + + // Apply search text filter first + String searchText = _searchController.text.toLowerCase(); + if (searchText.isNotEmpty) { + filteredPlaces = filteredPlaces.where((place) { + return place.name?.toLowerCase().contains(searchText) ?? false; + }).toList(); + } + + // Apply selected filters + if (_selectedFilters.isNotEmpty) { + if (_selectedFilters.contains(_customSelectionFilterKey)) { + filteredPlaces = filteredPlaces.where((place) => _customPlaces!.contains(place)).toList(); + } else { + filteredPlaces = filteredPlaces.where((place) { + bool matchesFilter = false; if (_selectedFilters.contains('Visited')) { if (place.userData?.visited != null && place.userData!.visited!.isNotEmpty) { if (_selectedFilters.length > 1) { - return _matchesOtherFilters(place); + matchesFilter = _matchesOtherFilters(place); + } else { + matchesFilter = true; } - return true; } else { - return false; + matchesFilter = false; } } else { - return place.tags != null && place.tags!.any((tag) => _selectedFilters.contains(tag)); + matchesFilter = place.tags != null && place.tags!.any((tag) => _selectedFilters.contains(tag)); } + return matchesFilter; }).toList(); - }); + } } + + setState(() { + _storiedSights = filteredPlaces; + }); } bool _matchesOtherFilters(places_model.Place place) {