🚀 Disable gestures for bottom sheets with pager
* Disabled gestures for bottom sheets with pager (e.g. Reader Settings Bottom Sheet) * Fixed jerky scrolling issues due to gestures Resolves: #12
This commit is contained in:
parent
902b976bbe
commit
fa73fbb732
7 changed files with 98 additions and 75 deletions
|
|
@ -25,6 +25,7 @@ import androidx.compose.ui.graphics.Shape
|
|||
* @param shape Shape.
|
||||
* @param containerColor Container color.
|
||||
* @param onDismissRequest OnDismiss callback.
|
||||
* @param sheetGesturesEnabled Whether bottom sheet gestures are enabled.
|
||||
* @param dragHandle Drag Handle, pass null to disable.
|
||||
* @param content Content inside [ModalBottomSheet].
|
||||
*/
|
||||
|
|
@ -37,6 +38,7 @@ fun ModalBottomSheet(
|
|||
shape: Shape = BottomSheetDefaults.ExpandedShape,
|
||||
containerColor: Color = MaterialTheme.colorScheme.surfaceContainerLow,
|
||||
onDismissRequest: () -> Unit,
|
||||
sheetGesturesEnabled: Boolean,
|
||||
dragHandle: @Composable (() -> Unit)? = { BottomSheetDefaults.DragHandle() },
|
||||
content: @Composable ColumnScope.() -> Unit
|
||||
) {
|
||||
|
|
@ -51,6 +53,7 @@ fun ModalBottomSheet(
|
|||
)
|
||||
.fillMaxWidth()
|
||||
.then(modifier),
|
||||
sheetGesturesEnabled = sheetGesturesEnabled,
|
||||
onDismissRequest = {
|
||||
onDismissRequest()
|
||||
},
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ fun NavigationBottomSheet(onDismissRequest: () -> Unit) {
|
|||
|
||||
ModalBottomSheet(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
onDismissRequest = onDismissRequest
|
||||
onDismissRequest = onDismissRequest,
|
||||
sheetGesturesEnabled = true
|
||||
) {
|
||||
LazyColumn(Modifier.fillMaxWidth()) {
|
||||
LazyColumn(modifier = Modifier.fillMaxWidth()) {
|
||||
item {
|
||||
NavigationItem(
|
||||
title = stringResource(id = R.string.about_screen),
|
||||
|
|
|
|||
|
|
@ -30,9 +30,10 @@ fun BookInfoMoreBottomSheet(snackbarState: SnackbarHostState) {
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
onDismissRequest = {
|
||||
onEvent(BookInfoEvent.OnShowHideMoreBottomSheet(false))
|
||||
}
|
||||
},
|
||||
sheetGesturesEnabled = true
|
||||
) {
|
||||
LazyColumn(Modifier.fillMaxWidth()) {
|
||||
LazyColumn(modifier = Modifier.fillMaxWidth()) {
|
||||
item {
|
||||
NavigationItem(
|
||||
title = stringResource(id = R.string.details_book),
|
||||
|
|
|
|||
|
|
@ -66,9 +66,10 @@ fun BookInfoChangeCoverBottomSheet() {
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
onDismissRequest = {
|
||||
onEvent(BookInfoEvent.OnShowHideChangeCoverBottomSheet)
|
||||
}
|
||||
},
|
||||
sheetGesturesEnabled = true
|
||||
) {
|
||||
LazyColumn(Modifier.fillMaxWidth()) {
|
||||
LazyColumn(modifier = Modifier.fillMaxWidth()) {
|
||||
if (state.value.canResetCover) {
|
||||
item {
|
||||
BookInfoChangeCoverBottomSheetItem(
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package ua.acclorite.book_story.presentation.screens.book_info.components.details_bottom_sheet
|
||||
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -10,6 +9,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.core.components.common.LazyColumnWithScrollbar
|
||||
import ua.acclorite.book_story.presentation.core.components.modal_bottom_sheet.ModalBottomSheet
|
||||
import ua.acclorite.book_story.presentation.core.util.showToast
|
||||
import ua.acclorite.book_story.presentation.screens.book_info.data.BookInfoEvent
|
||||
|
|
@ -59,8 +59,14 @@ fun BookInfoDetailsBottomSheet() {
|
|||
modifier = Modifier.fillMaxWidth(),
|
||||
onDismissRequest = {
|
||||
onEvent(BookInfoEvent.OnShowHideDetailsBottomSheet)
|
||||
}
|
||||
},
|
||||
sheetGesturesEnabled = true
|
||||
) {
|
||||
LazyColumnWithScrollbar(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
contentPadding = PaddingValues(bottom = 8.dp)
|
||||
) {
|
||||
item {
|
||||
BookInfoDetailsBottomSheetItem(
|
||||
title = stringResource(id = R.string.file_name),
|
||||
description = state.value.book.filePath.substringAfterLast("/").trim()
|
||||
|
|
@ -75,6 +81,9 @@ fun BookInfoDetailsBottomSheet() {
|
|||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
BookInfoDetailsBottomSheetItem(
|
||||
title = stringResource(id = R.string.file_path),
|
||||
description = state.value.book.filePath.trim()
|
||||
|
|
@ -89,6 +98,9 @@ fun BookInfoDetailsBottomSheet() {
|
|||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
BookInfoDetailsBottomSheetItem(
|
||||
title = stringResource(id = R.string.file_last_opened),
|
||||
description = if (state.value.book.lastOpened != null) lastOpened
|
||||
|
|
@ -106,6 +118,9 @@ fun BookInfoDetailsBottomSheet() {
|
|||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
BookInfoDetailsBottomSheetItem(
|
||||
title = stringResource(id = R.string.file_size),
|
||||
description = fileSize.ifBlank { stringResource(id = R.string.unknown) }
|
||||
|
|
@ -123,7 +138,7 @@ fun BookInfoDetailsBottomSheet() {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,8 @@ fun BrowseFilterBottomSheet() {
|
|||
dragHandle = {},
|
||||
onDismissRequest = {
|
||||
onEvent(BrowseEvent.OnShowHideFilterBottomSheet)
|
||||
}
|
||||
},
|
||||
sheetGesturesEnabled = false
|
||||
) {
|
||||
BrowseFilterBottomSheetTabRow(
|
||||
onEvent = onEvent,
|
||||
|
|
@ -55,7 +56,7 @@ fun BrowseFilterBottomSheet() {
|
|||
HorizontalPager(state = pagerState, modifier = Modifier.fillMaxSize()) { page ->
|
||||
when (page) {
|
||||
0 -> {
|
||||
LazyColumnWithScrollbar(Modifier.fillMaxSize()) {
|
||||
LazyColumnWithScrollbar(modifier = Modifier.fillMaxSize()) {
|
||||
BrowseGeneralSubcategory(
|
||||
showTitle = false,
|
||||
showDivider = false,
|
||||
|
|
@ -66,7 +67,7 @@ fun BrowseFilterBottomSheet() {
|
|||
}
|
||||
|
||||
1 -> {
|
||||
LazyColumnWithScrollbar(Modifier.fillMaxSize()) {
|
||||
LazyColumnWithScrollbar(modifier = Modifier.fillMaxSize()) {
|
||||
BrowseFilterSubcategory(
|
||||
showTitle = false,
|
||||
showDivider = false,
|
||||
|
|
@ -77,7 +78,7 @@ fun BrowseFilterBottomSheet() {
|
|||
}
|
||||
|
||||
2 -> {
|
||||
LazyColumnWithScrollbar(Modifier.fillMaxSize()) {
|
||||
LazyColumnWithScrollbar(modifier = Modifier.fillMaxSize()) {
|
||||
BrowseSortSubcategory(
|
||||
showTitle = false,
|
||||
showDivider = false,
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ fun ReaderSettingsBottomSheet() {
|
|||
dragHandle = {},
|
||||
onDismissRequest = {
|
||||
onEvent(ReaderEvent.OnShowHideSettingsBottomSheet(false))
|
||||
}
|
||||
},
|
||||
sheetGesturesEnabled = false
|
||||
) {
|
||||
ReaderSettingsBottomSheetTabRow(pagerState = pagerState)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue