Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.
Kotlin alternativeandroidandroid-applicationclientglassmorphisminnertubelibrespotliquid-glassspotifyspotify-connectspotifyapiyoutube-musicyoutube-playerytdlnis
Come back to the home page where you left it
Lelonio3e57e064c413
diff --git a/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt b/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.ktindex 6553066..47c4bbc 100644--- a/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/home/HomeScreen.kt@@ -17,6 +17,7 @@ import androidx.compose.foundation.layout.sizeimport androidx.compose.foundation.layout.widthimport androidx.compose.foundation.lazy.LazyColumnimport androidx.compose.foundation.lazy.rememberLazyListState+import androidx.compose.runtime.saveable.rememberSaveableimport androidx.compose.foundation.lazy.LazyRowimport androidx.compose.foundation.lazy.itemsimport androidx.compose.foundation.lazy.itemsIndexed@@ -201,7 +202,12 @@ fun HomeScreen(}is MainViewModel.UiState.Ready -> {- var filter by remember { mutableStateOf(Feed.ALL) }+ // Saved rather than remembered, like the scroll position below it:+ // both are undone by leaving for a playlist and coming back, and a+ // page that forgets which shelf you were reading is the same+ // complaint as one that forgets where you were in it.+ var filterName by rememberSaveable { mutableStateOf(Feed.ALL.name) }+ val filter = Feed.entries.firstOrNull { it.name == filterName } ?: Feed.ALL// Read once here rather than inside the rows: the label travels// with the play so the player can say where the song came from,// and that is a plain string by the time it leaves this screen.@@ -211,7 +217,12 @@ fun HomeScreen(// which for an old account is close to arbitrary — the playlist// opened every day can sit thirtieth.val playlists = remember(state.playlists, playlistOrder) {- state.playlists.sortedByRecentlyOpened(playlistOrder)+ // The phone's own music belongs to the library rather than to+ // this page: home is what the service put together for the+ // listener, and a folder of files is not that.+ state.playlists+ .filterNot { dev.lelonio.square.data.LocalLibrary.isLocalContext(it.uri) }+ .sortedByRecentlyOpened(playlistOrder)}val listState = rememberLazyListState()@@ -234,7 +245,19 @@ fun HomeScreen(// Back to the top when the view changes. The lists have nothing in// common, so keeping the old offset drops the new one in the middle// of itself.- LaunchedEffect(filter) { listState.scrollToItem(0) }+ //+ // The first run is skipped, and that is the whole point: an effect+ // keyed on the filter also runs when this screen is composed, which+ // is every time the listener comes back from a playlist. The page+ // they left halfway down was being scrolled to the top under them+ // for a filter that had not changed at all.+ var scrolledFor by rememberSaveable { mutableStateOf(filter.name) }+ LaunchedEffect(filter) {+ if (scrolledFor != filter.name) {+ scrolledFor = filter.name+ listState.scrollToItem(0)+ }+ }Column(Modifier.fillMaxSize()) {Header(@@ -251,7 +274,7 @@ fun HomeScreen(highlighted = filter,backdrop = backdrop,topPadding = contentPadding.calculateTopPadding(),- onFilter = { filter = it },+ onFilter = { filterName = it.name },onOpenSettings = onOpenSettings,friends = friends,onOpenFriends = onOpenFriends,