Consolidate badge components

(cherry picked from commit 2096df301d55ed446db21d0d2881e9d273674fae)

# Conflicts:
#	app/src/main/java/eu/kanade/presentation/browse/MigrateSourceScreen.kt
#	app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaPresenter.kt
This commit is contained in:
arkon 2022-07-16 17:40:40 -04:00 committed by Jobobby04
parent af83f81034
commit 97e9218f75
5 changed files with 16 additions and 41 deletions

View File

@ -13,7 +13,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
@ -25,8 +24,9 @@ import androidx.compose.ui.unit.dp
import eu.kanade.domain.source.model.Source
import eu.kanade.presentation.browse.components.BaseSourceItem
import eu.kanade.presentation.browse.components.SourceIcon
import eu.kanade.presentation.components.Badge
import eu.kanade.presentation.components.BadgeGroup
import eu.kanade.presentation.components.EmptyScreen
import eu.kanade.presentation.components.ItemBadges
import eu.kanade.presentation.components.LoadingScreen
import eu.kanade.presentation.components.ScrollbarLazyColumn
import eu.kanade.presentation.theme.header
@ -130,7 +130,9 @@ fun MigrateSourceItem(
onLongClickItem = onLongClickItem,
icon = { SourceIcon(source = source) },
action = {
ItemBadges(primaryText = "$count")
BadgeGroup {
Badge(text = "$count")
}
// SY -->
TextButton(onClick = onClickAll) {
Text(

View File

@ -1,4 +1,4 @@
package eu.kanade.presentation.library.components
package eu.kanade.presentation.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@ -14,6 +15,7 @@ import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
@Composable
@ -42,7 +44,10 @@ fun Badge(
Text(
text = text,
modifier = Modifier.padding(horizontal = 4.dp, vertical = 2.dp),
style = LocalTextStyle.current.copy(
color = textColor,
fontWeight = FontWeight.Medium,
),
)
}
}

View File

@ -1,36 +0,0 @@
package eu.kanade.presentation.components
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
@Composable
fun ItemBadges(
modifier: Modifier = Modifier,
primaryText: String,
) {
Row(
modifier = modifier.clip(RoundedCornerShape(4.dp)),
) {
Text(
text = primaryText,
modifier = Modifier
.background(MaterialTheme.colorScheme.primary)
.padding(horizontal = 4.dp, vertical = 2.dp),
style = MaterialTheme.typography.bodyMedium.copy(
color = MaterialTheme.colorScheme.onPrimary,
fontWeight = FontWeight.Medium,
),
)
// TODO: support more badges (e.g., for library items)
}
}

View File

@ -12,6 +12,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.components.Badge
import eu.kanade.presentation.components.BadgeGroup
import eu.kanade.presentation.components.MangaCover
import eu.kanade.tachiyomi.R

View File

@ -18,6 +18,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import eu.kanade.domain.manga.model.MangaCover
import eu.kanade.presentation.components.Badge
import eu.kanade.presentation.components.BadgeGroup
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.selectedBackground
import eu.kanade.presentation.util.verticalPadding