From b3d7c9247530c0522033b4a9130d252bcbf50163 Mon Sep 17 00:00:00 2001 From: Eshlender <35057681+e-shl@users.noreply.github.com> Date: Thu, 2 Nov 2023 07:17:17 +0500 Subject: [PATCH] Text on tabs Overflow Ellipsis (#10095) * Update TabbedDialog to TabbedScreen * clean --- .../presentation/components/TabbedDialog.kt | 21 ++++++------------- .../core/components/material/Tabs.kt | 7 ++++++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt index 675f353604..20e3640c92 100644 --- a/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt +++ b/app/src/main/java/eu/kanade/presentation/components/TabbedDialog.kt @@ -16,7 +16,6 @@ import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Tab import androidx.compose.material3.TabRow -import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf @@ -32,6 +31,7 @@ import eu.kanade.tachiyomi.R import kotlinx.coroutines.launch import tachiyomi.presentation.core.components.HorizontalPager import tachiyomi.presentation.core.components.material.TabIndicator +import tachiyomi.presentation.core.components.material.TabText object TabbedDialogPaddings { val Horizontal = 24.dp @@ -61,21 +61,12 @@ fun TabbedDialog( indicator = { TabIndicator(it[pagerState.currentPage], pagerState.currentPageOffsetFraction) }, divider = {}, ) { - tabTitles.fastForEachIndexed { i, tab -> - val selected = pagerState.currentPage == i + tabTitles.fastForEachIndexed { index, tab -> Tab( - selected = selected, - onClick = { scope.launch { pagerState.animateScrollToPage(i) } }, - text = { - Text( - text = tab, - color = if (selected) { - MaterialTheme.colorScheme.primary - } else { - MaterialTheme.colorScheme.onSurfaceVariant - }, - ) - }, + selected = pagerState.currentPage == index, + onClick = { scope.launch { pagerState.animateScrollToPage(index) } }, + text = { TabText(text = tab) }, + unselectedContentColor = MaterialTheme.colorScheme.onSurface, ) } } diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/Tabs.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/Tabs.kt index 66e44ca242..0770d577a3 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/Tabs.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/material/Tabs.kt @@ -21,6 +21,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.composed import androidx.compose.ui.draw.clip +import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.IntOffset import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -62,7 +63,11 @@ fun TabText(text: String, badgeCount: Int? = null) { Row( verticalAlignment = Alignment.CenterVertically, ) { - Text(text = text) + Text( + text = text, + maxLines = 1, + overflow = TextOverflow.Ellipsis, + ) if (badgeCount != null) { Pill( text = "$badgeCount",