mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-29 19:18:52 +03:00
MangaScreen: Adjust insets (#8097)
I should have done this when Scaffold was rebased
This commit is contained in:
parent
5a37f2398a
commit
6b1d597d34
2 changed files with 19 additions and 18 deletions
|
@ -12,7 +12,12 @@ import androidx.compose.foundation.layout.Arrangement
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.RowScope
|
import androidx.compose.foundation.layout.RowScope
|
||||||
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
|
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||||
|
import androidx.compose.foundation.layout.asPaddingValues
|
||||||
|
import androidx.compose.foundation.layout.navigationBars
|
||||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||||
|
import androidx.compose.foundation.layout.only
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.shape.ZeroCornerSize
|
import androidx.compose.foundation.shape.ZeroCornerSize
|
||||||
|
@ -86,7 +91,7 @@ fun MangaBottomActionMenu(
|
||||||
}
|
}
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.navigationBarsPadding()
|
.padding(WindowInsets.navigationBars.only(WindowInsetsSides.Bottom).asPaddingValues())
|
||||||
.padding(horizontal = 8.dp, vertical = 12.dp),
|
.padding(horizontal = 8.dp, vertical = 12.dp),
|
||||||
) {
|
) {
|
||||||
if (onBookmarkClicked != null) {
|
if (onBookmarkClicked != null) {
|
||||||
|
|
|
@ -66,7 +66,6 @@ import eu.kanade.presentation.manga.components.MangaChapterListItem
|
||||||
import eu.kanade.presentation.manga.components.MangaInfoBox
|
import eu.kanade.presentation.manga.components.MangaInfoBox
|
||||||
import eu.kanade.presentation.util.isScrolledToEnd
|
import eu.kanade.presentation.util.isScrolledToEnd
|
||||||
import eu.kanade.presentation.util.isScrollingUp
|
import eu.kanade.presentation.util.isScrollingUp
|
||||||
import eu.kanade.presentation.util.plus
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.download.model.Download
|
import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
import eu.kanade.tachiyomi.source.SourceManager
|
||||||
|
@ -207,7 +206,6 @@ private fun MangaScreenSmallImpl(
|
||||||
onAllChapterSelected: (Boolean) -> Unit,
|
onAllChapterSelected: (Boolean) -> Unit,
|
||||||
onInvertSelection: () -> Unit,
|
onInvertSelection: () -> Unit,
|
||||||
) {
|
) {
|
||||||
val layoutDirection = LocalLayoutDirection.current
|
|
||||||
val chapterListState = rememberLazyListState()
|
val chapterListState = rememberLazyListState()
|
||||||
|
|
||||||
val chapters = remember(state) { state.processedChapters.toList() }
|
val chapters = remember(state) { state.processedChapters.toList() }
|
||||||
|
@ -222,6 +220,8 @@ private fun MangaScreenSmallImpl(
|
||||||
BackHandler(onBack = internalOnBackPressed)
|
BackHandler(onBack = internalOnBackPressed)
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(WindowInsets.navigationBars.only(WindowInsetsSides.Horizontal).asPaddingValues()),
|
||||||
topBar = {
|
topBar = {
|
||||||
val firstVisibleItemIndex by remember {
|
val firstVisibleItemIndex by remember {
|
||||||
derivedStateOf { chapterListState.firstVisibleItemIndex }
|
derivedStateOf { chapterListState.firstVisibleItemIndex }
|
||||||
|
@ -287,11 +287,6 @@ private fun MangaScreenSmallImpl(
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
val noTopContentPadding = PaddingValues(
|
|
||||||
start = contentPadding.calculateStartPadding(layoutDirection),
|
|
||||||
end = contentPadding.calculateEndPadding(layoutDirection),
|
|
||||||
bottom = contentPadding.calculateBottomPadding(),
|
|
||||||
) + WindowInsets.navigationBars.only(WindowInsetsSides.Bottom).asPaddingValues()
|
|
||||||
val topPadding = contentPadding.calculateTopPadding()
|
val topPadding = contentPadding.calculateTopPadding()
|
||||||
|
|
||||||
SwipeRefresh(
|
SwipeRefresh(
|
||||||
|
@ -309,12 +304,13 @@ private fun MangaScreenSmallImpl(
|
||||||
VerticalFastScroller(
|
VerticalFastScroller(
|
||||||
listState = chapterListState,
|
listState = chapterListState,
|
||||||
topContentPadding = topPadding,
|
topContentPadding = topPadding,
|
||||||
endContentPadding = noTopContentPadding.calculateEndPadding(layoutDirection),
|
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxHeight(),
|
modifier = Modifier.fillMaxHeight(),
|
||||||
state = chapterListState,
|
state = chapterListState,
|
||||||
contentPadding = noTopContentPadding,
|
contentPadding = PaddingValues(
|
||||||
|
bottom = contentPadding.calculateBottomPadding(),
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
item(
|
item(
|
||||||
key = MangaScreenItem.INFO_BOX,
|
key = MangaScreenItem.INFO_BOX,
|
||||||
|
@ -518,8 +514,6 @@ fun MangaScreenLargeImpl(
|
||||||
},
|
},
|
||||||
) { contentPadding ->
|
) { contentPadding ->
|
||||||
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
BoxWithConstraints(modifier = Modifier.fillMaxSize()) {
|
||||||
val withNavBarContentPadding = contentPadding +
|
|
||||||
WindowInsets.navigationBars.only(WindowInsetsSides.Bottom).asPaddingValues()
|
|
||||||
val firstWidth = (maxWidth / 2).coerceAtMost(450.dp)
|
val firstWidth = (maxWidth / 2).coerceAtMost(450.dp)
|
||||||
val secondWidth = maxWidth - firstWidth
|
val secondWidth = maxWidth - firstWidth
|
||||||
|
|
||||||
|
@ -527,8 +521,7 @@ fun MangaScreenLargeImpl(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.TopStart)
|
.align(Alignment.TopStart)
|
||||||
.width(firstWidth)
|
.width(firstWidth)
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState()),
|
||||||
.padding(bottom = withNavBarContentPadding.calculateBottomPadding()),
|
|
||||||
) {
|
) {
|
||||||
MangaInfoBox(
|
MangaInfoBox(
|
||||||
windowWidthSizeClass = windowWidthSizeClass,
|
windowWidthSizeClass = windowWidthSizeClass,
|
||||||
|
@ -564,13 +557,15 @@ fun MangaScreenLargeImpl(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.TopEnd)
|
.align(Alignment.TopEnd)
|
||||||
.width(secondWidth),
|
.width(secondWidth),
|
||||||
topContentPadding = withNavBarContentPadding.calculateTopPadding(),
|
topContentPadding = contentPadding.calculateTopPadding(),
|
||||||
endContentPadding = withNavBarContentPadding.calculateEndPadding(layoutDirection),
|
|
||||||
) {
|
) {
|
||||||
LazyColumn(
|
LazyColumn(
|
||||||
modifier = Modifier.fillMaxHeight(),
|
modifier = Modifier.fillMaxHeight(),
|
||||||
state = chapterListState,
|
state = chapterListState,
|
||||||
contentPadding = withNavBarContentPadding,
|
contentPadding = PaddingValues(
|
||||||
|
top = contentPadding.calculateTopPadding(),
|
||||||
|
bottom = contentPadding.calculateBottomPadding(),
|
||||||
|
),
|
||||||
) {
|
) {
|
||||||
item(
|
item(
|
||||||
key = MangaScreenItem.CHAPTER_HEADER,
|
key = MangaScreenItem.CHAPTER_HEADER,
|
||||||
|
@ -599,6 +594,7 @@ fun MangaScreenLargeImpl(
|
||||||
@Composable
|
@Composable
|
||||||
private fun SharedMangaBottomActionMenu(
|
private fun SharedMangaBottomActionMenu(
|
||||||
selected: List<ChapterItem>,
|
selected: List<ChapterItem>,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
onMultiBookmarkClicked: (List<Chapter>, bookmarked: Boolean) -> Unit,
|
onMultiBookmarkClicked: (List<Chapter>, bookmarked: Boolean) -> Unit,
|
||||||
onMultiMarkAsReadClicked: (List<Chapter>, markAsRead: Boolean) -> Unit,
|
onMultiMarkAsReadClicked: (List<Chapter>, markAsRead: Boolean) -> Unit,
|
||||||
onMarkPreviousAsReadClicked: (Chapter) -> Unit,
|
onMarkPreviousAsReadClicked: (Chapter) -> Unit,
|
||||||
|
@ -608,7 +604,7 @@ private fun SharedMangaBottomActionMenu(
|
||||||
) {
|
) {
|
||||||
MangaBottomActionMenu(
|
MangaBottomActionMenu(
|
||||||
visible = selected.isNotEmpty(),
|
visible = selected.isNotEmpty(),
|
||||||
modifier = Modifier.fillMaxWidth(fillFraction),
|
modifier = modifier.fillMaxWidth(fillFraction),
|
||||||
onBookmarkClicked = {
|
onBookmarkClicked = {
|
||||||
onMultiBookmarkClicked.invoke(selected.map { it.chapter }, true)
|
onMultiBookmarkClicked.invoke(selected.map { it.chapter }, true)
|
||||||
}.takeIf { selected.any { !it.chapter.bookmark } },
|
}.takeIf { selected.any { !it.chapter.bookmark } },
|
||||||
|
|
Loading…
Reference in a new issue