mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 04:31:50 +01:00
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,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,6 +385,31 @@ private fun MangaAndSourceTitlesSmall(
|
|||||||
Column(
|
Column(
|
||||||
verticalArrangement = Arrangement.spacedBy(2.dp),
|
verticalArrangement = Arrangement.spacedBy(2.dp),
|
||||||
) {
|
) {
|
||||||
|
MangaContentInfo(
|
||||||
|
title = title,
|
||||||
|
doSearch = doSearch,
|
||||||
|
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(
|
||||||
text = title.ifBlank { stringResource(R.string.unknown_title) },
|
text = title.ifBlank { stringResource(R.string.unknown_title) },
|
||||||
style = MaterialTheme.typography.titleLarge,
|
style = MaterialTheme.typography.titleLarge,
|
||||||
@ -489,6 +424,7 @@ private fun MangaAndSourceTitlesSmall(
|
|||||||
},
|
},
|
||||||
onClick = { if (title.isNotBlank()) doSearch(title, true) },
|
onClick = { if (title.isNotBlank()) doSearch(title, true) },
|
||||||
),
|
),
|
||||||
|
textAlign = textAlign,
|
||||||
)
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(2.dp))
|
Spacer(modifier = Modifier.height(2.dp))
|
||||||
@ -519,6 +455,7 @@ private fun MangaAndSourceTitlesSmall(
|
|||||||
},
|
},
|
||||||
onClick = { if (!author.isNullOrBlank()) doSearch(author, true) },
|
onClick = { if (!author.isNullOrBlank()) doSearch(author, true) },
|
||||||
),
|
),
|
||||||
|
textAlign = textAlign,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -541,6 +478,7 @@ private fun MangaAndSourceTitlesSmall(
|
|||||||
onLongClick = { context.copyToClipboard(artist, artist) },
|
onLongClick = { context.copyToClipboard(artist, artist) },
|
||||||
onClick = { doSearch(artist, true) },
|
onClick = { doSearch(artist, true) },
|
||||||
),
|
),
|
||||||
|
textAlign = textAlign,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -604,8 +542,6 @@ private fun MangaAndSourceTitlesSmall(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
Loading…
Reference in New Issue
Block a user