🚀 Bottom bar padding Option
* Added "Bottom bar padding" option, that lets users change padding below bottom bar slider to prevent accident touch Resolves: #125
This commit is contained in:
parent
dee6ae10c7
commit
562ef8715d
12 changed files with 71 additions and 6 deletions
|
|
@ -45,6 +45,7 @@ object DataStoreConstants {
|
|||
val SCREEN_BRIGHTNESS = doublePreferencesKey("screen_brightness")
|
||||
val HORIZONTAL_GESTURE = stringPreferencesKey("horizontal_gesture")
|
||||
val HORIZONTAL_GESTURE_SCROLL = doublePreferencesKey("horizontal_gesture_scroll")
|
||||
val BOTTOM_BAR_PADDING = intPreferencesKey("bottom_bar_padding")
|
||||
|
||||
// Browse settings
|
||||
val BROWSE_FILES_STRUCTURE = stringPreferencesKey("browse_files_structure")
|
||||
|
|
|
|||
|
|
@ -5,7 +5,9 @@ import androidx.compose.foundation.layout.Arrangement
|
|||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.navigationBarsPadding
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
|
|
@ -22,6 +24,7 @@ import androidx.compose.runtime.remember
|
|||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.domain.library.book.Book
|
||||
|
|
@ -44,6 +47,7 @@ fun ReaderBottomBar(
|
|||
currentChapter: Chapter?,
|
||||
currentChapterProgress: Float,
|
||||
checkpoint: Checkpoint,
|
||||
bottomBarPadding: Dp,
|
||||
restoreCheckpoint: (ReaderEvent.OnRestoreCheckpoint) -> Unit,
|
||||
scroll: (ReaderEvent.OnScroll) -> Unit,
|
||||
changeProgress: (ReaderEvent.OnChangeProgress) -> Unit
|
||||
|
|
@ -89,20 +93,21 @@ fun ReaderBottomBar(
|
|||
.background(Colors.readerSystemBarsColor)
|
||||
.noRippleClickable(onClick = {})
|
||||
.navigationBarsPadding()
|
||||
.padding(horizontal = 18.dp)
|
||||
.padding(top = 16.dp),
|
||||
.padding(horizontal = 18.dp),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center
|
||||
) {
|
||||
Spacer(Modifier.height(16.dp))
|
||||
|
||||
Text(
|
||||
text = progress.value,
|
||||
color = MaterialTheme.colorScheme.onSurface,
|
||||
style = MaterialTheme.typography.titleLarge
|
||||
)
|
||||
Row(
|
||||
modifier = Modifier.padding(top = 3.dp, bottom = 5.dp),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
|
||||
Spacer(Modifier.height(6.dp))
|
||||
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
HorizontalExpandingTransition(
|
||||
visible = arrowDirection == Direction.START,
|
||||
startDirection = true
|
||||
|
|
@ -150,5 +155,7 @@ fun ReaderBottomBar(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp + bottomBarPadding))
|
||||
}
|
||||
}
|
||||
|
|
@ -51,6 +51,7 @@ fun ReaderContent(
|
|||
horizontalGestureScroll: Float,
|
||||
paragraphHeight: Dp,
|
||||
sidePadding: Dp,
|
||||
bottomBarPadding: Dp,
|
||||
backgroundColor: Color,
|
||||
fontColor: Color,
|
||||
fontFamily: FontWithName,
|
||||
|
|
@ -124,6 +125,7 @@ fun ReaderContent(
|
|||
horizontalGestureScroll = horizontalGestureScroll,
|
||||
paragraphHeight = paragraphHeight,
|
||||
sidePadding = sidePadding,
|
||||
bottomBarPadding = bottomBarPadding,
|
||||
backgroundColor = backgroundColor,
|
||||
fontColor = fontColor,
|
||||
fontFamily = fontFamily,
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ fun ReaderScaffold(
|
|||
horizontalGestureScroll: Float,
|
||||
paragraphHeight: Dp,
|
||||
sidePadding: Dp,
|
||||
bottomBarPadding: Dp,
|
||||
backgroundColor: Color,
|
||||
fontColor: Color,
|
||||
fontFamily: FontWithName,
|
||||
|
|
@ -132,6 +133,7 @@ fun ReaderScaffold(
|
|||
currentChapter = currentChapter,
|
||||
currentChapterProgress = currentChapterProgress,
|
||||
checkpoint = checkpoint,
|
||||
bottomBarPadding = bottomBarPadding,
|
||||
restoreCheckpoint = restoreCheckpoint,
|
||||
scroll = scroll,
|
||||
changeProgress = changeProgress
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.settings.components.SettingsSubcategory
|
||||
import ua.acclorite.book_story.presentation.settings.reader.padding.components.BottomBarPaddingOption
|
||||
import ua.acclorite.book_story.presentation.settings.reader.padding.components.CutoutPaddingOption
|
||||
import ua.acclorite.book_story.presentation.settings.reader.padding.components.SidePaddingOption
|
||||
import ua.acclorite.book_story.presentation.settings.reader.padding.components.VerticalPaddingOption
|
||||
|
|
@ -36,5 +37,9 @@ fun LazyListScope.PaddingSubcategory(
|
|||
item {
|
||||
CutoutPaddingOption()
|
||||
}
|
||||
|
||||
item {
|
||||
BottomBarPaddingOption()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package ua.acclorite.book_story.presentation.settings.reader.padding.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.presentation.core.components.settings.SliderWithTitle
|
||||
import ua.acclorite.book_story.ui.main.MainEvent
|
||||
import ua.acclorite.book_story.ui.main.MainModel
|
||||
|
||||
@Composable
|
||||
fun BottomBarPaddingOption() {
|
||||
val mainModel = hiltViewModel<MainModel>()
|
||||
val state = mainModel.state.collectAsStateWithLifecycle()
|
||||
|
||||
SliderWithTitle(
|
||||
value = state.value.bottomBarPadding to "pt",
|
||||
fromValue = 0,
|
||||
toValue = 24,
|
||||
title = stringResource(id = R.string.bottom_bar_padding_option),
|
||||
onValueChange = {
|
||||
mainModel.onEvent(
|
||||
MainEvent.OnChangeBottomBarPadding(it)
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
@ -47,4 +47,5 @@ sealed class MainEvent {
|
|||
data class OnChangeScreenBrightness(val value: Float) : MainEvent()
|
||||
data class OnChangeHorizontalGesture(val value: String) : MainEvent()
|
||||
data class OnChangeHorizontalGestureScroll(val value: Float) : MainEvent()
|
||||
data class OnChangeBottomBarPadding(val value: Int) : MainEvent()
|
||||
}
|
||||
|
|
@ -394,6 +394,14 @@ class MainModel @Inject constructor(
|
|||
it.copy(horizontalGestureScroll = this.toFloat())
|
||||
}
|
||||
)
|
||||
|
||||
is MainEvent.OnChangeBottomBarPadding -> handleDatastoreUpdate(
|
||||
key = DataStoreConstants.BOTTOM_BAR_PADDING,
|
||||
value = event.value,
|
||||
updateState = {
|
||||
it.copy(bottomBarPadding = this)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,7 @@ data class MainState(
|
|||
ReaderHorizontalGesture.OFF
|
||||
},
|
||||
val horizontalGestureScroll: Float = provideDefaultValue { 0.7f },
|
||||
val bottomBarPadding: Int = provideDefaultValue { 0 },
|
||||
|
||||
// Browse Settings
|
||||
val browseFilesStructure: BrowseFilesStructure = provideDefaultValue {
|
||||
|
|
@ -295,6 +296,10 @@ data class MainState(
|
|||
horizontalGestureScroll = provideValue(
|
||||
HORIZONTAL_GESTURE_SCROLL, convert = { toFloat() }
|
||||
) { horizontalGestureScroll },
|
||||
|
||||
bottomBarPadding = provideValue(
|
||||
BOTTOM_BAR_PADDING
|
||||
) { bottomBarPadding },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,6 +218,9 @@ data class ReaderScreen(val bookId: Int) : Screen, Parcelable {
|
|||
}
|
||||
)
|
||||
}
|
||||
val bottomBarPadding = remember(mainState.value.bottomBarPadding) {
|
||||
(mainState.value.bottomBarPadding * 4f).dp
|
||||
}
|
||||
|
||||
val chapters = remember(state.value.book.chapters) {
|
||||
val chapters = mutableMapOf<Int, Chapter>()
|
||||
|
|
@ -320,6 +323,7 @@ data class ReaderScreen(val bookId: Int) : Screen, Parcelable {
|
|||
horizontalGestureScroll = mainState.value.horizontalGestureScroll,
|
||||
paragraphHeight = paragraphHeight,
|
||||
sidePadding = sidePadding,
|
||||
bottomBarPadding = bottomBarPadding,
|
||||
backgroundColor = backgroundColor.value,
|
||||
fontColor = fontColor.value,
|
||||
fontFamily = fontFamily,
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@
|
|||
<string name="screen_brightness_option">Яскравість</string>
|
||||
<string name="horizontal_gesture_option">Горизонтальний жест</string>
|
||||
<string name="horizontal_gesture_scroll_option">Частка прокрутки</string>
|
||||
<string name="bottom_bar_padding_option">Відступ нижньої панелі</string>
|
||||
|
||||
<!-- Browse -->
|
||||
<string name="browse_files_structure_option">Структура файлів</string>
|
||||
|
|
|
|||
|
|
@ -268,6 +268,7 @@
|
|||
<string name="screen_brightness_option">Brightness</string>
|
||||
<string name="horizontal_gesture_option">Horizontal gesture</string>
|
||||
<string name="horizontal_gesture_scroll_option">Scroll fraction</string>
|
||||
<string name="bottom_bar_padding_option">Bottom bar margin</string>
|
||||
|
||||
<!-- Browse -->
|
||||
<string name="browse_files_structure_option">Files structure</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue