🛠️ Move fast color preset change to top bar
* Moved swipe area of "Fast color preset change" to top bar
This commit is contained in:
parent
8599594372
commit
092ae331aa
5 changed files with 23 additions and 23 deletions
|
|
@ -85,7 +85,6 @@ import ua.acclorite.book_story.presentation.screens.reader.components.ReaderText
|
||||||
import ua.acclorite.book_story.presentation.screens.reader.components.ReaderUpdateDialog
|
import ua.acclorite.book_story.presentation.screens.reader.components.ReaderUpdateDialog
|
||||||
import ua.acclorite.book_story.presentation.screens.reader.components.app_bar.ReaderBottomBar
|
import ua.acclorite.book_story.presentation.screens.reader.components.app_bar.ReaderBottomBar
|
||||||
import ua.acclorite.book_story.presentation.screens.reader.components.app_bar.ReaderTopBar
|
import ua.acclorite.book_story.presentation.screens.reader.components.app_bar.ReaderTopBar
|
||||||
import ua.acclorite.book_story.presentation.screens.reader.components.readerFastColorPresetChange
|
|
||||||
import ua.acclorite.book_story.presentation.screens.reader.components.settings_bottom_sheet.ReaderSettingsBottomSheet
|
import ua.acclorite.book_story.presentation.screens.reader.components.settings_bottom_sheet.ReaderSettingsBottomSheet
|
||||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||||
import ua.acclorite.book_story.presentation.screens.settings.nested.reader.data.ReaderTextAlignment
|
import ua.acclorite.book_story.presentation.screens.settings.nested.reader.data.ReaderTextAlignment
|
||||||
|
|
@ -476,21 +475,6 @@ private fun ReaderScreen(lazyListState: LazyListState) {
|
||||||
Modifier
|
Modifier
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.readerFastColorPresetChange(
|
|
||||||
fastColorPresetChangeEnabled = mainState.value.fastColorPresetChange,
|
|
||||||
isLoading = state.value.loading,
|
|
||||||
toolbarHidden = toolbarHidden,
|
|
||||||
presetChanged = {
|
|
||||||
context
|
|
||||||
.getString(
|
|
||||||
R.string.color_preset_selected_query,
|
|
||||||
it
|
|
||||||
.asString(context)
|
|
||||||
.trim()
|
|
||||||
)
|
|
||||||
.showToast(context = context, longToast = false)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.padding(contentPadding)
|
.padding(contentPadding)
|
||||||
.padding(vertical = verticalPadding),
|
.padding(vertical = verticalPadding),
|
||||||
verticalArrangement = Arrangement.spacedBy(paragraphHeight),
|
verticalArrangement = Arrangement.spacedBy(paragraphHeight),
|
||||||
|
|
|
||||||
|
|
@ -16,21 +16,19 @@ import ua.acclorite.book_story.presentation.screens.settings.data.SettingsEvent
|
||||||
*
|
*
|
||||||
* @param fastColorPresetChangeEnabled Whether this is enabled.
|
* @param fastColorPresetChangeEnabled Whether this is enabled.
|
||||||
* @param isLoading Whether Reader is loading.
|
* @param isLoading Whether Reader is loading.
|
||||||
* @param toolbarHidden Whether toolbar(selection) is hidden.
|
|
||||||
* @param presetChanged Callback when Color Preset was changed.
|
* @param presetChanged Callback when Color Preset was changed.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
fun Modifier.readerFastColorPresetChange(
|
fun Modifier.readerFastColorPresetChange(
|
||||||
fastColorPresetChangeEnabled: Boolean,
|
fastColorPresetChangeEnabled: Boolean,
|
||||||
isLoading: Boolean,
|
isLoading: Boolean,
|
||||||
toolbarHidden: Boolean,
|
|
||||||
presetChanged: (UIText) -> Unit
|
presetChanged: (UIText) -> Unit
|
||||||
): Modifier {
|
): Modifier {
|
||||||
val onSettingsEvent = LocalSettingsViewModel.current.onEvent
|
val onSettingsEvent = LocalSettingsViewModel.current.onEvent
|
||||||
|
|
||||||
val offset = remember { mutableFloatStateOf(0f) }
|
val offset = remember { mutableFloatStateOf(0f) }
|
||||||
return this.then(
|
return this.then(
|
||||||
if (fastColorPresetChangeEnabled && toolbarHidden && !isLoading) {
|
if (fastColorPresetChangeEnabled && !isLoading) {
|
||||||
Modifier.pointerInput(Unit) {
|
Modifier.pointerInput(Unit) {
|
||||||
detectHorizontalDragGestures(
|
detectHorizontalDragGestures(
|
||||||
onDragStart = { offset.floatValue = 0f },
|
onDragStart = { offset.floatValue = 0f },
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,15 @@ import ua.acclorite.book_story.presentation.core.components.CustomAnimatedVisibi
|
||||||
import ua.acclorite.book_story.presentation.core.components.CustomIconButton
|
import ua.acclorite.book_story.presentation.core.components.CustomIconButton
|
||||||
import ua.acclorite.book_story.presentation.core.components.LocalHistoryViewModel
|
import ua.acclorite.book_story.presentation.core.components.LocalHistoryViewModel
|
||||||
import ua.acclorite.book_story.presentation.core.components.LocalLibraryViewModel
|
import ua.acclorite.book_story.presentation.core.components.LocalLibraryViewModel
|
||||||
|
import ua.acclorite.book_story.presentation.core.components.LocalMainViewModel
|
||||||
import ua.acclorite.book_story.presentation.core.components.LocalReaderViewModel
|
import ua.acclorite.book_story.presentation.core.components.LocalReaderViewModel
|
||||||
import ua.acclorite.book_story.presentation.core.navigation.LocalOnNavigate
|
import ua.acclorite.book_story.presentation.core.navigation.LocalOnNavigate
|
||||||
import ua.acclorite.book_story.presentation.core.navigation.Screen
|
import ua.acclorite.book_story.presentation.core.navigation.Screen
|
||||||
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
import ua.acclorite.book_story.presentation.core.util.noRippleClickable
|
||||||
|
import ua.acclorite.book_story.presentation.core.util.showToast
|
||||||
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
import ua.acclorite.book_story.presentation.screens.history.data.HistoryEvent
|
||||||
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
import ua.acclorite.book_story.presentation.screens.library.data.LibraryEvent
|
||||||
|
import ua.acclorite.book_story.presentation.screens.reader.components.readerFastColorPresetChange
|
||||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||||
import ua.acclorite.book_story.presentation.ui.Colors
|
import ua.acclorite.book_story.presentation.ui.Colors
|
||||||
|
|
||||||
|
|
@ -56,6 +59,7 @@ import ua.acclorite.book_story.presentation.ui.Colors
|
||||||
@Composable
|
@Composable
|
||||||
fun ReaderTopBar() {
|
fun ReaderTopBar() {
|
||||||
val state = LocalReaderViewModel.current.state
|
val state = LocalReaderViewModel.current.state
|
||||||
|
val mainState = LocalMainViewModel.current.state
|
||||||
val onEvent = LocalReaderViewModel.current.onEvent
|
val onEvent = LocalReaderViewModel.current.onEvent
|
||||||
val onLibraryEvent = LocalLibraryViewModel.current.onEvent
|
val onLibraryEvent = LocalLibraryViewModel.current.onEvent
|
||||||
val onHistoryEvent = LocalHistoryViewModel.current.onEvent
|
val onHistoryEvent = LocalHistoryViewModel.current.onEvent
|
||||||
|
|
@ -70,6 +74,20 @@ fun ReaderTopBar() {
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.background(Colors.readerSystemBarsColor)
|
.background(Colors.readerSystemBarsColor)
|
||||||
|
.readerFastColorPresetChange(
|
||||||
|
fastColorPresetChangeEnabled = mainState.value.fastColorPresetChange,
|
||||||
|
isLoading = state.value.loading,
|
||||||
|
presetChanged = {
|
||||||
|
context
|
||||||
|
.getString(
|
||||||
|
R.string.color_preset_selected_query,
|
||||||
|
it
|
||||||
|
.asString(context)
|
||||||
|
.trim()
|
||||||
|
)
|
||||||
|
.showToast(context = context, longToast = false)
|
||||||
|
}
|
||||||
|
)
|
||||||
) {
|
) {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
navigationIcon = {
|
navigationIcon = {
|
||||||
|
|
|
||||||
|
|
@ -248,7 +248,7 @@
|
||||||
<string name="double_click_translation_option">Переклад подвійним кліком</string>
|
<string name="double_click_translation_option">Переклад подвійним кліком</string>
|
||||||
<string name="double_click_translation_option_desc">Двічі клацніть на абзац, щоб перекласти його</string>
|
<string name="double_click_translation_option_desc">Двічі клацніть на абзац, щоб перекласти його</string>
|
||||||
<string name="fast_color_preset_change_option">Швидка зміна пресета кольорів</string>
|
<string name="fast_color_preset_change_option">Швидка зміна пресета кольорів</string>
|
||||||
<string name="fast_color_preset_change_option_desc">Проведіть вліво або вправо, щоб змінити пресет кольорів</string>
|
<string name="fast_color_preset_change_option_desc">Проведіть верхню панель вліво або вправо, щоб змінити пресет кольорів</string>
|
||||||
<string name="text_alignment_option">Розташування текста</string>
|
<string name="text_alignment_option">Розташування текста</string>
|
||||||
<string name="letter_spacing_option">Відстань між літерами</string>
|
<string name="letter_spacing_option">Відстань між літерами</string>
|
||||||
<string name="cutout_padding_option">Відступ від виїмки</string>
|
<string name="cutout_padding_option">Відступ від виїмки</string>
|
||||||
|
|
@ -552,7 +552,7 @@
|
||||||
після цього перемістіть його до бажаного місця.
|
після цього перемістіть його до бажаного місця.
|
||||||
Ви можете швидко змінювати пресети кольорів увімкнувши відповідне
|
Ви можете швидко змінювати пресети кольорів увімкнувши відповідне
|
||||||
налаштування в підкатегорії «Кольори» налаштувань Зовнішнього Вигляду,
|
налаштування в підкатегорії «Кольори» налаштувань Зовнішнього Вигляду,
|
||||||
та потім провівши вліво або вправо в Читачі, щоб швидко змінити пресет кольорів.
|
та потім провівши верхню панель вліво або вправо в Читачі, щоб швидко змінити пресет кольорів.
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -249,7 +249,7 @@
|
||||||
<string name="double_click_translation_option">Double click translation</string>
|
<string name="double_click_translation_option">Double click translation</string>
|
||||||
<string name="double_click_translation_option_desc">Double click on paragraph to translate it</string>
|
<string name="double_click_translation_option_desc">Double click on paragraph to translate it</string>
|
||||||
<string name="fast_color_preset_change_option">Fast color preset change</string>
|
<string name="fast_color_preset_change_option">Fast color preset change</string>
|
||||||
<string name="fast_color_preset_change_option_desc">Swipe left or right to change color preset</string>
|
<string name="fast_color_preset_change_option_desc">Swipe top bar left or right to change color preset</string>
|
||||||
<string name="text_alignment_option">Text alignment</string>
|
<string name="text_alignment_option">Text alignment</string>
|
||||||
<string name="letter_spacing_option">Letter spacing</string>
|
<string name="letter_spacing_option">Letter spacing</string>
|
||||||
<string name="cutout_padding_option">Cutout padding</string>
|
<string name="cutout_padding_option">Cutout padding</string>
|
||||||
|
|
@ -550,7 +550,7 @@
|
||||||
If you want to reorder color preset, select it and hold «Handle» icon-button,
|
If you want to reorder color preset, select it and hold «Handle» icon-button,
|
||||||
then move it to the desired position.
|
then move it to the desired position.
|
||||||
You can fast change color presets by enabling corresponding setting
|
You can fast change color presets by enabling corresponding setting
|
||||||
in Appearance setting\'s «Colors» subcategory, then swiping left or right in Reader,
|
in Appearance setting\'s «Colors» subcategory, then swiping top bar left or right in Reader,
|
||||||
to fast change color preset.
|
to fast change color preset.
|
||||||
</string>
|
</string>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue