diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryMediaTabs.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryMediaTabs.kt index 3245ea965..46399a129 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryMediaTabs.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryMediaTabs.kt @@ -92,7 +92,9 @@ fun LibraryAlbumsTab( onAlbumLongPress: (Album) -> Unit = {}, onAlbumSelectionToggle: (Album) -> Unit = {}, getSelectionIndex: (Long) -> Int? = { null }, - storageFilter: StorageFilter = StorageFilter.ALL + storageFilter: StorageFilter = StorageFilter.ALL, + listState: androidx.compose.foundation.lazy.LazyListState = androidx.compose.foundation.lazy.rememberLazyListState(), + gridState: androidx.compose.foundation.lazy.grid.LazyGridState = androidx.compose.foundation.lazy.grid.rememberLazyGridState() ) { val hasCurrentSong by remember(playerViewModel) { playerViewModel.stablePlayerState @@ -100,10 +102,8 @@ fun LibraryAlbumsTab( .distinctUntilChanged() }.collectAsStateWithLifecycle(initialValue = false) - val gridState = rememberLazyGridState() - val listState = rememberLazyListState() - val dummyListState = rememberLazyListState() - val dummyGridState = rememberLazyGridState() + val dummyListState = androidx.compose.foundation.lazy.rememberLazyListState() + val dummyGridState = androidx.compose.foundation.lazy.grid.rememberLazyGridState() val context = LocalContext.current val imageLoader = context.imageLoader @@ -481,7 +481,8 @@ fun LibraryArtistsTab( onArtistClick: (Long) -> Unit, isRefreshing: Boolean, onRefresh: () -> Unit, - storageFilter: StorageFilter = StorageFilter.ALL + storageFilter: StorageFilter = StorageFilter.ALL, + listState: androidx.compose.foundation.lazy.LazyListState = androidx.compose.foundation.lazy.rememberLazyListState() ) { val hasCurrentSong by remember(playerViewModel) { playerViewModel.stablePlayerState @@ -489,8 +490,7 @@ fun LibraryArtistsTab( .distinctUntilChanged() }.collectAsStateWithLifecycle(initialValue = false) - val listState = rememberLazyListState() - val dummyListState = rememberLazyListState() + val dummyListState = androidx.compose.foundation.lazy.rememberLazyListState() val artistFastScrollLabelProvider = remember(artists, currentArtistSortOption) { { index: Int -> artistFastScrollLabel( diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryScreen.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryScreen.kt index 5d37d029e..9976cb86e 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryScreen.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibraryScreen.kt @@ -438,6 +438,10 @@ fun LibraryScreen( songInfoBottomSheetViewModel: SongInfoBottomSheetViewModel = hiltViewModel() ) { // La recolección de estados de alto nivel se mantiene mínima. + val albumsListState = androidx.compose.foundation.lazy.rememberLazyListState() + val albumsGridState = androidx.compose.foundation.lazy.grid.rememberLazyGridState() + val songsListState = androidx.compose.foundation.lazy.rememberLazyListState() + val artistsListState = androidx.compose.foundation.lazy.rememberLazyListState() val context = LocalContext.current // Added context val haptic = LocalHapticFeedback.current val lastTabIndex by playerViewModel.lastLibraryTabIndexFlow.collectAsStateWithLifecycle() @@ -1533,7 +1537,8 @@ fun LibraryScreen( onRegisterLocateCurrentSongAction = { songsLocateAction = it }, sortOption = playerUiState.currentSongSortOption, storageFilter = playerUiState.currentStorageFilter, - hasCurrentSong = hasCurrentSong + hasCurrentSong = hasCurrentSong, + listState = songsListState ) } LibraryTabId.ALBUMS -> { @@ -1563,7 +1568,9 @@ fun LibraryScreen( onAlbumLongPress = onAlbumLongPress, onAlbumSelectionToggle = onAlbumSelectionToggle, getSelectionIndex = getAlbumSelectionIndex, - storageFilter = playerUiState.currentStorageFilter + storageFilter = playerUiState.currentStorageFilter, + listState = albumsListState, + gridState = albumsGridState ) } @@ -1585,7 +1592,8 @@ fun LibraryScreen( }, isRefreshing = isRefreshing, onRefresh = onRefresh, - storageFilter = playerUiState.currentStorageFilter + storageFilter = playerUiState.currentStorageFilter, + listState = artistsListState ) } diff --git a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibrarySongsTab.kt b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibrarySongsTab.kt index 5fdab7ddb..6f37000af 100644 --- a/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibrarySongsTab.kt +++ b/app/src/main/java/com/theveloper/pixelplay/presentation/screens/LibrarySongsTab.kt @@ -79,10 +79,10 @@ fun LibrarySongsTab( onLocateCurrentSongVisibilityChanged: (Boolean) -> Unit = {}, onRegisterLocateCurrentSongAction: ((() -> Unit)?) -> Unit = {}, storageFilter: StorageFilter = StorageFilter.ALL, - hasCurrentSong: Boolean = false + hasCurrentSong: Boolean = false, + listState: androidx.compose.foundation.lazy.LazyListState = androidx.compose.foundation.lazy.rememberLazyListState() ) { - val listState = rememberLazyListState() - val dummyListState = rememberLazyListState() + val dummyListState = androidx.compose.foundation.lazy.rememberLazyListState() val pullToRefreshState = rememberPullToRefreshState() val coroutineScope = rememberCoroutineScope() val visibilityCallback by rememberUpdatedState(onLocateCurrentSongVisibilityChanged)