Skip to content

Unofficial YouTube Music / Spotify Premium client for Android, built in Liquid Glass. Audio effects, Spotify Connect, listening history, 8 languages. Rust core on librespot.

Make the chips switch the home view, and keep the app in the bar

Lelonio77a4bc9f0de0
diff --git a/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin b/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
index d4e8332..3782ae7 100644
--- a/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
+++ b/app/.cxx/Debug/286k5v33/arm64-v8a/configure_fingerprint.bin
@@ -2,27 +2,27 @@ C/C++ Structured Logc
a
_/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/additional_project_files.txtC
A
-?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ��ŋ�3  ��߈�3`
+?com.android.build.gradle.internal.cxx.io.EncodedFileFingerPrint  ��݋�3  ��߈�3`
^
-\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build.json  ��ŋ�3� ��߈�3e
+\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build.json  ��݋�3� ��߈�3e
c
-a/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build_mini.json  ��ŋ�3� ��߈�3R
+a/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/android_gradle_build_mini.json  ��݋�3� ��߈�3R
P
-N/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja  ��ŋ�3� ��߈�3V
+N/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja  ��݋�3� ��߈�3V
T
-R/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja.txt  ��ŋ�3[
+R/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build.ninja.txt  ��݋�3[
Y
-W/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build_file_index.txt  ��ŋ�3 @ ��߈�3\
+W/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/build_file_index.txt  ��݋�3 @ ��߈�3\
Z
-X/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json  ��ŋ�3֚ ��߈�3`
+X/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json  ��݋�3֚ ��߈�3`
^
-\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json.bin  ��ŋ�3 �" ��߈�3f
+\/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/compile_commands.json.bin  ��݋�3 �" ��߈�3f
d
-b/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/metadata_generation_command.txt  ��ŋ�3
+b/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/metadata_generation_command.txt  ��݋�3
� ��߈�3Y
W
-U/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/prefab_config.json  ��ŋ�3  ( ��߈�3^
+U/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/prefab_config.json  ��݋�3  ( ��߈�3^
\
-Z/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/symbol_folder_index.txt  ��ŋ�3  Y ��߈�3D
+Z/Users/emanuele/Progetto Spotify/app/.cxx/Debug/286k5v33/arm64-v8a/symbol_folder_index.txt  ��݋�3  Y ��߈�3D
B
-@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  ��ŋ�3 � �Ȅ��3
\ No newline at end of file
+@/Users/emanuele/Progetto Spotify/app/src/main/cpp/CMakeLists.txt  ��݋�3 � �Ȅ��3
\ No newline at end of file
diff --git a/app/src/main/java/dev/emanuele/spot/ui/components/GlassMenu.kt b/app/src/main/java/dev/emanuele/spot/ui/components/GlassMenu.kt
index 3d4c1c3..2569b2a 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/components/GlassMenu.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/components/GlassMenu.kt
@@ -42,6 +42,8 @@ import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.unit.IntOffset
import androidx.compose.ui.unit.dp
+import com.adamglin.phosphoricons.Regular
+import com.adamglin.phosphoricons.regular.Check
import androidx.compose.ui.window.Popup
import androidx.compose.ui.window.PopupProperties
@@ -229,3 +231,102 @@ fun GlassIconMenuItem(
/** Light enough to stay glass; the capsule is small and never covers text. */
private val CapsuleFilm = Color.White.copy(alpha = 0.14f)
+
+/**
+ * A short list of choices, in glass, drawn inside the screen.
+ *
+ * The opaque [GlassMenu] above is a popup, and a popup is a window of its own:
+ * it cannot sample another window's layer, so it can only fake the material with
+ * a dark fill. That is the right trade for a menu that has to sit over a track
+ * list near the bottom of the page, where the tab bar would otherwise cross it.
+ *
+ * This one is for menus that open high up, clear of the bars, and can therefore
+ * be drawn in the page and refract it properly. It is also narrower and tighter:
+ * these are variants of one setting, not a list of verbs, so each row is a word
+ * and a tick rather than a word and an icon.
+ */
+@Composable
+fun BoxScope.GlassChoiceMenu(
+ visible: Boolean,
+ anchor: IntOffset,
+ backdrop: Backdrop,
+ onDismiss: () -> Unit,
+ content: @Composable ColumnScope.() -> Unit,
+) {
+ AnimatedVisibility(
+ visible = visible,
+ enter = fadeIn(tween(120)),
+ exit = fadeOut(tween(120)),
+ modifier = Modifier.fillMaxSize(),
+ ) {
+ Box(
+ Modifier
+ .fillMaxSize()
+ .clickable(interactionSource = null, indication = null, onClick = onDismiss),
+ )
+ }
+
+ AnimatedVisibility(
+ visible = visible,
+ enter = scaleIn(tween(180), initialScale = 0.85f, transformOrigin = TopEnd) +
+ fadeIn(tween(120)),
+ exit = scaleOut(tween(130), targetScale = 0.9f, transformOrigin = TopEnd) +
+ fadeOut(tween(110)),
+ modifier = Modifier
+ .align(Alignment.TopStart)
+ .offset { anchor },
+ ) {
+ val shape = RoundedCornerShape(20.dp)
+ GlassSurface(
+ backdrop = backdrop,
+ shape = shape,
+ surfaceColor = CapsuleFilm,
+ blurRadius = 20.dp,
+ modifier = Modifier
+ .width(CHOICE_MENU_WIDTH)
+ .clip(shape)
+ .softShadow(shape, elevation = 18.dp, spot = 0.3f),
+ ) {
+ Column(Modifier.padding(vertical = 4.dp), content = content)
+ }
+ }
+}
+
+@Composable
+fun GlassChoiceItem(
+ label: String,
+ selected: Boolean,
+ onClick: () -> Unit,
+) {
+ Row(
+ Modifier
+ .fillMaxWidth()
+ .clickable(onClick = onClick)
+ .padding(start = 16.dp, end = 12.dp, top = 9.dp, bottom = 9.dp),
+ verticalAlignment = Alignment.CenterVertically,
+ ) {
+ Text(
+ label,
+ style = MaterialTheme.typography.bodyMedium,
+ color = if (selected) Color.White else Color.White.copy(alpha = 0.72f),
+ maxLines = 1,
+ modifier = Modifier.weight(1f),
+ )
+ // Only the chosen row carries a mark: a column of icons down the side
+ // would make four variants of one setting look like four commands.
+ if (selected) {
+ Icon(
+ CheckIcon,
+ contentDescription = null,
+ tint = Color.White,
+ modifier = Modifier.size(15.dp),
+ )
+ }
+ }
+}
+
+/** Narrow on purpose; the longest label still fits on one line. */
+val CHOICE_MENU_WIDTH = 196.dp
+
+private val CheckIcon
+ get() = com.adamglin.PhosphorIcons.Regular.Check
diff --git a/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt
index 401cb58..ed710db 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/home/HomeScreen.kt
@@ -24,6 +24,13 @@ import androidx.compose.material3.CircularProgressIndicator
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
+import androidx.compose.animation.AnimatedContent
+import androidx.compose.animation.core.tween
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
+import androidx.compose.animation.slideInVertically
+import androidx.compose.animation.togetherWith
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
@@ -66,12 +73,10 @@ import java.util.Calendar
/**
* What the feed is showing.
*
- * A filter rather than tabs: the sections keep their order and the chips only
- * decide which of them are on the page, so nothing moves around when you switch
- * and "Tutto" is genuinely the whole thing rather than a fourth view.
- *
- * The chips are in the sections' own order, so scrolling walks along them left
- * to right instead of jumping about.
+ * Chips rather than a second tab bar: they sit inside the page, under the name,
+ * and "Tutto" is genuinely the whole thing rather than a fourth view. The
+ * sections keep their order in every one of them, so switching never rearranges
+ * what stays on screen.
*/
private enum class Feed(val label: String) {
ALL("Tutto"),
@@ -148,10 +153,6 @@ fun HomeScreen(
val playlists = remember(state.playlists, playlistOrder) {
state.playlists.sortedByRecentlyOpened(playlistOrder)
}
- val showReleases = filter == Feed.ALL || filter == Feed.RELEASES
- val showArtists = filter == Feed.ALL || filter == Feed.ARTISTS
- val showLibrary = filter == Feed.ALL || filter == Feed.LIBRARY
-
val listState = rememberLazyListState()
// How far the header has collapsed, 0 to 1.
@@ -170,33 +171,43 @@ fun HomeScreen(
}
}
- // Which section is being looked at, for the chips.
- //
- // Read from the item type rather than from an index: sections
- // appear and disappear with the filter, so any arithmetic over
- // positions would be wrong the moment one of them is empty.
- val visibleSection by remember {
- derivedStateOf {
- listState.layoutInfo.visibleItemsInfo
- .firstNotNullOfOrNull { info ->
- Feed.entries.firstOrNull { it.name == info.contentType }
- }
- }
- }
+ // 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) }
Column(Modifier.fillMaxSize()) {
Header(
name = state.displayName,
avatarUrl = state.avatarUrl,
collapse = { collapse },
- filter = filter,
- highlighted = if (filter == Feed.ALL) visibleSection ?: Feed.ALL else filter,
+ // The chip that is lit is the one that was tapped. It used
+ // to follow whichever section the scroll had reached, which
+ // read as a control changing itself: the chips look like a
+ // filter, so a lit one has to mean "this is what you are
+ // looking at because you asked for it".
+ highlighted = filter,
backdrop = backdrop,
topPadding = contentPadding.calculateTopPadding(),
onFilter = { filter = it },
onOpenSettings = onOpenSettings,
)
+ AnimatedContent(
+ targetState = filter,
+ transitionSpec = {
+ // Short and vertical: the sections do not move sideways
+ // when they are filtered, so neither should the change.
+ (fadeIn(tween(220)) + slideInVertically(tween(260)) { it / 14 })
+ .togetherWith(fadeOut(tween(120)))
+ },
+ label = "feed",
+ ) { current ->
+ val showReleases = current == Feed.ALL || current == Feed.RELEASES
+ val showArtists = current == Feed.ALL || current == Feed.ARTISTS
+ val showLibrary = current == Feed.ALL || current == Feed.LIBRARY
+ val filter = current
+
LazyColumn(
Modifier
.fillMaxSize()
@@ -275,6 +286,7 @@ fun HomeScreen(
item(contentType = "tail") { Box(Modifier.height(24.dp)) }
}
+ }
}
}
}
@@ -303,8 +315,7 @@ private fun Header(
* no recomposition at all.
*/
collapse: () -> Float,
- filter: Feed,
- /** The chip drawn as active, which follows the scroll while nothing is filtered. */
+ /** The chip drawn as active: the one that was tapped. */
highlighted: Feed,
backdrop: Backdrop,
topPadding: Dp,
@@ -340,43 +351,44 @@ private fun Header(
verticalAlignment = Alignment.CenterVertically,
) {
Column(Modifier.weight(1f)) {
- // The name and the icon, where the greeting used to be. The
- // home page carried nothing of the app on it — no name, no mark
- // — so the first screen after the launcher looked like it
- // belonged to nothing in particular.
+ // What survives the collapse, along with the account picture.
//
- // Height goes with the alpha. Fading it alone would leave the
- // header the same size with a blank line in it.
+ // The account name is the greeting; the mark is what page you
+ // are on. Once the header is a bar, a bar carrying only a first
+ // name says nothing about where you are, so it is the name that
+ // leaves and the app that stays. It grows a little on the way
+ // in, since by then it is the only title on screen.
AppLockup(
- iconSize = 18.dp,
- nameHeight = 11.dp,
+ iconSize = 26.dp,
+ nameHeight = 15.dp,
+ modifier = Modifier.graphicsLayer {
+ val scale = 1f + 0.1f * collapse()
+ scaleX = scale
+ scaleY = scale
+ transformOrigin = TransformOrigin(0f, 0.5f)
+ },
+ )
+ // Height goes with the alpha. Fading it alone would leave the
+ // bar the same size with a blank line in it.
+ Text(
+ name,
+ style = MaterialTheme.typography.displayLarge,
+ maxLines = 1,
+ overflow = TextOverflow.Ellipsis,
modifier = Modifier
.layout { measurable, constraints ->
val placeable = measurable.measure(constraints)
- val height = lerp(LOCKUP_HEIGHT, 0.dp, collapse()).roundToPx()
+ val height = ((1f - collapse()) * placeable.height).toInt()
layout(placeable.width, height) { placeable.place(0, 0) }
}
- // The icon is taller than the row gets on the way out,
- // and would otherwise spill over the name.
.graphicsLayer {
clip = true
- alpha = 1f - collapse()
+ alpha = (1f - collapse() * 1.6f).coerceIn(0f, 1f)
+ // Anchored to the mark above it rather than sliding
+ // up from wherever it was.
+ transformOrigin = TransformOrigin(0f, 0f)
},
)
- Text(
- name,
- style = MaterialTheme.typography.displayLarge,
- maxLines = 1,
- overflow = TextOverflow.Ellipsis,
- // Scaled rather than swapped for a smaller style: a style
- // change is a jump, and this has to track a finger.
- modifier = Modifier.graphicsLayer {
- val scale = 1f - 0.34f * collapse()
- scaleX = scale
- scaleY = scale
- transformOrigin = TransformOrigin(0f, 0.5f)
- },
- )
}
// Falls back to the generated cover keyed on the name, which is what
@@ -675,8 +687,6 @@ private val SelectedFilm = Color.White.copy(alpha = 0.26f)
*/
private const val COLLAPSE_DISTANCE_PX = 140f
-/** The icon-and-name line above the account name, at rest. */
-private val LOCKUP_HEIGHT = 20.dp
/** Comfortably under the 640px Spotify serves, so it is never upscaled. */
private val COVER_SIZE = 210.dp
diff --git a/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt b/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt
index d85163f..caf8275 100644
--- a/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt
+++ b/app/src/main/java/dev/emanuele/spot/ui/library/PlaylistScreen.kt
@@ -69,8 +69,9 @@ import com.kyant.backdrop.Backdrop
import com.kyant.backdrop.backdrops.layerBackdrop
import com.kyant.backdrop.backdrops.rememberLayerBackdrop
import dev.emanuele.spot.ui.components.Artwork
-import dev.emanuele.spot.ui.components.GlassMenu
-import dev.emanuele.spot.ui.components.GlassMenuItem
+import dev.emanuele.spot.ui.components.CHOICE_MENU_WIDTH
+import dev.emanuele.spot.ui.components.GlassChoiceItem
+import dev.emanuele.spot.ui.components.GlassChoiceMenu
import dev.emanuele.spot.ui.components.LazyScrollBar
import dev.emanuele.spot.ui.components.SwipeToQueue
import dev.emanuele.spot.ui.glass.LiquidButton
@@ -427,20 +428,17 @@ fun PlaylistScreen(
)
}
- GlassMenu(
+ // In the page rather than in a popup of its own: the sort button is up
+ // by the header, well clear of the bars that would otherwise be drawn
+ // over this, so it can be real glass instead of a dark card.
+ GlassChoiceMenu(
visible = sortOpen,
anchor = sortAnchor.leftOf(density),
+ backdrop = pageBackdrop,
onDismiss = { sortOpen = false },
) {
TrackSort.entries.forEach { option ->
- GlassMenuItem(
- option.label,
- if (option == sort) {
- PhosphorIcons.Regular.Check
- } else {
- PhosphorIcons.Regular.ArrowsDownUp
- },
- ) {
+ GlassChoiceItem(option.label, selected = option == sort) {
sort = option
onSortChange(option.name)
sortOpen = false
@@ -457,7 +455,7 @@ fun PlaylistScreen(
* those controls is at the right-hand edge of the screen.
*/
private fun IntOffset.leftOf(density: androidx.compose.ui.unit.Density): IntOffset {
- val width = with(density) { MENU_WIDTH.roundToPx() }
+ val width = with(density) { CHOICE_MENU_WIDTH.roundToPx() }
val gap = with(density) { 8.dp.roundToPx() }
return IntOffset((x - width + gap).coerceAtLeast(gap), y + gap)
}