Make padding names neutral (#8531)

This commit is contained in:
Andreas 2022-11-13 18:11:51 +01:00 committed by GitHub
parent 6017229d1b
commit 3407eb84c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 81 additions and 68 deletions

View File

@ -23,7 +23,6 @@ import androidx.compose.material.icons.outlined.History
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Button
import androidx.compose.material3.Divider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
@ -57,7 +56,7 @@ import eu.kanade.presentation.components.ScrollbarLazyColumn
import eu.kanade.presentation.components.WarningBanner
import eu.kanade.presentation.more.settings.widget.TextPreferenceWidget
import eu.kanade.presentation.more.settings.widget.TrailingWidgetBuffer
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.source.ConfigurableSource
@ -208,10 +207,10 @@ private fun DetailsHeader(
modifier = Modifier
.fillMaxWidth()
.padding(
start = horizontalPadding,
end = horizontalPadding,
top = 16.dp,
bottom = 8.dp,
start = MaterialTheme.padding.medium,
end = MaterialTheme.padding.medium,
top = MaterialTheme.padding.medium,
bottom = MaterialTheme.padding.small,
),
horizontalAlignment = Alignment.CenterHorizontally,
) {
@ -240,8 +239,8 @@ private fun DetailsHeader(
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = horizontalPadding * 2,
vertical = 8.dp,
horizontal = MaterialTheme.padding.extraLarge,
vertical = MaterialTheme.padding.small,
),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
@ -278,10 +277,10 @@ private fun DetailsHeader(
Row(
modifier = Modifier.padding(
start = horizontalPadding,
end = horizontalPadding,
top = 8.dp,
bottom = 16.dp,
start = MaterialTheme.padding.medium,
end = MaterialTheme.padding.medium,
top = MaterialTheme.padding.small,
bottom = MaterialTheme.padding.medium,
),
) {
OutlinedButton(

View File

@ -43,10 +43,10 @@ import eu.kanade.presentation.components.LoadingScreen
import eu.kanade.presentation.components.SwipeRefresh
import eu.kanade.presentation.manga.components.DotSeparatorNoSpaceText
import eu.kanade.presentation.theme.header
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.presentation.util.plus
import eu.kanade.presentation.util.secondaryItemAlpha
import eu.kanade.presentation.util.topPaddingValues
import eu.kanade.presentation.util.topSmallPaddingValues
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.extension.model.Extension
import eu.kanade.tachiyomi.extension.model.InstallStep
@ -113,7 +113,7 @@ private fun ExtensionContent(
var trustState by remember { mutableStateOf<Extension.Untrusted?>(null) }
FastScrollLazyColumn(
contentPadding = contentPadding + topPaddingValues,
contentPadding = contentPadding + topSmallPaddingValues,
) {
items(
items = state.items,
@ -272,7 +272,7 @@ private fun ExtensionItemContent(
modifier: Modifier = Modifier,
) {
Column(
modifier = modifier.padding(start = horizontalPadding),
modifier = modifier.padding(start = MaterialTheme.padding.medium),
) {
Text(
text = extension.name,
@ -396,7 +396,7 @@ private fun ExtensionHeader(
action: @Composable RowScope.() -> Unit = {},
) {
Row(
modifier = modifier.padding(horizontal = horizontalPadding),
modifier = modifier.padding(horizontal = MaterialTheme.padding.medium),
verticalAlignment = Alignment.CenterVertically,
) {
Text(

View File

@ -34,10 +34,10 @@ import eu.kanade.presentation.components.LoadingScreen
import eu.kanade.presentation.components.ScrollbarLazyColumn
import eu.kanade.presentation.components.Scroller.STICKY_HEADER_KEY_PREFIX
import eu.kanade.presentation.theme.header
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.presentation.util.plus
import eu.kanade.presentation.util.secondaryItemAlpha
import eu.kanade.presentation.util.topPaddingValues
import eu.kanade.presentation.util.topSmallPaddingValues
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrationSourcesPresenter
import eu.kanade.tachiyomi.util.system.copyToClipboard
@ -84,13 +84,13 @@ private fun MigrateSourceList(
onToggleSortingDirection: () -> Unit,
) {
ScrollbarLazyColumn(
contentPadding = contentPadding + topPaddingValues,
contentPadding = contentPadding + topSmallPaddingValues,
) {
stickyHeader(key = STICKY_HEADER_KEY_PREFIX) {
Row(
modifier = Modifier
.background(MaterialTheme.colorScheme.background)
.padding(start = horizontalPadding),
.padding(start = MaterialTheme.padding.medium),
verticalAlignment = Alignment.CenterVertically,
) {
Text(
@ -152,7 +152,7 @@ private fun MigrateSourceItem(
content = { _, sourceLangString ->
Column(
modifier = Modifier
.padding(horizontal = horizontalPadding)
.padding(horizontal = MaterialTheme.padding.medium)
.weight(1f),
) {
Text(

View File

@ -30,9 +30,9 @@ import eu.kanade.presentation.components.EmptyScreen
import eu.kanade.presentation.components.LoadingScreen
import eu.kanade.presentation.components.ScrollbarLazyColumn
import eu.kanade.presentation.theme.header
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.presentation.util.plus
import eu.kanade.presentation.util.topPaddingValues
import eu.kanade.presentation.util.topSmallPaddingValues
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.source.LocalSource
import eu.kanade.tachiyomi.ui.browse.source.SourcesPresenter
@ -85,7 +85,7 @@ private fun SourceList(
onClickPin: (Source) -> Unit,
) {
ScrollbarLazyColumn(
contentPadding = contentPadding + topPaddingValues,
contentPadding = contentPadding + topSmallPaddingValues,
) {
items(
items = state.items,
@ -146,7 +146,7 @@ private fun SourceHeader(
Text(
text = LocaleHelper.getSourceDisplayName(language, context),
modifier = modifier
.padding(horizontal = horizontalPadding, vertical = 8.dp),
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
style = MaterialTheme.typography.header,
)
}

View File

@ -4,11 +4,11 @@ import androidx.compose.foundation.combinedClickable
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
@Composable
fun BaseBrowseItem(
@ -25,7 +25,7 @@ fun BaseBrowseItem(
onClick = onClickItem,
onLongClick = onLongClickItem,
)
.padding(horizontal = horizontalPadding, vertical = 8.dp),
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
verticalAlignment = Alignment.CenterVertically,
) {
icon()

View File

@ -10,7 +10,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextOverflow
import eu.kanade.domain.source.model.Source
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.presentation.util.secondaryItemAlpha
import eu.kanade.tachiyomi.util.system.LocaleHelper
@ -43,7 +43,7 @@ private val defaultIcon: @Composable RowScope.(Source) -> Unit = { source ->
private val defaultContent: @Composable RowScope.(Source, String?) -> Unit = { source, sourceLangString ->
Column(
modifier = Modifier
.padding(horizontal = horizontalPadding)
.padding(horizontal = MaterialTheme.padding.medium)
.weight(1f),
) {
Text(

View File

@ -3,6 +3,7 @@ package eu.kanade.presentation.category
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
@ -12,9 +13,9 @@ import eu.kanade.presentation.category.components.CategoryFloatingActionButton
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.EmptyScreen
import eu.kanade.presentation.components.Scaffold
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.presentation.util.plus
import eu.kanade.presentation.util.topPaddingValues
import eu.kanade.presentation.util.topSmallPaddingValues
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.ui.category.CategoryScreenState
@ -55,7 +56,7 @@ fun CategoryScreen(
CategoryContent(
categories = state.categories,
lazyListState = lazyListState,
paddingValues = paddingValues + topPaddingValues + PaddingValues(horizontal = horizontalPadding),
paddingValues = paddingValues + topSmallPaddingValues + PaddingValues(horizontal = MaterialTheme.padding.medium),
onClickRename = onClickRename,
onClickDelete = onClickDelete,
onMoveUp = onClickMoveUp,

View File

@ -14,13 +14,14 @@ import androidx.compose.material.icons.outlined.Label
import androidx.compose.material3.ElevatedCard
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import eu.kanade.domain.category.model.Category
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.tachiyomi.R
@Composable
@ -41,14 +42,18 @@ fun CategoryListItem(
modifier = Modifier
.fillMaxWidth()
.clickable { onRename() }
.padding(start = horizontalPadding, top = horizontalPadding, end = horizontalPadding),
.padding(
start = MaterialTheme.padding.medium,
top = MaterialTheme.padding.medium,
end = MaterialTheme.padding.medium,
),
verticalAlignment = Alignment.CenterVertically,
) {
Icon(imageVector = Icons.Outlined.Label, contentDescription = "")
Text(
text = category.name,
modifier = Modifier
.padding(start = horizontalPadding),
.padding(start = MaterialTheme.padding.medium),
)
}
Row {

View File

@ -10,6 +10,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.AlertDialog
import androidx.compose.material3.Checkbox
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TriStateCheckbox
import androidx.compose.runtime.Composable
@ -23,7 +24,7 @@ import androidx.compose.ui.res.stringResource
import eu.kanade.core.prefs.CheckboxState
import eu.kanade.domain.category.model.Category
import eu.kanade.presentation.category.visualName
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.tachiyomi.R
@Composable
@ -123,7 +124,7 @@ fun ChangeCategoryDialog(
Text(
text = checkbox.value.visualName,
modifier = Modifier.padding(horizontal = horizontalPadding),
modifier = Modifier.padding(horizontal = MaterialTheme.padding.medium),
)
}
}

View File

@ -8,8 +8,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.tachiyomi.util.lang.toRelativeString
import java.text.DateFormat
import java.util.Date
@ -24,7 +23,7 @@ fun RelativeDateHeader(
val context = LocalContext.current
Text(
modifier = modifier
.padding(horizontal = horizontalPadding, vertical = 8.dp),
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
text = remember {
date.toRelativeString(
context,

View File

@ -32,8 +32,7 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.verticalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.CrashLogUtil
import kotlinx.coroutines.launch
@ -62,8 +61,8 @@ fun CrashScreen(
)
}
.padding(WindowInsets.navigationBars.asPaddingValues())
.padding(horizontal = horizontalPadding, vertical = verticalPadding),
verticalArrangement = Arrangement.spacedBy(verticalPadding),
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
verticalArrangement = Arrangement.spacedBy(MaterialTheme.padding.small),
) {
Button(
onClick = {
@ -89,7 +88,7 @@ fun CrashScreen(
.verticalScroll(rememberScrollState())
.padding(paddingValues)
.padding(top = 56.dp)
.padding(horizontal = horizontalPadding),
.padding(horizontal = MaterialTheme.padding.medium),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Icon(
@ -105,11 +104,11 @@ fun CrashScreen(
Text(
text = stringResource(R.string.crash_screen_description, stringResource(id = R.string.app_name)),
modifier = Modifier
.padding(vertical = verticalPadding),
.padding(vertical = MaterialTheme.padding.small),
)
Box(
modifier = Modifier
.padding(vertical = verticalPadding)
.padding(vertical = MaterialTheme.padding.small)
.clip(MaterialTheme.shapes.small)
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surfaceVariant),
@ -117,7 +116,7 @@ fun CrashScreen(
Text(
text = exception.toString(),
modifier = Modifier
.padding(all = verticalPadding),
.padding(all = MaterialTheme.padding.small),
color = MaterialTheme.colorScheme.onSurfaceVariant,
)
}

View File

@ -22,7 +22,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.domain.history.model.HistoryWithRelations
import eu.kanade.presentation.components.MangaCover
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.lang.toTimestampString
import java.text.DecimalFormat
@ -42,7 +42,7 @@ fun HistoryItem(
modifier = modifier
.clickable(onClick = onClickResume)
.height(HISTORY_ITEM_HEIGHT)
.padding(horizontal = horizontalPadding, vertical = 8.dp),
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
verticalAlignment = Alignment.CenterVertically,
) {
MangaCover.Book(
@ -53,7 +53,7 @@ fun HistoryItem(
Column(
modifier = Modifier
.weight(1f)
.padding(start = horizontalPadding, end = 8.dp),
.padding(start = MaterialTheme.padding.medium, end = MaterialTheme.padding.small),
) {
val textStyle = MaterialTheme.typography.bodyMedium
Text(

View File

@ -16,7 +16,7 @@ import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.domain.manga.model.Manga
import eu.kanade.presentation.components.MangaCover
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
@Composable
fun BaseMangaListItem(
@ -32,7 +32,7 @@ fun BaseMangaListItem(
modifier = modifier
.clickable(onClick = onClickItem)
.height(56.dp)
.padding(horizontal = horizontalPadding),
.padding(horizontal = MaterialTheme.padding.medium),
verticalAlignment = Alignment.CenterVertically,
) {
cover()
@ -44,7 +44,7 @@ fun BaseMangaListItem(
private val defaultCover: @Composable RowScope.(Manga, () -> Unit) -> Unit = { manga, onClick ->
MangaCover.Square(
modifier = Modifier
.padding(vertical = 8.dp)
.padding(vertical = MaterialTheme.padding.small)
.fillMaxHeight(),
data = manga,
onClick = onClick,
@ -56,7 +56,7 @@ private val defaultContent: @Composable RowScope.(Manga) -> Unit = {
Text(
text = it.title,
modifier = Modifier
.padding(start = horizontalPadding),
.padding(start = MaterialTheme.padding.medium),
overflow = TextOverflow.Ellipsis,
maxLines = 1,
style = MaterialTheme.typography.bodyMedium,

View File

@ -40,7 +40,7 @@ import eu.kanade.presentation.components.ChapterDownloadIndicator
import eu.kanade.presentation.components.MangaCover
import eu.kanade.presentation.components.RelativeDateHeader
import eu.kanade.presentation.util.ReadItemAlpha
import eu.kanade.presentation.util.horizontalPadding
import eu.kanade.presentation.util.padding
import eu.kanade.presentation.util.selectedBackground
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.download.model.Download
@ -65,7 +65,7 @@ fun LazyListScope.updatesLastUpdatedItem(
Box(
modifier = Modifier
.animateItemPlacement()
.padding(horizontal = horizontalPadding, vertical = 8.dp),
.padding(horizontal = MaterialTheme.padding.medium, vertical = MaterialTheme.padding.small),
) {
Text(
text = if (time.isNullOrEmpty()) {
@ -169,7 +169,7 @@ fun UpdatesUiItem(
},
)
.height(56.dp)
.padding(horizontal = horizontalPadding),
.padding(horizontal = MaterialTheme.padding.medium),
verticalAlignment = Alignment.CenterVertically,
) {
MangaCover.Square(
@ -181,7 +181,7 @@ fun UpdatesUiItem(
)
Column(
modifier = Modifier
.padding(horizontal = horizontalPadding)
.padding(horizontal = MaterialTheme.padding.medium)
.weight(1f),
) {
val bookmark = remember(update.bookmark) { update.bookmark }

View File

@ -1,15 +1,24 @@
package eu.kanade.presentation.util
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.material3.MaterialTheme
import androidx.compose.ui.unit.dp
private val horizontal = 16.dp
private val vertical = 8.dp
val horizontalPadding = horizontal
val verticalPadding = vertical
val topPaddingValues = PaddingValues(top = vertical)
val topSmallPaddingValues = PaddingValues(top = MaterialTheme.padding.small)
const val ReadItemAlpha = .38f
const val SecondaryItemAlpha = .78f
class Padding {
val extraLarge = 32.dp
val large = 24.dp
val medium = 16.dp
val small = 8.dp
}
val MaterialTheme.padding: Padding
get() = Padding()