Tweak extension details screen (#7257)

This commit is contained in:
AntsyLich 2022-06-08 03:47:46 +06:00 committed by GitHub
parent 177a642afc
commit 7a661747c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,6 +45,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import eu.kanade.presentation.browse.components.ExtensionIcon import eu.kanade.presentation.browse.components.ExtensionIcon
import eu.kanade.presentation.components.DIVIDER_ALPHA import eu.kanade.presentation.components.DIVIDER_ALPHA
@ -139,6 +140,7 @@ private fun WarningBanner(@StringRes textRes: Int) {
Text( Text(
text = stringResource(textRes), text = stringResource(textRes),
color = MaterialTheme.colorScheme.onError, color = MaterialTheme.colorScheme.onError,
style = MaterialTheme.typography.bodyMedium,
) )
} }
} }
@ -195,6 +197,7 @@ private fun DetailsHeader(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
) { ) {
InfoText( InfoText(
modifier = Modifier.weight(1f),
primaryText = extension.versionName, primaryText = extension.versionName,
secondaryText = stringResource(R.string.ext_info_version), secondaryText = stringResource(R.string.ext_info_version),
) )
@ -202,6 +205,7 @@ private fun DetailsHeader(
InfoDivider() InfoDivider()
InfoText( InfoText(
modifier = Modifier.weight(if (extension.isNsfw) 1.5f else 1f),
primaryText = LocaleHelper.getSourceDisplayName(extension.lang, context), primaryText = LocaleHelper.getSourceDisplayName(extension.lang, context),
secondaryText = stringResource(R.string.ext_info_language), secondaryText = stringResource(R.string.ext_info_language),
) )
@ -210,6 +214,7 @@ private fun DetailsHeader(
InfoDivider() InfoDivider()
InfoText( InfoText(
modifier = Modifier.weight(1f),
primaryText = stringResource(R.string.ext_nsfw_short), primaryText = stringResource(R.string.ext_nsfw_short),
primaryTextStyle = MaterialTheme.typography.bodyLarge.copy( primaryTextStyle = MaterialTheme.typography.bodyLarge.copy(
color = MaterialTheme.colorScheme.error, color = MaterialTheme.colorScheme.error,
@ -255,6 +260,7 @@ private fun DetailsHeader(
@Composable @Composable
private fun InfoText( private fun InfoText(
modifier: Modifier,
primaryText: String, primaryText: String,
primaryTextStyle: TextStyle = MaterialTheme.typography.bodyLarge, primaryTextStyle: TextStyle = MaterialTheme.typography.bodyLarge,
secondaryText: String, secondaryText: String,
@ -262,22 +268,24 @@ private fun InfoText(
) { ) {
val interactionSource = remember { MutableInteractionSource() } val interactionSource = remember { MutableInteractionSource() }
val modifier = if (onClick != null) { val clickableModifier = if (onClick != null) {
Modifier.clickable(interactionSource, indication = null) { onClick() } Modifier.clickable(interactionSource, indication = null) { onClick() }
} else Modifier } else Modifier
Column( Column(
modifier = modifier, modifier = modifier.then(clickableModifier),
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center, verticalArrangement = Arrangement.Center,
) { ) {
Text( Text(
text = primaryText, text = primaryText,
textAlign = TextAlign.Center,
style = primaryTextStyle, style = primaryTextStyle,
) )
Text( Text(
text = secondaryText + if (onClick != null) "" else "", text = secondaryText + if (onClick != null) "" else "",
textAlign = TextAlign.Center,
style = MaterialTheme.typography.bodyMedium, style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f), color = MaterialTheme.colorScheme.onSurface.copy(alpha = 0.5f),
) )