diff --git a/lib/controller/search_sort_controller.dart b/lib/controller/search_sort_controller.dart index 91fd4e0d..2bbb1f8e 100644 --- a/lib/controller/search_sort_controller.dart +++ b/lib/controller/search_sort_controller.dart @@ -75,6 +75,10 @@ class SearchSortController { RxMap get playlistsMap => PlaylistController.inst.playlistsMap; + bool get hasRunningSearch => _runningSearches.values.any((running) => running); + + final _runningSearches = {}.obs; + void searchAll(String text) { lastSearchText = text; final enabledSearches = settings.activeSearchMediaTypes; @@ -176,6 +180,7 @@ class SearchSortController { return await SearchPortsProvider.inst.preparePorts( type: MediaType.track, onResult: (result) { + _runningSearches[MediaType.track] = false; final r = result as (List, bool, String); final isTemp = r.$2; final fetchedQuery = r.$3; @@ -219,6 +224,8 @@ class SearchSortController { return await SearchPortsProvider.inst.preparePorts( type: MediaType.playlist, onResult: (result) { + _runningSearches[MediaType.playlist] = false; + final r = result as (List, bool, String); final isTemp = r.$2; final fetchedQuery = r.$3; @@ -251,6 +258,7 @@ class SearchSortController { return await SearchPortsProvider.inst.preparePorts( type: type, onResult: (result) { + _runningSearches[type] = false; final r = result as (List, bool, String); final isTemp = r.$2; final fetchedQuery = r.$3; @@ -286,7 +294,7 @@ class SearchSortController { } return; } - + _runningSearches[MediaType.track] = true; final sp = await _prepareTracksPorts(); sp.send({ 'text': text, @@ -435,6 +443,7 @@ class SearchSortController { return; } + _runningSearches[type] = true; final sp = await _prepareMediaPorts(keys, type); sp.send({ 'text': text, @@ -452,6 +461,7 @@ class SearchSortController { } return; } + _runningSearches[MediaType.playlist] = true; final sp = await _preparePlaylistPorts(); sp.send({ 'text': text, diff --git a/lib/ui/pages/main_page.dart b/lib/ui/pages/main_page.dart index 31be764c..540b4f64 100644 --- a/lib/ui/pages/main_page.dart +++ b/lib/ui/pages/main_page.dart @@ -242,10 +242,21 @@ class MainPage extends StatelessWidget { Player.inst.playOrPause(0, SelectedTracksController.inst.currentAllTracks, QueueSource.allTracks, shuffle: fab == FABType.shuffle); } }, - child: Icon( - ScrollSearchController.inst.isGlobalSearchMenuShown.value ? Broken.search_status_1 : settings.floatingActionButton.value.toIcon(), - color: const Color.fromRGBO(255, 255, 255, 0.8), - ), + child: ScrollSearchController.inst.isGlobalSearchMenuShown.value + ? Stack( + alignment: Alignment.center, + children: [ + const Icon( + Broken.search_status_1, + color: Color.fromRGBO(255, 255, 255, 0.8), + ), + if (SearchSortController.inst.hasRunningSearch) searchProgressWidget, + ], + ) + : Icon( + settings.floatingActionButton.value.toIcon(), + color: const Color.fromRGBO(255, 255, 255, 0.8), + ), ), ), ); diff --git a/pubspec.yaml b/pubspec.yaml index 0663a50a..2b05056a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: namida description: A Beautiful and Feature-rich Music Player, With YouTube & Video Support Built in Flutter publish_to: "none" -version: 2.2.8-beta+240513131 +version: 2.2.9-beta+240513132 environment: sdk: ">=3.1.4 <4.0.0"