Combining manga information into a function (#10093)
* Combining manga information into a function * clean space * indexes * context * clean * textAlign for Tablet Mode
This commit is contained in:
parent
8a1625ec79
commit
d862d83511
1 changed files with 148 additions and 212 deletions
|
@ -1,6 +1,5 @@
|
||||||
package eu.kanade.presentation.manga.components
|
package eu.kanade.presentation.manga.components
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import androidx.compose.animation.animateContentSize
|
import androidx.compose.animation.animateContentSize
|
||||||
import androidx.compose.animation.core.animateFloatAsState
|
import androidx.compose.animation.core.animateFloatAsState
|
||||||
import androidx.compose.animation.graphics.res.animatedVectorResource
|
import androidx.compose.animation.graphics.res.animatedVectorResource
|
||||||
|
@ -43,6 +42,7 @@ import androidx.compose.material3.DropdownMenuItem
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.LocalContentColor
|
import androidx.compose.material3.LocalContentColor
|
||||||
import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement
|
import androidx.compose.material3.LocalMinimumInteractiveComponentEnforcement
|
||||||
|
import androidx.compose.material3.LocalTextStyle
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.ProvideTextStyle
|
import androidx.compose.material3.ProvideTextStyle
|
||||||
import androidx.compose.material3.SuggestionChip
|
import androidx.compose.material3.SuggestionChip
|
||||||
|
@ -134,7 +134,6 @@ fun MangaInfoBox(
|
||||||
coverDataProvider = coverDataProvider,
|
coverDataProvider = coverDataProvider,
|
||||||
onCoverClick = onCoverClick,
|
onCoverClick = onCoverClick,
|
||||||
title = title,
|
title = title,
|
||||||
context = LocalContext.current,
|
|
||||||
doSearch = doSearch,
|
doSearch = doSearch,
|
||||||
author = author,
|
author = author,
|
||||||
artist = artist,
|
artist = artist,
|
||||||
|
@ -148,7 +147,6 @@ fun MangaInfoBox(
|
||||||
coverDataProvider = coverDataProvider,
|
coverDataProvider = coverDataProvider,
|
||||||
onCoverClick = onCoverClick,
|
onCoverClick = onCoverClick,
|
||||||
title = title,
|
title = title,
|
||||||
context = LocalContext.current,
|
|
||||||
doSearch = doSearch,
|
doSearch = doSearch,
|
||||||
author = author,
|
author = author,
|
||||||
artist = artist,
|
artist = artist,
|
||||||
|
@ -323,7 +321,6 @@ private fun MangaAndSourceTitlesLarge(
|
||||||
coverDataProvider: () -> Manga,
|
coverDataProvider: () -> Manga,
|
||||||
onCoverClick: () -> Unit,
|
onCoverClick: () -> Unit,
|
||||||
title: String,
|
title: String,
|
||||||
context: Context,
|
|
||||||
doSearch: (query: String, global: Boolean) -> Unit,
|
doSearch: (query: String, global: Boolean) -> Unit,
|
||||||
author: String?,
|
author: String?,
|
||||||
artist: String?,
|
artist: String?,
|
||||||
|
@ -344,102 +341,16 @@ private fun MangaAndSourceTitlesLarge(
|
||||||
onClick = onCoverClick,
|
onClick = onCoverClick,
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(16.dp))
|
Spacer(modifier = Modifier.height(16.dp))
|
||||||
Text(
|
MangaContentInfo(
|
||||||
text = title.ifBlank { stringResource(R.string.unknown_title) },
|
title = title,
|
||||||
style = MaterialTheme.typography.titleLarge,
|
doSearch = doSearch,
|
||||||
modifier = Modifier.clickableNoIndication(
|
author = author,
|
||||||
onLongClick = { if (title.isNotBlank()) context.copyToClipboard(title, title) },
|
artist = artist,
|
||||||
onClick = { if (title.isNotBlank()) doSearch(title, true) },
|
status = status,
|
||||||
),
|
sourceName = sourceName,
|
||||||
|
isStubSource = isStubSource,
|
||||||
textAlign = TextAlign.Center,
|
textAlign = TextAlign.Center,
|
||||||
)
|
)
|
||||||
Spacer(modifier = Modifier.height(2.dp))
|
|
||||||
Text(
|
|
||||||
text = author?.takeIf { it.isNotBlank() } ?: stringResource(R.string.unknown_author),
|
|
||||||
style = MaterialTheme.typography.titleSmall,
|
|
||||||
modifier = Modifier
|
|
||||||
.secondaryItemAlpha()
|
|
||||||
.padding(top = 2.dp)
|
|
||||||
.clickableNoIndication(
|
|
||||||
onLongClick = {
|
|
||||||
if (!author.isNullOrBlank()) {
|
|
||||||
context.copyToClipboard(
|
|
||||||
author,
|
|
||||||
author,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onClick = { if (!author.isNullOrBlank()) doSearch(author, true) },
|
|
||||||
),
|
|
||||||
textAlign = TextAlign.Center,
|
|
||||||
)
|
|
||||||
if (!artist.isNullOrBlank() && author != artist) {
|
|
||||||
Text(
|
|
||||||
text = artist,
|
|
||||||
style = MaterialTheme.typography.titleSmall,
|
|
||||||
modifier = Modifier
|
|
||||||
.secondaryItemAlpha()
|
|
||||||
.padding(top = 2.dp)
|
|
||||||
.clickableNoIndication(
|
|
||||||
onLongClick = { context.copyToClipboard(artist, artist) },
|
|
||||||
onClick = { doSearch(artist, true) },
|
|
||||||
),
|
|
||||||
textAlign = TextAlign.Center,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Spacer(modifier = Modifier.height(4.dp))
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.secondaryItemAlpha(),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = when (status) {
|
|
||||||
SManga.ONGOING.toLong() -> Icons.Outlined.Schedule
|
|
||||||
SManga.COMPLETED.toLong() -> Icons.Outlined.DoneAll
|
|
||||||
SManga.LICENSED.toLong() -> Icons.Outlined.AttachMoney
|
|
||||||
SManga.PUBLISHING_FINISHED.toLong() -> Icons.Outlined.Done
|
|
||||||
SManga.CANCELLED.toLong() -> Icons.Outlined.Close
|
|
||||||
SManga.ON_HIATUS.toLong() -> Icons.Outlined.Pause
|
|
||||||
else -> Icons.Outlined.Block
|
|
||||||
},
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(end = 4.dp)
|
|
||||||
.size(16.dp),
|
|
||||||
)
|
|
||||||
ProvideTextStyle(MaterialTheme.typography.bodyMedium) {
|
|
||||||
Text(
|
|
||||||
text = when (status) {
|
|
||||||
SManga.ONGOING.toLong() -> stringResource(R.string.ongoing)
|
|
||||||
SManga.COMPLETED.toLong() -> stringResource(R.string.completed)
|
|
||||||
SManga.LICENSED.toLong() -> stringResource(R.string.licensed)
|
|
||||||
SManga.PUBLISHING_FINISHED.toLong() -> stringResource(R.string.publishing_finished)
|
|
||||||
SManga.CANCELLED.toLong() -> stringResource(R.string.cancelled)
|
|
||||||
SManga.ON_HIATUS.toLong() -> stringResource(R.string.on_hiatus)
|
|
||||||
else -> stringResource(R.string.unknown)
|
|
||||||
},
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 1,
|
|
||||||
)
|
|
||||||
DotSeparatorText()
|
|
||||||
if (isStubSource) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.Warning,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(end = 4.dp)
|
|
||||||
.size(16.dp),
|
|
||||||
tint = MaterialTheme.colorScheme.error,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Text(
|
|
||||||
text = sourceName,
|
|
||||||
modifier = Modifier.clickableNoIndication { doSearch(sourceName, false) },
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 1,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +360,6 @@ private fun MangaAndSourceTitlesSmall(
|
||||||
coverDataProvider: () -> Manga,
|
coverDataProvider: () -> Manga,
|
||||||
onCoverClick: () -> Unit,
|
onCoverClick: () -> Unit,
|
||||||
title: String,
|
title: String,
|
||||||
context: Context,
|
|
||||||
doSearch: (query: String, global: Boolean) -> Unit,
|
doSearch: (query: String, global: Boolean) -> Unit,
|
||||||
author: String?,
|
author: String?,
|
||||||
artist: String?,
|
artist: String?,
|
||||||
|
@ -475,135 +385,161 @@ private fun MangaAndSourceTitlesSmall(
|
||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(2.dp),
|
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||||
) {
|
) {
|
||||||
Text(
|
MangaContentInfo(
|
||||||
text = title.ifBlank { stringResource(R.string.unknown_title) },
|
title = title,
|
||||||
style = MaterialTheme.typography.titleLarge,
|
doSearch = doSearch,
|
||||||
modifier = Modifier.clickableNoIndication(
|
author = author,
|
||||||
|
artist = artist,
|
||||||
|
status = status,
|
||||||
|
sourceName = sourceName,
|
||||||
|
isStubSource = isStubSource,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun MangaContentInfo(
|
||||||
|
title: String,
|
||||||
|
textAlign: TextAlign? = LocalTextStyle.current.textAlign,
|
||||||
|
doSearch: (query: String, global: Boolean) -> Unit,
|
||||||
|
author: String?,
|
||||||
|
artist: String?,
|
||||||
|
status: Long,
|
||||||
|
sourceName: String,
|
||||||
|
isStubSource: Boolean,
|
||||||
|
) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
Text(
|
||||||
|
text = title.ifBlank { stringResource(R.string.unknown_title) },
|
||||||
|
style = MaterialTheme.typography.titleLarge,
|
||||||
|
modifier = Modifier.clickableNoIndication(
|
||||||
|
onLongClick = {
|
||||||
|
if (title.isNotBlank()) {
|
||||||
|
context.copyToClipboard(
|
||||||
|
title,
|
||||||
|
title,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onClick = { if (title.isNotBlank()) doSearch(title, true) },
|
||||||
|
),
|
||||||
|
textAlign = textAlign,
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(2.dp))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.secondaryItemAlpha(),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Filled.PersonOutline,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(16.dp),
|
||||||
|
)
|
||||||
|
Text(
|
||||||
|
text = author?.takeIf { it.isNotBlank() }
|
||||||
|
?: stringResource(R.string.unknown_author),
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
modifier = Modifier
|
||||||
|
.clickableNoIndication(
|
||||||
onLongClick = {
|
onLongClick = {
|
||||||
if (title.isNotBlank()) {
|
if (!author.isNullOrBlank()) {
|
||||||
context.copyToClipboard(
|
context.copyToClipboard(
|
||||||
title,
|
author,
|
||||||
title,
|
author,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onClick = { if (title.isNotBlank()) doSearch(title, true) },
|
onClick = { if (!author.isNullOrBlank()) doSearch(author, true) },
|
||||||
),
|
),
|
||||||
|
textAlign = textAlign,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!artist.isNullOrBlank() && author != artist) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.secondaryItemAlpha(),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Filled.Brush,
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.size(16.dp),
|
||||||
)
|
)
|
||||||
|
Text(
|
||||||
|
text = artist,
|
||||||
|
style = MaterialTheme.typography.titleSmall,
|
||||||
|
modifier = Modifier
|
||||||
|
.clickableNoIndication(
|
||||||
|
onLongClick = { context.copyToClipboard(artist, artist) },
|
||||||
|
onClick = { doSearch(artist, true) },
|
||||||
|
),
|
||||||
|
textAlign = textAlign,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(2.dp))
|
Spacer(modifier = Modifier.height(2.dp))
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.secondaryItemAlpha(),
|
modifier = Modifier.secondaryItemAlpha(),
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
) {
|
||||||
) {
|
Icon(
|
||||||
|
imageVector = when (status) {
|
||||||
|
SManga.ONGOING.toLong() -> Icons.Outlined.Schedule
|
||||||
|
SManga.COMPLETED.toLong() -> Icons.Outlined.DoneAll
|
||||||
|
SManga.LICENSED.toLong() -> Icons.Outlined.AttachMoney
|
||||||
|
SManga.PUBLISHING_FINISHED.toLong() -> Icons.Outlined.Done
|
||||||
|
SManga.CANCELLED.toLong() -> Icons.Outlined.Close
|
||||||
|
SManga.ON_HIATUS.toLong() -> Icons.Outlined.Pause
|
||||||
|
else -> Icons.Outlined.Block
|
||||||
|
},
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(end = 4.dp)
|
||||||
|
.size(16.dp),
|
||||||
|
)
|
||||||
|
ProvideTextStyle(MaterialTheme.typography.bodyMedium) {
|
||||||
|
Text(
|
||||||
|
text = when (status) {
|
||||||
|
SManga.ONGOING.toLong() -> stringResource(R.string.ongoing)
|
||||||
|
SManga.COMPLETED.toLong() -> stringResource(R.string.completed)
|
||||||
|
SManga.LICENSED.toLong() -> stringResource(R.string.licensed)
|
||||||
|
SManga.PUBLISHING_FINISHED.toLong() -> stringResource(R.string.publishing_finished)
|
||||||
|
SManga.CANCELLED.toLong() -> stringResource(R.string.cancelled)
|
||||||
|
SManga.ON_HIATUS.toLong() -> stringResource(R.string.on_hiatus)
|
||||||
|
else -> stringResource(R.string.unknown)
|
||||||
|
},
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
|
DotSeparatorText()
|
||||||
|
if (isStubSource) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Filled.PersonOutline,
|
imageVector = Icons.Filled.Warning,
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(16.dp),
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = author?.takeIf { it.isNotBlank() }
|
|
||||||
?: stringResource(R.string.unknown_author),
|
|
||||||
style = MaterialTheme.typography.titleSmall,
|
|
||||||
modifier = Modifier
|
|
||||||
.clickableNoIndication(
|
|
||||||
onLongClick = {
|
|
||||||
if (!author.isNullOrBlank()) {
|
|
||||||
context.copyToClipboard(
|
|
||||||
author,
|
|
||||||
author,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onClick = { if (!author.isNullOrBlank()) doSearch(author, true) },
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!artist.isNullOrBlank() && author != artist) {
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.secondaryItemAlpha(),
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.Brush,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier.size(16.dp),
|
|
||||||
)
|
|
||||||
Text(
|
|
||||||
text = artist,
|
|
||||||
style = MaterialTheme.typography.titleSmall,
|
|
||||||
modifier = Modifier
|
|
||||||
.clickableNoIndication(
|
|
||||||
onLongClick = { context.copyToClipboard(artist, artist) },
|
|
||||||
onClick = { doSearch(artist, true) },
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(2.dp))
|
|
||||||
|
|
||||||
Row(
|
|
||||||
modifier = Modifier.secondaryItemAlpha(),
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = when (status) {
|
|
||||||
SManga.ONGOING.toLong() -> Icons.Outlined.Schedule
|
|
||||||
SManga.COMPLETED.toLong() -> Icons.Outlined.DoneAll
|
|
||||||
SManga.LICENSED.toLong() -> Icons.Outlined.AttachMoney
|
|
||||||
SManga.PUBLISHING_FINISHED.toLong() -> Icons.Outlined.Done
|
|
||||||
SManga.CANCELLED.toLong() -> Icons.Outlined.Close
|
|
||||||
SManga.ON_HIATUS.toLong() -> Icons.Outlined.Pause
|
|
||||||
else -> Icons.Outlined.Block
|
|
||||||
},
|
|
||||||
contentDescription = null,
|
contentDescription = null,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(end = 4.dp)
|
.padding(end = 4.dp)
|
||||||
.size(16.dp),
|
.size(16.dp),
|
||||||
|
tint = MaterialTheme.colorScheme.error,
|
||||||
)
|
)
|
||||||
ProvideTextStyle(MaterialTheme.typography.bodyMedium) {
|
|
||||||
Text(
|
|
||||||
text = when (status) {
|
|
||||||
SManga.ONGOING.toLong() -> stringResource(R.string.ongoing)
|
|
||||||
SManga.COMPLETED.toLong() -> stringResource(R.string.completed)
|
|
||||||
SManga.LICENSED.toLong() -> stringResource(R.string.licensed)
|
|
||||||
SManga.PUBLISHING_FINISHED.toLong() -> stringResource(R.string.publishing_finished)
|
|
||||||
SManga.CANCELLED.toLong() -> stringResource(R.string.cancelled)
|
|
||||||
SManga.ON_HIATUS.toLong() -> stringResource(R.string.on_hiatus)
|
|
||||||
else -> stringResource(R.string.unknown)
|
|
||||||
},
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 1,
|
|
||||||
)
|
|
||||||
DotSeparatorText()
|
|
||||||
if (isStubSource) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Filled.Warning,
|
|
||||||
contentDescription = null,
|
|
||||||
modifier = Modifier
|
|
||||||
.padding(end = 4.dp)
|
|
||||||
.size(16.dp),
|
|
||||||
tint = MaterialTheme.colorScheme.error,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
Text(
|
|
||||||
text = sourceName,
|
|
||||||
modifier = Modifier.clickableNoIndication {
|
|
||||||
doSearch(
|
|
||||||
sourceName,
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
},
|
|
||||||
overflow = TextOverflow.Ellipsis,
|
|
||||||
maxLines = 1,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Text(
|
||||||
|
text = sourceName,
|
||||||
|
modifier = Modifier.clickableNoIndication {
|
||||||
|
doSearch(
|
||||||
|
sourceName,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
maxLines = 1,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue