diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/core/constants/DataStoreConstants.kt b/app/src/main/java/ua/acclorite/book_story/presentation/core/constants/DataStoreConstants.kt index a653cc73..014e99fc 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/core/constants/DataStoreConstants.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/core/constants/DataStoreConstants.kt @@ -51,6 +51,7 @@ object DataStoreConstants { val HORIZONTAL_GESTURE_SCROLL = doublePreferencesKey("horizontal_gesture_scroll") val HORIZONTAL_GESTURE_SENSITIVITY = doublePreferencesKey("horizontal_gesture_sensitivity") val HORIZONTAL_GESTURE_ALPHA_ANIM = booleanPreferencesKey("horizontal_gesture_alpha_anim_bool") + val HORIZONTAL_GESTURE_PULL_ANIM = booleanPreferencesKey("horizontal_gesture_pull_anim") val BOTTOM_BAR_PADDING = intPreferencesKey("bottom_bar_padding") val HIGHLIGHTED_READING = booleanPreferencesKey("highlighted_reading") val HIGHLIGHTED_READING_THICKNESS = intPreferencesKey("highlighted_reading_thickness") diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderContent.kt b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderContent.kt index 23dde7ee..2d110446 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderContent.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderContent.kt @@ -58,6 +58,7 @@ fun ReaderContent( horizontalGestureScroll: Float, horizontalGestureSensitivity: Dp, horizontalGestureAlphaAnim: Boolean, + horizontalGesturePullAnim: Boolean, highlightedReading: Boolean, highlightedReadingThickness: FontWeight, progress: String, @@ -135,6 +136,7 @@ fun ReaderContent( horizontalGestureScroll = horizontalGestureScroll, horizontalGestureSensitivity = horizontalGestureSensitivity, horizontalGestureAlphaAnim = horizontalGestureAlphaAnim, + horizontalGesturePullAnim = horizontalGesturePullAnim, highlightedReading = highlightedReading, highlightedReadingThickness = highlightedReadingThickness, progress = progress, diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderHorizontalGesture.kt b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderHorizontalGesture.kt index b43e09ba..5eaa81b8 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderHorizontalGesture.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderHorizontalGesture.kt @@ -35,12 +35,14 @@ fun Modifier.readerHorizontalGesture( horizontalGestureScroll: Float, horizontalGestureSensitivity: Dp, horizontalGestureAlphaAnim: Boolean, + horizontalGesturePullAnim: Boolean, isLoading: Boolean ): Modifier { if (horizontalGesture == ReaderHorizontalGesture.OFF || isLoading) return this val inverted = rememberUpdatedState(horizontalGesture == ReaderHorizontalGesture.INVERSE) val sensitivity = rememberUpdatedState(horizontalGestureSensitivity) val alphaAnim = rememberUpdatedState(horizontalGestureAlphaAnim) + val pullAnim = rememberUpdatedState(horizontalGesturePullAnim) val scope = rememberCoroutineScope() val density = LocalDensity.current @@ -84,7 +86,8 @@ fun Modifier.readerHorizontalGesture( .alpha(calculateAlpha()) .offset { IntOffset( - x = animatedHorizontalOffset.value.roundToInt(), + x = if (pullAnim.value) animatedHorizontalOffset.value.roundToInt() + else 0, y = 0 ) } diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderLayout.kt b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderLayout.kt index e85a90e3..65e61d56 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderLayout.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderLayout.kt @@ -58,6 +58,7 @@ fun ReaderLayout( horizontalGestureScroll: Float, horizontalGestureSensitivity: Dp, horizontalGestureAlphaAnim: Boolean, + horizontalGesturePullAnim: Boolean, highlightedReading: Boolean, highlightedReadingThickness: FontWeight, progress: String, @@ -164,6 +165,7 @@ fun ReaderLayout( horizontalGestureScroll = horizontalGestureScroll, horizontalGestureSensitivity = horizontalGestureSensitivity, horizontalGestureAlphaAnim = horizontalGestureAlphaAnim, + horizontalGesturePullAnim = horizontalGesturePullAnim, isLoading = isLoading ) ) { diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderScaffold.kt b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderScaffold.kt index 5c1c7956..1877220f 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderScaffold.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/reader/ReaderScaffold.kt @@ -62,6 +62,7 @@ fun ReaderScaffold( horizontalGestureScroll: Float, horizontalGestureSensitivity: Dp, horizontalGestureAlphaAnim: Boolean, + horizontalGesturePullAnim: Boolean, highlightedReading: Boolean, highlightedReadingThickness: FontWeight, progress: String, @@ -166,6 +167,7 @@ fun ReaderScaffold( horizontalGestureScroll = horizontalGestureScroll, horizontalGestureSensitivity = horizontalGestureSensitivity, horizontalGestureAlphaAnim = horizontalGestureAlphaAnim, + horizontalGesturePullAnim = horizontalGesturePullAnim, highlightedReading = highlightedReading, highlightedReadingThickness = highlightedReadingThickness, progress = progress, diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/ReadingModeSubcategory.kt b/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/ReadingModeSubcategory.kt index d7987838..327b3e57 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/ReadingModeSubcategory.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/ReadingModeSubcategory.kt @@ -17,6 +17,7 @@ import ua.acclorite.book_story.R import ua.acclorite.book_story.presentation.settings.components.SettingsSubcategory import ua.acclorite.book_story.presentation.settings.reader.reading_mode.components.HorizontalGestureAlphaAnimOption import ua.acclorite.book_story.presentation.settings.reader.reading_mode.components.HorizontalGestureOption +import ua.acclorite.book_story.presentation.settings.reader.reading_mode.components.HorizontalGesturePullAnimOption import ua.acclorite.book_story.presentation.settings.reader.reading_mode.components.HorizontalGestureScrollOption import ua.acclorite.book_story.presentation.settings.reader.reading_mode.components.HorizontalGestureSensitivityOption @@ -44,6 +45,10 @@ fun LazyListScope.ReadingModeSubcategory( HorizontalGestureSensitivityOption() } + item { + HorizontalGesturePullAnimOption() + } + item { HorizontalGestureAlphaAnimOption() } diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/components/HorizontalGestureAlphaAnimOption.kt b/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/components/HorizontalGestureAlphaAnimOption.kt index 350fe7c6..6b55e901 100644 --- a/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/components/HorizontalGestureAlphaAnimOption.kt +++ b/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/components/HorizontalGestureAlphaAnimOption.kt @@ -31,6 +31,7 @@ fun HorizontalGestureAlphaAnimOption() { SwitchWithTitle( selected = state.value.horizontalGestureAlphaAnim, title = stringResource(id = R.string.horizontal_gesture_alpha_anim_option), + description = stringResource(id = R.string.horizontal_gesture_alpha_anim_option_desc), onClick = { mainModel.onEvent( MainEvent.OnChangeHorizontalGestureAlphaAnim( diff --git a/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/components/HorizontalGesturePullAnimOption.kt b/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/components/HorizontalGesturePullAnimOption.kt new file mode 100644 index 00000000..28ca73ce --- /dev/null +++ b/app/src/main/java/ua/acclorite/book_story/presentation/settings/reader/reading_mode/components/HorizontalGesturePullAnimOption.kt @@ -0,0 +1,44 @@ +/* + * 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.presentation.settings.reader.reading_mode.components + +import androidx.compose.runtime.Composable +import androidx.compose.ui.res.stringResource +import androidx.hilt.navigation.compose.hiltViewModel +import androidx.lifecycle.compose.collectAsStateWithLifecycle +import ua.acclorite.book_story.R +import ua.acclorite.book_story.domain.reader.ReaderHorizontalGesture +import ua.acclorite.book_story.presentation.core.components.settings.SwitchWithTitle +import ua.acclorite.book_story.ui.main.MainEvent +import ua.acclorite.book_story.ui.main.MainModel +import ua.acclorite.book_story.ui.theme.ExpandingTransition + +@Composable +fun HorizontalGesturePullAnimOption() { + val mainModel = hiltViewModel() + val state = mainModel.state.collectAsStateWithLifecycle() + + ExpandingTransition( + visible = when (state.value.horizontalGesture) { + ReaderHorizontalGesture.OFF -> false + else -> true + } + ) { + SwitchWithTitle( + selected = state.value.horizontalGesturePullAnim, + title = stringResource(id = R.string.horizontal_gesture_pull_anim_option), + description = stringResource(id = R.string.horizontal_gesture_pull_anim_option_desc), + onClick = { + mainModel.onEvent( + MainEvent.OnChangeHorizontalGesturePullAnim( + !state.value.horizontalGesturePullAnim + ) + ) + } + ) + } +} \ No newline at end of file diff --git a/app/src/main/java/ua/acclorite/book_story/ui/main/MainEvent.kt b/app/src/main/java/ua/acclorite/book_story/ui/main/MainEvent.kt index 8f4f0b9f..3c406ee5 100644 --- a/app/src/main/java/ua/acclorite/book_story/ui/main/MainEvent.kt +++ b/app/src/main/java/ua/acclorite/book_story/ui/main/MainEvent.kt @@ -66,4 +66,5 @@ sealed class MainEvent { data class OnChangeFontThickness(val value: String) : MainEvent() data class OnChangeProgressCount(val value: String) : MainEvent() data class OnChangeHorizontalGestureAlphaAnim(val value: Boolean) : MainEvent() + data class OnChangeHorizontalGesturePullAnim(val value: Boolean) : MainEvent() } \ No newline at end of file diff --git a/app/src/main/java/ua/acclorite/book_story/ui/main/MainModel.kt b/app/src/main/java/ua/acclorite/book_story/ui/main/MainModel.kt index c4dc9c48..f6cbe396 100644 --- a/app/src/main/java/ua/acclorite/book_story/ui/main/MainModel.kt +++ b/app/src/main/java/ua/acclorite/book_story/ui/main/MainModel.kt @@ -506,6 +506,14 @@ class MainModel @Inject constructor( it.copy(horizontalGestureAlphaAnim = this) } ) + + is MainEvent.OnChangeHorizontalGesturePullAnim -> handleDatastoreUpdate( + key = DataStoreConstants.HORIZONTAL_GESTURE_PULL_ANIM, + value = event.value, + updateState = { + it.copy(horizontalGesturePullAnim = this) + } + ) } } diff --git a/app/src/main/java/ua/acclorite/book_story/ui/main/MainState.kt b/app/src/main/java/ua/acclorite/book_story/ui/main/MainState.kt index f75d8fdb..c7e2ec43 100644 --- a/app/src/main/java/ua/acclorite/book_story/ui/main/MainState.kt +++ b/app/src/main/java/ua/acclorite/book_story/ui/main/MainState.kt @@ -101,6 +101,7 @@ data class MainState( val horizontalGestureScroll: Float = provideDefaultValue { 0.7f }, val horizontalGestureSensitivity: Float = provideDefaultValue { 0.6f }, val horizontalGestureAlphaAnim: Boolean = provideDefaultValue { true }, + val horizontalGesturePullAnim: Boolean = provideDefaultValue { true }, val bottomBarPadding: Int = provideDefaultValue { 0 }, val highlightedReading: Boolean = provideDefaultValue { false }, val highlightedReadingThickness: Int = provideDefaultValue { 2 }, @@ -369,6 +370,10 @@ data class MainState( horizontalGestureAlphaAnim = provideValue( HORIZONTAL_GESTURE_ALPHA_ANIM ) { horizontalGestureAlphaAnim }, + + horizontalGesturePullAnim = provideValue( + HORIZONTAL_GESTURE_PULL_ANIM + ) { horizontalGesturePullAnim }, ) } } diff --git a/app/src/main/java/ua/acclorite/book_story/ui/reader/ReaderScreen.kt b/app/src/main/java/ua/acclorite/book_story/ui/reader/ReaderScreen.kt index 55d17cf4..6cf498b7 100644 --- a/app/src/main/java/ua/acclorite/book_story/ui/reader/ReaderScreen.kt +++ b/app/src/main/java/ua/acclorite/book_story/ui/reader/ReaderScreen.kt @@ -425,6 +425,7 @@ data class ReaderScreen(val bookId: Int) : Screen, Parcelable { horizontalGestureScroll = mainState.value.horizontalGestureScroll, horizontalGestureSensitivity = horizontalGestureSensitivity, horizontalGestureAlphaAnim = mainState.value.horizontalGestureAlphaAnim, + horizontalGesturePullAnim = mainState.value.horizontalGesturePullAnim, highlightedReading = mainState.value.highlightedReading, highlightedReadingThickness = highlightedReadingThickness, progress = progress, diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 79b90a1c..257cfc70 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -187,6 +187,13 @@ Частка прокрутки Чутливість Анімація видимості + + Увімкнути анімацію видимості під час використання горизонтального жесту + + Анімація тягнення + + Увімкнути анімацію тягнення під час використання горизонтального жесту + Відступ нижньої панелі Підсвічування слів Підсвічувати початок кожного слова diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 399bb75d..ac40cf5c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -218,6 +218,13 @@ Scroll fraction Sensitivity Visibility animation + + Enable visibility animation when using horizontal gesture + + Pull animation + + Enable pull animation when using horizontal gesture + Bottom bar margin Highlight words Highlight the beginning of each word