feat: option to disable scrolling in the Reader
* Appears after enabling horizontal gesture Resolves: #186
This commit is contained in:
parent
5ba036fafb
commit
24d3e3ba0a
10 changed files with 62 additions and 3 deletions
|
|
@ -4,6 +4,8 @@
|
|||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
|
||||
@file:Suppress("RemoveExplicitTypeArguments")
|
||||
|
||||
package ua.acclorite.book_story.data.settings
|
||||
|
||||
import androidx.datastore.preferences.core.Preferences
|
||||
|
|
@ -82,7 +84,7 @@ class SettingsManager @Inject constructor(
|
|||
}
|
||||
)
|
||||
val theme = setting<Theme, String>(
|
||||
key = stringPreferencesKey("theme"), default = Theme.Companion.entries().first(),
|
||||
key = stringPreferencesKey("theme"), default = Theme.entries().first(),
|
||||
serialize = { it.name }, deserialize = { Theme.valueOf(it) }
|
||||
)
|
||||
val darkTheme = setting<DarkTheme, String>(
|
||||
|
|
@ -205,6 +207,9 @@ class SettingsManager @Inject constructor(
|
|||
val horizontalGesturePullAnim = setting<Boolean, Boolean>(
|
||||
key = booleanPreferencesKey("horizontal_gesture_pull_anim"), default = true
|
||||
)
|
||||
val horizontalGestureDisableScrolling = setting<Boolean, Boolean>(
|
||||
key = booleanPreferencesKey("horizontal_gesture_disable_scrolling"), default = false
|
||||
)
|
||||
val bottomBarPadding = setting<Int, Int>(
|
||||
key = intPreferencesKey("bottom_bar_padding"), default = 0
|
||||
)
|
||||
|
|
|
|||
|
|
@ -408,6 +408,7 @@ data class ReaderScreen(val bookId: Int) : Screen, Parcelable {
|
|||
horizontalGestureSensitivity = horizontalGestureSensitivity,
|
||||
horizontalGestureAlphaAnim = settings.horizontalGestureAlphaAnim.value,
|
||||
horizontalGesturePullAnim = settings.horizontalGesturePullAnim.value,
|
||||
horizontalGestureDisableScrolling = settings.horizontalGestureDisableScrolling.value,
|
||||
highlightedReading = settings.highlightedReading.value,
|
||||
highlightedReadingThickness = highlightedReadingThickness,
|
||||
progress = progress,
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ fun LazyColumnWithScrollbar(
|
|||
state: LazyListState = rememberLazyListState(),
|
||||
scrollbarSettings: ScrollbarSettings = ScrollbarData.secondaryScrollbar,
|
||||
enableScrollbar: Boolean = true,
|
||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||
verticalArrangement: Arrangement.Vertical = Arrangement.Top,
|
||||
contentPadding: PaddingValues = PaddingValues(0.dp),
|
||||
userScrollEnabled: Boolean = true,
|
||||
content: LazyListScope.() -> Unit
|
||||
) {
|
||||
val enabled = remember {
|
||||
|
|
@ -44,7 +45,8 @@ fun LazyColumnWithScrollbar(
|
|||
modifier = modifier,
|
||||
state = state,
|
||||
verticalArrangement = verticalArrangement,
|
||||
contentPadding = contentPadding
|
||||
contentPadding = contentPadding,
|
||||
userScrollEnabled = userScrollEnabled
|
||||
) {
|
||||
content()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ fun ReaderContent(
|
|||
horizontalGestureSensitivity: Dp,
|
||||
horizontalGestureAlphaAnim: Boolean,
|
||||
horizontalGesturePullAnim: Boolean,
|
||||
horizontalGestureDisableScrolling: Boolean,
|
||||
highlightedReading: Boolean,
|
||||
highlightedReadingThickness: FontWeight,
|
||||
progress: String,
|
||||
|
|
@ -135,6 +136,7 @@ fun ReaderContent(
|
|||
horizontalGestureSensitivity = horizontalGestureSensitivity,
|
||||
horizontalGestureAlphaAnim = horizontalGestureAlphaAnim,
|
||||
horizontalGesturePullAnim = horizontalGesturePullAnim,
|
||||
horizontalGestureDisableScrolling = horizontalGestureDisableScrolling,
|
||||
highlightedReading = highlightedReading,
|
||||
highlightedReadingThickness = highlightedReadingThickness,
|
||||
progress = progress,
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ fun ReaderLayout(
|
|||
horizontalGestureSensitivity: Dp,
|
||||
horizontalGestureAlphaAnim: Boolean,
|
||||
horizontalGesturePullAnim: Boolean,
|
||||
horizontalGestureDisableScrolling: Boolean,
|
||||
highlightedReading: Boolean,
|
||||
highlightedReadingThickness: FontWeight,
|
||||
progress: String,
|
||||
|
|
@ -168,6 +169,7 @@ fun ReaderLayout(
|
|||
enableScrollbar = false,
|
||||
parentModifier = Modifier.weight(1f),
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
userScrollEnabled = !horizontalGestureDisableScrolling,
|
||||
contentPadding = PaddingValues(
|
||||
top = (WindowInsets.displayCutout.asPaddingValues()
|
||||
.calculateTopPadding() + paragraphHeight)
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ fun ReaderScaffold(
|
|||
horizontalGestureSensitivity: Dp,
|
||||
horizontalGestureAlphaAnim: Boolean,
|
||||
horizontalGesturePullAnim: Boolean,
|
||||
horizontalGestureDisableScrolling: Boolean,
|
||||
highlightedReading: Boolean,
|
||||
highlightedReadingThickness: FontWeight,
|
||||
progress: String,
|
||||
|
|
@ -166,6 +167,7 @@ fun ReaderScaffold(
|
|||
horizontalGestureSensitivity = horizontalGestureSensitivity,
|
||||
horizontalGestureAlphaAnim = horizontalGestureAlphaAnim,
|
||||
horizontalGesturePullAnim = horizontalGesturePullAnim,
|
||||
horizontalGestureDisableScrolling = horizontalGestureDisableScrolling,
|
||||
highlightedReading = highlightedReading,
|
||||
highlightedReadingThickness = highlightedReadingThickness,
|
||||
progress = progress,
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.ui.settings.components.SettingsSubcategory
|
||||
import ua.acclorite.book_story.ui.settings.reader.reading_mode.components.HorizontalGestureAlphaAnimOption
|
||||
import ua.acclorite.book_story.ui.settings.reader.reading_mode.components.HorizontalGestureDisableScrollingOption
|
||||
import ua.acclorite.book_story.ui.settings.reader.reading_mode.components.HorizontalGestureOption
|
||||
import ua.acclorite.book_story.ui.settings.reader.reading_mode.components.HorizontalGesturePullAnimOption
|
||||
import ua.acclorite.book_story.ui.settings.reader.reading_mode.components.HorizontalGestureScrollOption
|
||||
|
|
@ -52,5 +53,9 @@ fun LazyListScope.ReadingModeSubcategory(
|
|||
item {
|
||||
HorizontalGestureAlphaAnimOption()
|
||||
}
|
||||
|
||||
item {
|
||||
HorizontalGestureDisableScrollingOption()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Book's Story — free and open-source Material You eBook reader.
|
||||
* Copyright (C) 2024-2025 Acclorite
|
||||
* SPDX-License-Identifier: GPL-3.0-only
|
||||
*/
|
||||
|
||||
package ua.acclorite.book_story.ui.settings.reader.reading_mode.components
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.reader.model.ReaderHorizontalGesture
|
||||
import ua.acclorite.book_story.ui.common.components.settings.SwitchWithTitle
|
||||
import ua.acclorite.book_story.ui.common.helpers.LocalSettings
|
||||
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||
|
||||
@Composable
|
||||
fun HorizontalGestureDisableScrollingOption() {
|
||||
val settings = LocalSettings.current
|
||||
|
||||
ExpandingTransition(
|
||||
visible = when (settings.horizontalGesture.value) {
|
||||
ReaderHorizontalGesture.OFF -> false
|
||||
else -> true
|
||||
}
|
||||
) {
|
||||
SwitchWithTitle(
|
||||
selected = settings.horizontalGestureDisableScrolling.value,
|
||||
title = stringResource(id = R.string.horizontal_gesture_disable_scrolling_option),
|
||||
description = stringResource(id = R.string.horizontal_gesture_disable_scrolling_option_desc),
|
||||
onClick = {
|
||||
settings.horizontalGestureDisableScrolling.update(!settings.horizontalGestureDisableScrolling.lastValue)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -211,6 +211,8 @@
|
|||
<string name="horizontal_gesture_pull_anim_option_desc">
|
||||
Увімкнути анімацію тягнення під час використання горизонтального жесту
|
||||
</string>
|
||||
<string name="horizontal_gesture_disable_scrolling_option">Вимкнути гортання</string>
|
||||
<string name="horizontal_gesture_disable_scrolling_option_desc">Повністю вимкнути гортання читача</string>
|
||||
<string name="bottom_bar_padding_option">Відступ нижньої панелі</string>
|
||||
<string name="highlighted_reading_option">Підсвічування слів</string>
|
||||
<string name="highlighted_reading_option_desc">Підсвічувати початок кожного слова</string>
|
||||
|
|
|
|||
|
|
@ -235,6 +235,8 @@
|
|||
<string name="horizontal_gesture_pull_anim_option_desc">
|
||||
Enable pull animation when using horizontal gesture
|
||||
</string>
|
||||
<string name="horizontal_gesture_disable_scrolling_option">Disable scrolling</string>
|
||||
<string name="horizontal_gesture_disable_scrolling_option_desc">Completely disable reader scrolling</string>
|
||||
<string name="bottom_bar_padding_option">Bottom bar margin</string>
|
||||
<string name="highlighted_reading_option">Highlight words</string>
|
||||
<string name="highlighted_reading_option_desc">Highlight the beginning of each word</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue