diff --git a/mobile/src/main/java/it/panov/musyx/mobile/ui/MusyxApp.kt b/mobile/src/main/java/it/panov/musyx/mobile/ui/MusyxApp.kt index 5f4ed47..d9dfde2 100644 --- a/mobile/src/main/java/it/panov/musyx/mobile/ui/MusyxApp.kt +++ b/mobile/src/main/java/it/panov/musyx/mobile/ui/MusyxApp.kt @@ -24,7 +24,11 @@ import androidx.compose.foundation.layout.statusBarsPadding import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.layout.width import androidx.compose.foundation.shape.CircleShape +import androidx.compose.foundation.text.BasicText +import androidx.compose.foundation.text.TextAutoSize import androidx.compose.material3.IconButton +import androidx.compose.material3.LocalContentColor +import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.NavigationBarItemDefaults @@ -37,13 +41,14 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.res.stringResource import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import it.panov.musyx.mobile.R import it.panov.musyx.mobile.ui.components.MusyxIcon import it.panov.musyx.mobile.ui.screens.AlbumScreen import it.panov.musyx.mobile.ui.screens.ArtistScreen import it.panov.musyx.mobile.ui.screens.ChartScreen -import it.panov.musyx.mobile.ui.screens.DownloadsScreen import it.panov.musyx.mobile.ui.screens.CollectionScreen +import it.panov.musyx.mobile.ui.screens.DownloadsScreen import it.panov.musyx.mobile.ui.screens.GenreScreen import it.panov.musyx.mobile.ui.screens.HoldingScreen import it.panov.musyx.mobile.ui.screens.HomeScreen @@ -190,7 +195,7 @@ private fun NavBar(current: Route, onNavigate: (Route) -> Unit) { selected = selected, onClick = { onNavigate(item.route) }, icon = { MusyxIcon(item.icon, tint = if (selected) c.accentInk else c.muted) }, - label = { Text(stringResource(item.label), maxLines = 1) }, + label = { NavLabel(stringResource(item.label)) }, colors = NavigationBarItemDefaults.colors( indicatorColor = c.accent, selectedTextColor = c.fg, @@ -201,6 +206,18 @@ private fun NavBar(current: Route, onNavigate: (Route) -> Unit) { } } +/** A navigation label, shrunk to fit its fifth of the width rather than cut off at larger text sizes. */ +@Composable +private fun NavLabel(text: String) { + val style = LocalTextStyle.current + BasicText( + text, + style = style.copy(color = LocalContentColor.current), + maxLines = 1, + autoSize = TextAutoSize.StepBased(minFontSize = 9.sp, maxFontSize = style.fontSize), + ) +} + /** `musyx` and the amber dot. */ @Composable fun Wordmark(modifier: Modifier = Modifier) {