From fb83a07f843e8cec2dc935f1b4eed6351aff672b Mon Sep 17 00:00:00 2001 From: Andreas Date: Sun, 15 May 2022 20:00:35 +0200 Subject: [PATCH] Add missing top padding for screen that was rewritten in Compose (#7145) --- .../presentation/extension/ExtensionScreen.kt | 4 +++- .../presentation/history/HistoryScreen.kt | 4 +++- .../source/MigrateSourceScreen.kt | 4 +++- .../presentation/source/SourceScreen.kt | 4 +++- .../eu/kanade/presentation/util/Constants.kt | 3 +++ .../kanade/presentation/util/PaddingValues.kt | 20 +++++++++++++++++++ 6 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 app/src/main/java/eu/kanade/presentation/util/PaddingValues.kt diff --git a/app/src/main/java/eu/kanade/presentation/extension/ExtensionScreen.kt b/app/src/main/java/eu/kanade/presentation/extension/ExtensionScreen.kt index 7be37a398..1eaf5ad80 100644 --- a/app/src/main/java/eu/kanade/presentation/extension/ExtensionScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/extension/ExtensionScreen.kt @@ -41,7 +41,9 @@ import com.google.accompanist.swiperefresh.rememberSwipeRefreshState import eu.kanade.presentation.browse.components.BaseBrowseItem import eu.kanade.presentation.browse.components.ExtensionIcon import eu.kanade.presentation.theme.header +import eu.kanade.presentation.util.topPaddingValues import eu.kanade.presentation.util.horizontalPadding +import eu.kanade.presentation.util.plus import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.extension.model.Extension import eu.kanade.tachiyomi.extension.model.InstallStep @@ -110,7 +112,7 @@ fun ExtensionContent( ) { val (trustState, setTrustState) = remember { mutableStateOf(null) } LazyColumn( - contentPadding = WindowInsets.navigationBars.asPaddingValues(), + contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, ) { items( items = items, diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 6904cafa5..1bfcecdc2 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -44,7 +44,9 @@ import eu.kanade.domain.history.model.HistoryWithRelations import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.LoadingScreen import eu.kanade.presentation.components.MangaCover +import eu.kanade.presentation.util.topPaddingValues import eu.kanade.presentation.util.horizontalPadding +import eu.kanade.presentation.util.plus import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.ui.recent.history.HistoryPresenter @@ -107,7 +109,7 @@ fun HistoryContent( LazyColumn( modifier = Modifier .nestedScroll(nestedScroll), - contentPadding = WindowInsets.navigationBars.asPaddingValues(), + contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, state = scrollState, ) { items(history) { item -> diff --git a/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt b/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt index 5394200d3..d85869d16 100644 --- a/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/source/MigrateSourceScreen.kt @@ -22,7 +22,9 @@ import eu.kanade.presentation.components.ItemBadges import eu.kanade.presentation.components.LoadingScreen import eu.kanade.presentation.source.components.BaseSourceItem import eu.kanade.presentation.theme.header +import eu.kanade.presentation.util.topPaddingValues import eu.kanade.presentation.util.horizontalPadding +import eu.kanade.presentation.util.plus import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrateSourceState import eu.kanade.tachiyomi.ui.browse.migration.sources.MigrationSourcesPresenter @@ -62,7 +64,7 @@ fun MigrateSourceList( LazyColumn( modifier = Modifier.nestedScroll(nestedScrollInterop), - contentPadding = WindowInsets.navigationBars.asPaddingValues(), + contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, ) { item(key = "title") { Text( diff --git a/app/src/main/java/eu/kanade/presentation/source/SourceScreen.kt b/app/src/main/java/eu/kanade/presentation/source/SourceScreen.kt index c6da3123a..a91517035 100644 --- a/app/src/main/java/eu/kanade/presentation/source/SourceScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/source/SourceScreen.kt @@ -36,7 +36,9 @@ import eu.kanade.presentation.components.EmptyScreen import eu.kanade.presentation.components.LoadingScreen import eu.kanade.presentation.source.components.BaseSourceItem import eu.kanade.presentation.theme.header +import eu.kanade.presentation.util.topPaddingValues import eu.kanade.presentation.util.horizontalPadding +import eu.kanade.presentation.util.plus import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.source.LocalSource import eu.kanade.tachiyomi.ui.browse.source.SourcePresenter @@ -86,7 +88,7 @@ fun SourceList( LazyColumn( modifier = Modifier .nestedScroll(nestedScrollConnection), - contentPadding = WindowInsets.navigationBars.asPaddingValues(), + contentPadding = WindowInsets.navigationBars.asPaddingValues() + topPaddingValues, ) { items( items = list, diff --git a/app/src/main/java/eu/kanade/presentation/util/Constants.kt b/app/src/main/java/eu/kanade/presentation/util/Constants.kt index fcf64d77b..da958b5d6 100644 --- a/app/src/main/java/eu/kanade/presentation/util/Constants.kt +++ b/app/src/main/java/eu/kanade/presentation/util/Constants.kt @@ -1,5 +1,8 @@ package eu.kanade.presentation.util +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.ui.unit.dp val horizontalPadding = 16.dp + +val topPaddingValues = PaddingValues(top = 8.dp) diff --git a/app/src/main/java/eu/kanade/presentation/util/PaddingValues.kt b/app/src/main/java/eu/kanade/presentation/util/PaddingValues.kt new file mode 100644 index 000000000..b1a2a9784 --- /dev/null +++ b/app/src/main/java/eu/kanade/presentation/util/PaddingValues.kt @@ -0,0 +1,20 @@ +package eu.kanade.presentation.util + +import androidx.compose.foundation.layout.PaddingValues +import androidx.compose.foundation.layout.calculateEndPadding +import androidx.compose.foundation.layout.calculateStartPadding +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalLayoutDirection + +@Composable +operator fun PaddingValues.plus(other: PaddingValues): PaddingValues { + val layoutDirection = LocalLayoutDirection.current + return PaddingValues( + start = calculateStartPadding(layoutDirection) + + other.calculateStartPadding(layoutDirection), + end = calculateEndPadding(layoutDirection) + + other.calculateEndPadding(layoutDirection), + top = calculateTopPadding() + other.calculateTopPadding(), + bottom = calculateBottomPadding() + other.calculateBottomPadding(), + ) +}