Use Compose Foundation's flow layout (#9123)

This commit is contained in:
Ivan Iskandar 2023-02-22 00:04:11 +07:00 committed by GitHub
parent bd7b21337c
commit 6b03dca5f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 7 deletions

View file

@ -158,7 +158,6 @@ dependencies {
implementation(compose.ui.tooling) implementation(compose.ui.tooling)
implementation(compose.ui.util) implementation(compose.ui.util)
implementation(compose.accompanist.webview) implementation(compose.accompanist.webview)
implementation(compose.accompanist.flowlayout)
implementation(compose.accompanist.permissions) implementation(compose.accompanist.permissions)
implementation(compose.accompanist.themeadapter) implementation(compose.accompanist.themeadapter)
implementation(compose.accompanist.systemuicontroller) implementation(compose.accompanist.systemuicontroller)

View file

@ -3,8 +3,10 @@ package eu.kanade.presentation.browse
import androidx.annotation.StringRes import androidx.annotation.StringRes
import androidx.compose.animation.core.animateDpAsState import androidx.compose.animation.core.animateDpAsState
import androidx.compose.foundation.combinedClickable import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.RowScope
@ -34,7 +36,6 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.google.accompanist.flowlayout.FlowRow
import eu.kanade.presentation.browse.components.BaseBrowseItem import eu.kanade.presentation.browse.components.BaseBrowseItem
import eu.kanade.presentation.browse.components.ExtensionIcon import eu.kanade.presentation.browse.components.ExtensionIcon
import eu.kanade.presentation.manga.components.DotSeparatorNoSpaceText import eu.kanade.presentation.manga.components.DotSeparatorNoSpaceText
@ -287,7 +288,7 @@ private fun ExtensionItemContent(
// Won't look good but it's not like we can ellipsize overflowing content // Won't look good but it's not like we can ellipsize overflowing content
FlowRow( FlowRow(
modifier = Modifier.secondaryItemAlpha(), modifier = Modifier.secondaryItemAlpha(),
mainAxisSpacing = 4.dp, horizontalArrangement = Arrangement.spacedBy(4.dp),
) { ) {
ProvideTextStyle(value = MaterialTheme.typography.bodySmall) { ProvideTextStyle(value = MaterialTheme.typography.bodySmall) {
if (extension is Extension.Installed && extension.lang.isNotEmpty()) { if (extension is Extension.Installed && extension.lang.isNotEmpty()) {

View file

@ -10,6 +10,7 @@ import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.RowScope
@ -72,7 +73,6 @@ import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage import coil.compose.AsyncImage
import com.google.accompanist.flowlayout.FlowRow
import eu.kanade.presentation.components.DropdownMenu import eu.kanade.presentation.components.DropdownMenu
import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.model.SManga import eu.kanade.tachiyomi.source.model.SManga
@ -266,11 +266,11 @@ fun ExpandableMangaDescription(
if (expanded) { if (expanded) {
FlowRow( FlowRow(
modifier = Modifier.padding(horizontal = 16.dp), modifier = Modifier.padding(horizontal = 16.dp),
mainAxisSpacing = 4.dp, horizontalArrangement = Arrangement.spacedBy(4.dp),
crossAxisSpacing = 8.dp,
) { ) {
tags.forEach { tags.forEach {
TagsChip( TagsChip(
modifier = Modifier.padding(vertical = 4.dp),
text = it, text = it,
onClick = { onClick = {
tagSelected = it tagSelected = it
@ -286,6 +286,7 @@ fun ExpandableMangaDescription(
) { ) {
items(items = tags) { items(items = tags) {
TagsChip( TagsChip(
modifier = Modifier.padding(vertical = 4.dp),
text = it, text = it,
onClick = { onClick = {
tagSelected = it tagSelected = it
@ -640,10 +641,12 @@ private fun MangaSummary(
@Composable @Composable
private fun TagsChip( private fun TagsChip(
text: String, text: String,
modifier: Modifier = Modifier,
onClick: () -> Unit, onClick: () -> Unit,
) { ) {
CompositionLocalProvider(LocalMinimumInteractiveComponentEnforcement provides false) { CompositionLocalProvider(LocalMinimumInteractiveComponentEnforcement provides false) {
SuggestionChip( SuggestionChip(
modifier = modifier,
onClick = onClick, onClick = onClick,
label = { Text(text = text, style = MaterialTheme.typography.bodySmall) }, label = { Text(text = text, style = MaterialTheme.typography.bodySmall) },
border = null, border = null,

View file

@ -19,7 +19,6 @@ material-icons = { module = "androidx.compose.material:material-icons-extended"
material-core = { module = "androidx.compose.material:material" } material-core = { module = "androidx.compose.material:material" }
accompanist-webview = { module = "com.google.accompanist:accompanist-webview", version.ref = "accompanist" } accompanist-webview = { module = "com.google.accompanist:accompanist-webview", version.ref = "accompanist" }
accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayout", version.ref = "accompanist" }
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" } accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" }
accompanist-themeadapter = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" } accompanist-themeadapter = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" }
accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" } accompanist-systemuicontroller = { module = "com.google.accompanist:accompanist-systemuicontroller", version.ref = "accompanist" }