Fit navigation labels at large text sizes

At the large text size in Russian the bottom bar cut "Моя волна" to "Моя"
and "Коллекция" to "Коллекци". The five labels now shrink to fit their
slot; everything else keeps the chosen size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Yuriy PanovandClaude Opus 5.5 committed 2026-10-23 16:27:59 +06:00
1 parent 891b1b6efd
commit 04fb5b2b47
1 file changed
+19 -2
@@ -24,7 +24,11 @@ import androidx.compose.foundation.layout.statusBarsPadding
import androidx.compose.foundation.layout.systemBarsPadding import androidx.compose.foundation.layout.systemBarsPadding
import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape 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.IconButton
import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.NavigationBar import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.NavigationBarItemDefaults import androidx.compose.material3.NavigationBarItemDefaults
@@ -37,13 +41,14 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import it.panov.musyx.mobile.R import it.panov.musyx.mobile.R
import it.panov.musyx.mobile.ui.components.MusyxIcon import it.panov.musyx.mobile.ui.components.MusyxIcon
import it.panov.musyx.mobile.ui.screens.AlbumScreen import it.panov.musyx.mobile.ui.screens.AlbumScreen
import it.panov.musyx.mobile.ui.screens.ArtistScreen import it.panov.musyx.mobile.ui.screens.ArtistScreen
import it.panov.musyx.mobile.ui.screens.ChartScreen 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.CollectionScreen
import it.panov.musyx.mobile.ui.screens.DownloadsScreen
import it.panov.musyx.mobile.ui.screens.GenreScreen import it.panov.musyx.mobile.ui.screens.GenreScreen
import it.panov.musyx.mobile.ui.screens.HoldingScreen import it.panov.musyx.mobile.ui.screens.HoldingScreen
import it.panov.musyx.mobile.ui.screens.HomeScreen import it.panov.musyx.mobile.ui.screens.HomeScreen
@@ -190,7 +195,7 @@ private fun NavBar(current: Route, onNavigate: (Route) -> Unit) {
selected = selected, selected = selected,
onClick = { onNavigate(item.route) }, onClick = { onNavigate(item.route) },
icon = { MusyxIcon(item.icon, tint = if (selected) c.accentInk else c.muted) }, 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( colors = NavigationBarItemDefaults.colors(
indicatorColor = c.accent, indicatorColor = c.accent,
selectedTextColor = c.fg, 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. */ /** `musyx` and the amber dot. */
@Composable @Composable
fun Wordmark(modifier: Modifier = Modifier) { fun Wordmark(modifier: Modifier = Modifier) {