From 4be9f0b48439420e5385d6baa4ee1c9d88c22892 Mon Sep 17 00:00:00 2001 From: manavmodi Date: Mon, 4 Nov 2024 00:34:54 -0500 Subject: [PATCH 1/5] Adding search for the bottomsheet --- .../ExploreStoriedSightsBottomSheet.dart | 127 +++++++++++++++--- 1 file changed, 110 insertions(+), 17 deletions(-) diff --git a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart index e37cdd76b..bee0b554f 100644 --- a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart +++ b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart @@ -39,6 +39,8 @@ class ExploreStoriedSightsBottomSheetState extends State _regularFilters = {}; Set _expandedMainTags = {}; List? _customPlaces; + TextEditingController _searchController = TextEditingController(); + bool _isSearchExpanded = false; @@ -48,6 +50,17 @@ class ExploreStoriedSightsBottomSheetState extends State _buildPlaceListView() { @@ -366,6 +386,25 @@ 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('CustomSelection')) { + 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) { From ad74e1f8bbbd615e046fb04b536bd7675e63284d Mon Sep 17 00:00:00 2001 From: manavmodi Date: Mon, 4 Nov 2024 01:44:00 -0500 Subject: [PATCH 2/5] small fix --- lib/ui/explore/ExploreMapPanel.dart | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/ui/explore/ExploreMapPanel.dart b/lib/ui/explore/ExploreMapPanel.dart index df7e01150..be2cb05d5 100644 --- a/lib/ui/explore/ExploreMapPanel.dart +++ b/lib/ui/explore/ExploreMapPanel.dart @@ -587,10 +587,7 @@ class _ExploreMapPanelState extends State void _onMapTap(LatLng coordinate) { debugPrint('ExploreMap tap' ); MTDStop? mtdStop; - if (_selectedMapType == ExploreMapType.StoriedSites) { - _storiedSightsKey.currentState?.resetSelection(); - } - else if ((mtdStop = MTD().stops?.findStop(location: Native.LatLng(latitude: coordinate.latitude, longitude: coordinate.longitude), locationThresholdDistance: 25 /*in meters*/)) != null) { + if ((mtdStop = MTD().stops?.findStop(location: Native.LatLng(latitude: coordinate.latitude, longitude: coordinate.longitude), locationThresholdDistance: 25 /*in meters*/)) != null) { _selectMapExplore(mtdStop); } else if (_selectedMapExplore != null) { From 351fdcf63eeb7363c9ea912d766358f38f55796f Mon Sep 17 00:00:00 2001 From: manavmodi Date: Mon, 4 Nov 2024 15:44:37 -0500 Subject: [PATCH 3/5] Add search and a small fix --- .../ExploreStoriedSightsBottomSheet.dart | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart index 934f11a4d..b57abf07a 100644 --- a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart +++ b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart @@ -331,7 +331,7 @@ class ExploreStoriedSightsBottomSheetState extends State filterButtons = []; + filterButtons.add(_buildSearchButton()); // Add Custom Selection Filter Button if (_customPlaces != null) { String label = '${_customPlaces!.length} Places'; @@ -386,7 +387,6 @@ class ExploreStoriedSightsBottomSheetState extends State Date: Mon, 4 Nov 2024 15:53:44 -0500 Subject: [PATCH 4/5] Add focusNode --- lib/ui/explore/ExploreStoriedSightsBottomSheet.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart index b57abf07a..2d821373e 100644 --- a/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart +++ b/lib/ui/explore/ExploreStoriedSightsBottomSheet.dart @@ -34,6 +34,7 @@ class ExploreStoriedSightsBottomSheetState extends State _allPlaces = []; ScrollController? _scrollController; + final FocusNode _searchFocusNode = FocusNode(); Map> _mainFilters = {}; Set _regularFilters = {}; @@ -50,11 +51,22 @@ class ExploreStoriedSightsBottomSheetState extends State Date: Mon, 4 Nov 2024 15:54:48 -0500 Subject: [PATCH 5/5] Update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) 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)