From 04fb5b2b4740f0df41a3161dd343e79c9e7e22f4 Mon Sep 17 00:00:00 2001 From: Yuriy Panov Date: Fri, 23 Oct 2026 16:27:59 +0600 Subject: [PATCH] Fit navigation labels at large text sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../java/it/panov/musyx/mobile/ui/MusyxApp.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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) {