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
Make the app usable on its side
Leloniof42a0f7531cc
diff --git a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt b/app/src/main/java/dev/lelonio/square/ui/SquareApp.ktindex b2902dc..232dcc9 100644--- a/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt+++ b/app/src/main/java/dev/lelonio/square/ui/SquareApp.kt@@ -47,6 +47,7 @@ import androidx.compose.runtime.saveable.rememberSaveableimport androidx.compose.runtime.snapshotFlowimport androidx.compose.runtime.rememberCoroutineScopeimport androidx.compose.runtime.rememberUpdatedState+import androidx.compose.foundation.layout.widthInimport androidx.compose.runtime.setValueimport dev.lelonio.square.ui.components.FriendsPanelimport dev.lelonio.square.ui.components.SharedTrackCard@@ -1292,6 +1293,15 @@ fun SquareApp(}},onSeek = { player.seekTo(it) },+ // Back to the song on its side: the app follows the phone+ // again once the video is off; see the effect above.+ onSwitchToSong = {+ if (spotifyVideoOn) {+ dev.lelonio.square.backend.spotify.SpotifyVideoMode.listen(player.currentPosition)+ } else {+ YouTubeVideoMode.toggle(player)+ }+ },onToggleShuffle = { player.shuffleModeEnabled = !player.shuffleModeEnabled },onCycleRepeat = {player.repeatMode = when (player.repeatMode) {@@ -1346,13 +1356,18 @@ fun SquareApp()val foldThresholdPx = with(LocalDensity.current) { 50.dp.toPx() }// Beside the bar's own rather than inside it; see ScrollActivity.+ // On its side the phone has height for one row of bar, not two: the+ // bar stays folded — the page's own tab, the song, search — and opens+ // only when its tab is tapped, never by itself at the top of a page.+ val sideways = rememberUpdatedState(landscape)+ LaunchedEffect(landscape) { if (landscape) tabBarScroll.inline() }val scrollActivity = remember(tabBarScroll, foldThresholdPx) {dev.lelonio.square.ui.glass.ScrollActivity(onFold = { tabBarScroll.inline() },// Only at the top. Scrolling up in the middle of a list leaves// the bar where it is: it went away because the reader is// reading, and it comes back when they have finished.- onTop = { tabBarScroll.expand() },+ onTop = { if (!sideways.value) tabBarScroll.expand() },foldThresholdPx = foldThresholdPx,)}@@ -2147,7 +2162,10 @@ fun SquareApp(if (chrome > 0.01f) Box(Modifier.align(Alignment.BottomCenter)- .fillMaxWidth()+ // Sideways, no wider than a phone held upright: a bar+ // across the whole of a landscape screen is a strip+ // of glass with the controls lost at its ends.+ .then(if (landscape) Modifier.widthIn(max = 640.dp) else Modifier.fillMaxWidth())// The bar is where you type now, so it has to be above// the keyboard: the search field lived on the page until// a moment ago, where the keyboard covering the bottom ofdiff --git a/app/src/main/java/dev/lelonio/square/ui/browse/RadioScreen.kt b/app/src/main/java/dev/lelonio/square/ui/browse/RadioScreen.ktindex 7283dc2..fe7f4ab 100644--- a/app/src/main/java/dev/lelonio/square/ui/browse/RadioScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/browse/RadioScreen.kt@@ -96,7 +96,9 @@ fun RadioScreen(}LazyVerticalGrid(- columns = GridCells.Fixed(2),+ // As many as fit: two on a phone held upright, five or six on its side,+ // where two filled the screen with a pair of tiles taller than it.+ columns = GridCells.Adaptive(minSize = 150.dp),contentPadding = PaddingValues(start = 16.dp,end = 16.dp,diff --git a/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.kt b/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.ktindex 7b8205e..b8f5dd5 100644--- a/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/library/LibraryScreen.kt@@ -36,6 +36,7 @@ import androidx.compose.runtime.rememberimport androidx.compose.runtime.setValueimport androidx.compose.ui.Alignmentimport androidx.compose.ui.Modifier+import androidx.compose.ui.layout.layoutimport androidx.compose.ui.res.stringResourceimport androidx.compose.foundation.lazy.LazyRowimport androidx.compose.foundation.lazy.grid.GridItemSpan@@ -303,25 +304,33 @@ fun LibraryScreen(} else {Box(Modifier.fillMaxSize()) {Column(Modifier.fillMaxSize()) {- Header(- count = playlists.size,- layout = layout,- order = order,- filter = filter,- backdrop = backdrop,- topPadding = contentPadding.calculateTopPadding(),- onLayout = {- layout = it- view.grid = it == Layout.GRID- },- onOrder = { onOrderChosen(it) },- onFilter = { filter = it },- onSort = { sortOpen = true },- onSortAnchor = { sortAnchor = it },- canEdit = canEdit,- onCreatePlaylist = onCreatePlaylist,- onOpenRecap = if (listeningEvents != null) ({ recapOpen = true }) else null,- )+ // On its side the screen is short, and the heading held still+ // over the list covered half of it: there it scrolls away with+ // the list instead, as the first thing in it.+ val sideways = androidx.compose.ui.platform.LocalConfiguration.current.orientation ==+ android.content.res.Configuration.ORIENTATION_LANDSCAPE+ val heading: @Composable () -> Unit = {+ Header(+ count = playlists.size,+ layout = layout,+ order = order,+ filter = filter,+ backdrop = backdrop,+ topPadding = contentPadding.calculateTopPadding(),+ onLayout = {+ layout = it+ view.grid = it == Layout.GRID+ },+ onOrder = { onOrderChosen(it) },+ onFilter = { filter = it },+ onSort = { sortOpen = true },+ onSortAnchor = { sortAnchor = it },+ canEdit = canEdit,+ onCreatePlaylist = onCreatePlaylist,+ onOpenRecap = if (listeningEvents != null) ({ recapOpen = true }) else null,+ )+ }+ if (!sideways) heading()val listPadding = PaddingValues(start = 20.dp,@@ -333,7 +342,9 @@ fun LibraryScreen(when (layout) {Layout.GRID -> LazyVerticalGrid(state = gridState,- columns = GridCells.Fixed(2),+ // As many as fit: two on a phone held upright, five or six on its side,+ // where two filled the screen with a pair of tiles taller than it.+ columns = GridCells.Adaptive(minSize = 150.dp),contentPadding = listPadding,horizontalArrangement = Arrangement.spacedBy(14.dp),verticalArrangement = Arrangement.spacedBy(18.dp),@@ -345,6 +356,11 @@ fun LibraryScreen(frozen = { listBackdropFreeze.frozen() || gridState.isScrollInProgress },),) {+ if (sideways) {+ item(span = { GridItemSpan(maxLineSpan) }, key = "heading") {+ Box(Modifier.bleed(20.dp)) { heading() }+ }+ }item(span = { GridItemSpan(maxLineSpan) }, key = "search") {dev.lelonio.square.ui.components.ListSearchField(query = query,@@ -399,6 +415,9 @@ fun LibraryScreen(frozen = { listBackdropFreeze.frozen() || listState.isScrollInProgress },),) {+ if (sideways) {+ item(key = "heading") { Box(Modifier.bleed(20.dp)) { heading() } }+ }item(key = "search") {dev.lelonio.square.ui.components.ListSearchField(query = query,@@ -822,3 +841,16 @@ private fun ArtistShelf(}}}++/** Out past [horizontal] of the padding it was laid out in, on both sides. */+private fun Modifier.bleed(horizontal: androidx.compose.ui.unit.Dp): Modifier =+ layout { measurable, constraints ->+ val extra = horizontal.roundToPx()+ val placeable = measurable.measure(+ constraints.copy(+ minWidth = constraints.minWidth + 2 * extra,+ maxWidth = constraints.maxWidth + 2 * extra,+ ),+ )+ layout(constraints.maxWidth, placeable.height) { placeable.place(-extra, 0) }+ }diff --git a/app/src/main/java/dev/lelonio/square/ui/player/FullScreenVideo.kt b/app/src/main/java/dev/lelonio/square/ui/player/FullScreenVideo.ktindex c7f5254..82c4b6b 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/FullScreenVideo.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/FullScreenVideo.kt@@ -43,6 +43,7 @@ import com.adamglin.phosphoricons.fill.SkipForwardimport dev.lelonio.square.Rimport com.adamglin.phosphoricons.Regularimport com.adamglin.phosphoricons.regular.CornersIn+import com.adamglin.phosphoricons.regular.MusicNotesimport dev.lelonio.square.ui.library.formatDuration/**@@ -68,6 +69,13 @@ fun FullScreenVideo(onSeek: (Long) -> Unit,onToggleShuffle: () -> Unit,onCycleRepeat: () -> Unit,+ /**+ * Back to the song, staying on the side the phone is held. The only way+ * back used to be the button below, which turns the app upright: on a+ * phone held sideways, a foldable above all, going back to the song meant+ * going back to portrait.+ */+ onSwitchToSong: (() -> Unit)? = null,) {// The video's own shape, so it is fitted rather than stretched; see// rememberVideoRatio.@@ -162,20 +170,41 @@ fun FullScreenVideo(.align(Alignment.TopEnd).padding(horizontal = 20.dp, vertical = 16.dp),) {- Box(- Modifier- .size(40.dp)- .clip(androidx.compose.foundation.shape.CircleShape)- .background(Color.Black.copy(alpha = 0.4f))- .clickable { lockVideoOrientation(context, landscape = false) },- contentAlignment = Alignment.Center,+ androidx.compose.foundation.layout.Row(+ horizontalArrangement = androidx.compose.foundation.layout.Arrangement.spacedBy(10.dp),) {- Icon(- PhosphorIcons.Regular.CornersIn,- contentDescription = stringResource(R.string.exit_full_screen),- tint = Color.White,- modifier = Modifier.size(20.dp),- )+ if (onSwitchToSong != null) {+ Box(+ Modifier+ .size(40.dp)+ .clip(androidx.compose.foundation.shape.CircleShape)+ .background(Color.Black.copy(alpha = 0.4f))+ .clickable(onClick = onSwitchToSong),+ contentAlignment = Alignment.Center,+ ) {+ Icon(+ PhosphorIcons.Regular.MusicNotes,+ contentDescription = stringResource(R.string.switch_to_audio),+ tint = Color.White,+ modifier = Modifier.size(20.dp),+ )+ }+ }+ Box(+ Modifier+ .size(40.dp)+ .clip(androidx.compose.foundation.shape.CircleShape)+ .background(Color.Black.copy(alpha = 0.4f))+ .clickable { lockVideoOrientation(context, landscape = false) },+ contentAlignment = Alignment.Center,+ ) {+ Icon(+ PhosphorIcons.Regular.CornersIn,+ contentDescription = stringResource(R.string.exit_full_screen),+ tint = Color.White,+ modifier = Modifier.size(20.dp),+ )+ }}}diff --git a/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.kt b/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.ktindex 3510229..cd955be 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/LyricsOptions.kt@@ -46,6 +46,7 @@ import androidx.compose.ui.unit.dpimport com.adamglin.PhosphorIconsimport com.adamglin.phosphoricons.Regularimport com.adamglin.phosphoricons.regular.CaretDown+import com.adamglin.phosphoricons.regular.Quotesimport com.adamglin.phosphoricons.regular.Checkimport com.adamglin.phosphoricons.regular.Ximport dev.lelonio.square.R@@ -58,26 +59,29 @@ import dev.lelonio.square.ui.glass.backdrop.Backdropimport dev.lelonio.square.ui.glass.pressableimport kotlinx.coroutines.launch-/** Where the words on screen came from, and the way to the others. */+/**+ * The way to the other sources and styles: a round button in the column of+ * the lyrics' controls, above the translation, like them. It used to be a+ * labelled chip on its own in the other corner.+ */@Composablefun LyricsSourceChip(source: String?, backdrop: Backdrop, onClick: () -> Unit, modifier: Modifier = Modifier) {val label = LyricsSource.entries.firstOrNull { it.name == source }?.label?: stringResource(R.string.lyrics_sources)GlassSurface(backdrop = backdrop,- shape = RoundedCornerShape(50),- modifier = modifier.pressable(onClick, shape = RoundedCornerShape(50)),+ shape = androidx.compose.foundation.shape.CircleShape,+ modifier = modifier+ .size(44.dp)+ .pressable(onClick, shape = androidx.compose.foundation.shape.CircleShape),) {- Row(- Modifier.padding(start = 14.dp, end = 10.dp, top = 8.dp, bottom = 8.dp),- verticalAlignment = Alignment.CenterVertically,- ) {- Text(label, style = MaterialTheme.typography.labelLarge, color = GlassInk, maxLines = 1)+ Box(Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {Icon(- PhosphorIcons.Regular.CaretDown,- contentDescription = null,- tint = GlassInkDim,- modifier = Modifier.padding(start = 6.dp).size(14.dp),+ PhosphorIcons.Regular.Quotes,+ // Says which source it is, for whoever cannot see the words.+ contentDescription = label,+ tint = GlassInk,+ modifier = Modifier.size(20.dp),)}}diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.ktindex 5eaac20..faf88db 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerPanel.kt@@ -112,6 +112,8 @@ fun PlayerPanelSection(/** The layer the panel refracts; see the liquid-glass note in PlayerScreen. */backdrop: dev.lelonio.square.ui.glass.backdrop.Backdrop,modifier: Modifier = Modifier,+ /** False on a phone held sideways, where the cover is beside the views already. */+ showCover: Boolean = true,) {Column(modifier.fillMaxWidth(),@@ -140,9 +142,9 @@ fun PlayerPanelSection(.collectAsStateWithLifecycle()val karaokeOn = karaoke > 0f && !sdkPlayback- val views = remember(sdkPlayback) {+ val views = remember(sdkPlayback, showCover) {listOfNotNull(- PlayerPanel.NONE,+ PlayerPanel.NONE.takeIf { showCover },PlayerPanel.LYRICS,PlayerPanel.QUEUE,PlayerPanel.EFFECTS.takeUnless { sdkPlayback },@@ -177,7 +179,7 @@ fun PlayerPanelSection(.fillMaxWidth(0.84f).padding(top = 14.dp),) {- PanelTab(+ if (showCover) PanelTab(icon = PhosphorIcons.Regular.VinylRecord,activeIcon = PhosphorIcons.Fill.VinylRecord,label = stringResource(R.string.cover),diff --git a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.ktindex da7527c..d883b52 100644--- a/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt+++ b/app/src/main/java/dev/lelonio/square/ui/player/PlayerScreen.kt@@ -21,6 +21,9 @@ import androidx.compose.animation.core.animateDpAsStateimport androidx.compose.animation.core.tweenimport androidx.compose.foundation.backgroundimport androidx.compose.foundation.layout.width+import androidx.compose.foundation.layout.widthIn+import androidx.compose.foundation.layout.ColumnScope+import androidx.compose.foundation.layout.fillMaxHeightimport androidx.compose.foundation.borderimport androidx.compose.foundation.gestures.detectTapGesturesimport androidx.compose.ui.text.font.FontWeight@@ -222,6 +225,8 @@ private fun NowReadingLine(backdrop: Backdrop,onClick: () -> Unit,modifier: Modifier = Modifier,+ /** On its side: no wider than a phone held upright, in the middle. */+ sideways: Boolean = false,) {GlassSurface(backdrop = backdrop,@@ -229,6 +234,7 @@ private fun NowReadingLine(shape = RoundedCornerShape(50),modifier = modifier.padding(vertical = 6.dp)+ .then(if (sideways) Modifier.widthIn(max = 560.dp) else Modifier).fillMaxWidth().pressable(onClick = onClick),) {@@ -552,6 +558,17 @@ fun PlayerScreen(// lyric over one.val panelOpen = panel != PlayerPanel.NONE+ // On its side: the stage and the controls side by side; see stageBlock.+ val sideways = androidx.compose.ui.platform.LocalConfiguration.current.orientation ==+ android.content.res.Configuration.ORIENTATION_LANDSCAPE+ // On its side the player is two halves: the song on a card to the left,+ // the views — lyrics, queue, effects, credits — to the right; see SongCard.+ val readingSideways = sideways+ // The cover is the card's on its side, so the views start at the lyrics.+ LaunchedEffect(sideways, panel) {+ if (sideways && panel == PlayerPanel.NONE) panel = PlayerPanel.LYRICS+ }+// The words on their own, as Apple Music does it: while a song plays over// its lyrics and nobody touches the screen, everything but the transport// steps aside and the lyrics take the room, under a line with the song on@@ -562,7 +579,8 @@ fun PlayerScreen(// Set by the stage as a press arrives, read by the column after it.var pressOnLyrics by remember { mutableStateOf(false) }var lyricsAlone by remember { mutableStateOf(false) }- val lyricsReading = panel == PlayerPanel.LYRICS && lyrics != null && !lyricsLoading+ val lyricsReading = (panel == PlayerPanel.LYRICS || (sideways && panel == PlayerPanel.NONE)) &&+ lyrics != null && !lyricsLoading// On wantsPlay, not isPlaying: a tap on a line seeks, the player stops for// the moment it takes to load the new place, and on isPlaying that moment// brought everything back and folded it away again four seconds later.@@ -637,6 +655,21 @@ fun PlayerScreen(// Recorded for the glass above, so light drawn here is light the// buttons and the panels refract; see lightBackdrop.Box(Modifier.fillMaxSize().layerBackdrop(lightBackdrop)) {+ // On its side, the room is the sleeve itself, blurred and dimmed:+ // the picture behind the player upright is often another one — the+ // record's extended artwork — and beside the sleeve it read as two+ // different covers at once.+ if (sideways) {+ dev.lelonio.square.ui.components.Artwork(+ url = state.artworkUrl,+ title = state.title,+ modifier = Modifier+ .fillMaxSize()+ .blur(70.dp),+ corner = 0.dp,+ )+ Box(Modifier.fillMaxSize().background(Color.Black.copy(alpha = 0.45f)))+ }AmbientLight(ambient)// In this layer so the glass refracts the DJ, not the cover under it.val djShown by animateFloatAsState(@@ -685,7 +718,10 @@ fun PlayerScreen(// two overlap for the length of the change, and it comes back the// same way on a track that has no clip.val coverFade by animateFloatAsState(- targetValue = if (!videoOn && (canvas == null || !canvasReady)) 1f else 0f,+ // Never on its side, where the room is the sleeve, blurred: the+ // stand-in is the record's extended artwork, often another+ // picture, and it was what showed behind the sleeve.+ targetValue = if (!sideways && !videoOn && (canvas == null || !canvasReady)) 1f else 0f,animationSpec = tween(CANVAS_HANDOVER),label = "coverFade",)@@ -1006,6 +1042,10 @@ fun PlayerScreen(.systemBarsPadding().padding(horizontal = 20.dp),) {+ // Across the top upright; at the top of the song's+ // half on its side, where the video, devices and the way+ // down would otherwise be missing.+ val topBar: @Composable (Modifier) -> Unit = { barModifier ->TopBar(backdrop = upperBackdrop,panel = panel,@@ -1029,21 +1069,26 @@ fun PlayerScreen(onAnotherDevice = onAnotherDevice,onWatchVideo = onWatchVideo,videoOn = videoOn,- modifier = Modifier.retreat(chrome),+ modifier = barModifier,dj = isDjQueue(state.contextUri),)+ }+ if (!sideways) topBar(Modifier.retreat(chrome))// In its place while the lyrics are read alone: the song,// and the way back to its cover.NowReadingLine(state = state,+ sideways = sideways,// The ground, as the title pill reads it: over the// lyrics the clip is blurred on screen and not in its// own layer, and a pane refracting that layer showed// the moving cover sharp through frosted glass.backdrop = groundBackdrop,onClick = { panel = PlayerPanel.NONE },- modifier = Modifier.retreat(1f - chrome),+ modifier = Modifier+ .align(Alignment.CenterHorizontally)+ .retreat(if (readingSideways) 0f else 1f - chrome),)// Everything sits at the bottom, as in the reference: the@@ -1054,11 +1099,36 @@ fun PlayerScreen(// column measures against an infinite height. The panels// below cap their own height and scroll internally, so the// screen never needs to.- Column(- Modifier.fillMaxSize(),- horizontalAlignment = Alignment.CenterHorizontally,- verticalArrangement = Arrangement.Bottom,- ) {+ // The stage and the controls, as two pieces: one above the other on a+ // phone held upright, side by side on its side, where one above the+ // other left the controls stretched across the screen and the tabs+ // pushed off the bottom of it.+ val tabsBlock: @Composable () -> Unit = {+ PlayerPanelSection(+ panel = panel,+ onSelect = { panel = it },+ queue = queue,+ lyrics = lyrics,+ lyricsLoading = lyricsLoading,+ positionMs = positionMs,+ onPlayQueueItem = onPlayQueueItem,+ onSeek = onSeek,+ speed = state.speed,+ pitch = state.pitch,+ reverb = reverb,+ onSpeed = onSpeed,+ onPitch = onPitch,+ onReverb = onReverb,+ presets = presets,+ onApplyPreset = onApplyPreset,+ onSavePreset = onSavePreset,+ onDeletePreset = onDeletePreset,+ backdrop = lowerBackdrop,+ modifier = Modifier.retreat(chrome),+ showCover = !sideways,+ )+ }+ val stageBlock: @Composable ColumnScope.() -> Unit = {// With a Canvas the clip *is* the picture and a cover on// top would compete with it. Without one, the cover// fills the space above the controls — the shadow that@@ -1093,7 +1163,9 @@ fun PlayerScreen(// cover, at the size the record was given one for, and// putting the sleeve back on top of it is the same image// twice — which is what the reference stopped doing.- val coverShowing = panel == PlayerPanel.NONE &&+ // Never on its side, where the cover is the stage's own+ // to draw: see Stage.COVER.+ val coverShowing = !sideways && panel == PlayerPanel.NONE &&!(videoOn && videoPlayer != null && LocalGlassEnabled.current) &&(canvas == null || !canvasReady)// One at a time, from one clock.@@ -1187,7 +1259,12 @@ fun PlayerScreen(PlayerPanel.QUEUE -> Stage.QUEUEPlayerPanel.DEVICES -> Stage.DEVICESPlayerPanel.ADD_TO_PLAYLIST -> Stage.ADD_TO_PLAYLIST- PlayerPanel.NONE -> when {+ // On its side the cover is on the card to the+ // left, so the right half opens on the words, or+ // on what is coming up for a song without any.+ PlayerPanel.NONE -> if (sideways) {+ if (lyrics != null || lyricsLoading) Stage.LYRICS else Stage.QUEUE+ } else when {// Not while the player is travelling: a// TextureView inside a layer being scaled// and faded loses its surface for the length@@ -1224,6 +1301,8 @@ fun PlayerScreen(.graphicsLayer { alpha = panelAlpha },) { stage ->when (stage) {+ // Empty: the cover above this AnimatedContent+ // is what fills the slot when no panel is open.// Empty: the cover above this AnimatedContent// is what fills the slot when no panel is open.Stage.COVER -> Box(Modifier.fillMaxSize())@@ -1383,6 +1462,8 @@ fun PlayerScreen(}}+ }+ val controlsBlock: @Composable ColumnScope.() -> Unit = {// With a panel open the room below the stage goes to// the panel: lyrics, queue and effects ran out a video// row and a gap short of the title, over empty glass.@@ -1395,7 +1476,9 @@ fun PlayerScreen(label = "gapBelowStage",)val videoRowHeight by androidx.compose.animation.core.animateDpAsState(- if (panelOpen) 0.dp else VIDEO_ROW_HEIGHT,+ // On its side the room is the controls': the+ // video is one tap away at the top right.+ if (panelOpen || sideways) 0.dp else VIDEO_ROW_HEIGHT,tween(STAGE_FADE_MS * 2),label = "videoRowHeight",)@@ -1427,7 +1510,7 @@ fun PlayerScreen(contentAlignment = Alignment.Center,) {androidx.compose.animation.AnimatedVisibility(- visible = videoFileId != null && !panelOpen,+ visible = videoFileId != null && !panelOpen && !sideways,enter = fadeIn(tween(260)) + scaleIn(tween(260), initialScale = 0.9f),exit = fadeOut(tween(180)) + scaleOut(tween(180), targetScale = 0.92f),) {@@ -1469,6 +1552,18 @@ fun PlayerScreen(}}+ // On its side there is room above the title, and the+ // line being sung is the best thing to put in it.+ if (sideways && panel == PlayerPanel.NONE && lyrics?.synced == true) {+ SungLine(+ lyrics = lyrics,+ positionMs = positionMs,+ modifier = Modifier+ .fillMaxWidth()+ .padding(start = 8.dp, end = 8.dp, bottom = 8.dp),+ )+ }+// Title and artist on their own capsule, with the two// per-track actions on the right.GlassSurface(@@ -1582,7 +1677,8 @@ fun PlayerScreen(}Column(Modifier.retreat(chrome)) {- Spacer(Modifier.height(18.dp))+ // Tighter on its side, where the column is short.+ Spacer(Modifier.height(if (sideways) 10.dp else 18.dp))GlassProgressBar(positionMs = positionMs,@@ -1593,7 +1689,7 @@ fun PlayerScreen()TimeRow(positionMs, state.durationMs)- Spacer(Modifier.height(14.dp))+ Spacer(Modifier.height(if (sideways) 6.dp else 14.dp))}Controls(@@ -1607,33 +1703,58 @@ fun PlayerScreen(toggles = chrome,)- Spacer(Modifier.height(14.dp))--- PlayerPanelSection(- panel = panel,- onSelect = { panel = it },- queue = queue,- lyrics = lyrics,- lyricsLoading = lyricsLoading,- positionMs = positionMs,- onPlayQueueItem = onPlayQueueItem,- onSeek = onSeek,- speed = state.speed,- pitch = state.pitch,- reverb = reverb,- onSpeed = onSpeed,- onPitch = onPitch,- onReverb = onReverb,- presets = presets,- onApplyPreset = onApplyPreset,- onSavePreset = onSavePreset,- onDeletePreset = onDeletePreset,- backdrop = lowerBackdrop,- modifier = Modifier.retreat(chrome),- )+ // Under the transport upright; under the sleeve on+ // its side, where there is no height left for it here.+ if (!sideways) {+ Spacer(Modifier.height(14.dp))+ tabsBlock()+ }- Spacer(Modifier.height(20.dp))+ Spacer(Modifier.height(if (sideways) 12.dp else 20.dp))+ }+ if (sideways) {+ Row(Modifier.fillMaxSize()) {+ Column(+ Modifier+ .weight(0.85f)+ .fillMaxHeight(),+ ) {+ topBar(Modifier)+ SongCard(+ state = state,+ positionMs = positionMs,+ onSeek = onSeek,+ onTogglePlay = onTogglePlay,+ onNext = onNext,+ onPrevious = onPrevious,+ onCover = { panel = PlayerPanel.LYRICS },+ modifier = Modifier+ .weight(1f)+ .fillMaxWidth(),+ )+ }+ Spacer(Modifier.width(24.dp))+ Column(+ Modifier+ .weight(1.4f)+ .fillMaxHeight(),+ horizontalAlignment = Alignment.CenterHorizontally,+ ) {+ stageBlock()+ Spacer(Modifier.height(8.dp))+ tabsBlock()+ Spacer(Modifier.height(12.dp))+ }+ }+ } else {+ Column(+ Modifier.fillMaxSize(),+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.Bottom,+ ) {+ stageBlock()+ controlsBlock()+ }}}}@@ -2743,9 +2864,12 @@ private fun LyricsStage(source = lyrics?.source,backdrop = backdrop,onClick = { optionsOpen = true },+ // At the top of the column the translation and the karaoke+ // stand in, above them. With no words there is no+ // translation to sit above, so it takes that place instead.modifier = Modifier- .align(Alignment.BottomStart)- .padding(start = 6.dp, bottom = 6.dp),+ .align(Alignment.BottomEnd)+ .padding(end = 6.dp, bottom = if (lyrics != null) 106.dp else 56.dp),)}@@ -2788,3 +2912,164 @@ private fun LyricsStage()}}++/**+ * The line of [lyrics] being sung at [positionMs], changing with a dissolve;+ * nothing between lines, where nobody is singing. For the room above the+ * title on a phone held sideways.+ */+@Composable+private fun SungLine(+ lyrics: dev.lelonio.square.data.Lyrics,+ positionMs: State<Long>,+ modifier: Modifier = Modifier,+) {+ val line by remember(lyrics) {+ androidx.compose.runtime.derivedStateOf {+ val now = positionMs.value+ lyrics.lines.lastOrNull { (it.startTimeMs ?: Long.MAX_VALUE) <= now }+ ?.text?.trim().orEmpty()+ }+ }+ // Two lines' height whatever is being sung: a line that grew from one row+ // to two pushed the title, the progress and the transport down with it.+ AnimatedContent(+ targetState = line,+ transitionSpec = {+ (fadeIn(tween(320)) + androidx.compose.animation.slideInVertically(tween(320)) { it / 3 })+ .togetherWith(fadeOut(tween(220)))+ },+ label = "sungLine",+ contentAlignment = Alignment.BottomCenter,+ modifier = modifier.height(56.dp),+ ) { text ->+ Text(+ text,+ style = MaterialTheme.typography.titleMedium,+ fontWeight = FontWeight.SemiBold,+ color = GlassInk,+ textAlign = TextAlign.Center,+ maxLines = 2,+ overflow = TextOverflow.Ellipsis,+ modifier = Modifier.fillMaxWidth(),+ )+ }+}++/**+ * The song while its lyrics fill the rest of a sideways screen: the sleeve+ * with the transport over its foot, the progress under it, then the title and+ * the artist. A tap on the sleeve goes back to it.+ */+@Composable+private fun SongCard(+ state: PlaybackState,+ positionMs: State<Long>,+ onSeek: (Long) -> Unit,+ onTogglePlay: () -> Unit,+ onNext: () -> Unit,+ onPrevious: () -> Unit,+ onCover: () -> Unit,+ modifier: Modifier = Modifier,+) {+ Column(+ modifier.padding(vertical = 12.dp),+ horizontalAlignment = Alignment.CenterHorizontally,+ verticalArrangement = Arrangement.Center,+ ) {+ Box(+ Modifier+ .weight(1f, fill = false)+ .aspectRatio(1f)+ .softShadow(RoundedCornerShape(18.dp), elevation = 20.dp)+ .clip(RoundedCornerShape(18.dp))+ .clickable(onClick = onCover),+ ) {+ dev.lelonio.square.ui.components.Artwork(+ url = state.artworkUrl,+ title = state.title,+ modifier = Modifier.fillMaxSize(),+ corner = 18.dp,+ )+ // A shade at the foot, so the transport reads over any sleeve.+ Box(+ Modifier+ .align(Alignment.BottomCenter)+ .fillMaxWidth()+ .fillMaxHeight(0.42f)+ .background(Brush.verticalGradient(listOf(Color.Transparent, Color.Black.copy(alpha = 0.6f)))),+ )+ Row(+ Modifier+ .align(Alignment.BottomCenter)+ .padding(bottom = 12.dp),+ horizontalArrangement = Arrangement.spacedBy(18.dp),+ verticalAlignment = Alignment.CenterVertically,+ ) {+ CardButton(PhosphorIcons.Fill.SkipBack, stringResource(R.string.previous), 40.dp, state.hasPrevious, onPrevious)+ CardButton(+ if (state.wantsPlay) PhosphorIcons.Fill.Pause else PhosphorIcons.Fill.Play,+ stringResource(if (state.wantsPlay) R.string.pause else R.string.play),+ 52.dp,+ true,+ onTogglePlay,+ )+ CardButton(PhosphorIcons.Fill.SkipForward, stringResource(R.string.next), 40.dp, state.hasNext, onNext)+ }+ }+ Column(Modifier.widthIn(max = 420.dp).padding(top = 12.dp)) {+ GlassProgressBar(+ positionMs = positionMs,+ durationMs = state.durationMs,+ onSeek = onSeek,+ accentColor = GlassInk,+ trackColor = GlassInk.copy(alpha = 0.28f),+ )+ TimeRow(positionMs, state.durationMs)+ }+ Text(+ state.title,+ style = MaterialTheme.typography.titleMedium,+ fontWeight = FontWeight.SemiBold,+ color = GlassInk,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ textAlign = TextAlign.Center,+ modifier = Modifier.padding(top = 6.dp),+ )+ Text(+ state.artist,+ style = MaterialTheme.typography.bodyMedium,+ color = GlassInkDim,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ textAlign = TextAlign.Center,+ )+ }+}++/** A round control over the sleeve: a dark disc, a white glyph. */+@Composable+private fun CardButton(+ icon: androidx.compose.ui.graphics.vector.ImageVector,+ description: String,+ size: androidx.compose.ui.unit.Dp,+ enabled: Boolean,+ onClick: () -> Unit,+) {+ Box(+ Modifier+ .size(size)+ .clip(CircleShape)+ .background(Color.Black.copy(alpha = 0.35f))+ .clickable(enabled = enabled, onClick = onClick),+ contentAlignment = Alignment.Center,+ ) {+ Icon(+ icon,+ contentDescription = description,+ tint = Color.White.copy(alpha = if (enabled) 1f else 0.4f),+ modifier = Modifier.size(size * 0.45f),+ )+ }+}