🚀 Progress Bar Font Size option
* Changes font size of progress bar's text Part-of: #148
This commit is contained in:
parent
0c216bcb51
commit
8f9d849e3e
14 changed files with 71 additions and 3 deletions
|
|
@ -56,6 +56,7 @@ object DataStoreConstants {
|
||||||
val PROGRESS_BAR = booleanPreferencesKey("progress_bar")
|
val PROGRESS_BAR = booleanPreferencesKey("progress_bar")
|
||||||
val PROGRESS_BAR_PADDING = intPreferencesKey("progress_bar_padding")
|
val PROGRESS_BAR_PADDING = intPreferencesKey("progress_bar_padding")
|
||||||
val PROGRESS_BAR_ALIGNMENT = stringPreferencesKey("progress_bar_alignment")
|
val PROGRESS_BAR_ALIGNMENT = stringPreferencesKey("progress_bar_alignment")
|
||||||
|
val PROGRESS_BAR_FONT_SIZE = intPreferencesKey("progress_bar_font_size")
|
||||||
|
|
||||||
// Browse settings
|
// Browse settings
|
||||||
val BROWSE_FILES_STRUCTURE = stringPreferencesKey("browse_files_structure")
|
val BROWSE_FILES_STRUCTURE = stringPreferencesKey("browse_files_structure")
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ fun ReaderContent(
|
||||||
progressBar: Boolean,
|
progressBar: Boolean,
|
||||||
progressBarPadding: Dp,
|
progressBarPadding: Dp,
|
||||||
progressBarAlignment: HorizontalAlignment,
|
progressBarAlignment: HorizontalAlignment,
|
||||||
|
progressBarFontSize: TextUnit,
|
||||||
paragraphHeight: Dp,
|
paragraphHeight: Dp,
|
||||||
sidePadding: Dp,
|
sidePadding: Dp,
|
||||||
bottomBarPadding: Dp,
|
bottomBarPadding: Dp,
|
||||||
|
|
@ -130,6 +131,7 @@ fun ReaderContent(
|
||||||
progressBar = progressBar,
|
progressBar = progressBar,
|
||||||
progressBarPadding = progressBarPadding,
|
progressBarPadding = progressBarPadding,
|
||||||
progressBarAlignment = progressBarAlignment,
|
progressBarAlignment = progressBarAlignment,
|
||||||
|
progressBarFontSize = progressBarFontSize,
|
||||||
paragraphHeight = paragraphHeight,
|
paragraphHeight = paragraphHeight,
|
||||||
sidePadding = sidePadding,
|
sidePadding = sidePadding,
|
||||||
bottomBarPadding = bottomBarPadding,
|
bottomBarPadding = bottomBarPadding,
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ fun ReaderLayout(
|
||||||
progressBar: Boolean,
|
progressBar: Boolean,
|
||||||
progressBarPadding: Dp,
|
progressBarPadding: Dp,
|
||||||
progressBarAlignment: HorizontalAlignment,
|
progressBarAlignment: HorizontalAlignment,
|
||||||
|
progressBarFontSize: TextUnit,
|
||||||
paragraphHeight: Dp,
|
paragraphHeight: Dp,
|
||||||
sidePadding: Dp,
|
sidePadding: Dp,
|
||||||
backgroundColor: Color,
|
backgroundColor: Color,
|
||||||
|
|
@ -223,6 +224,7 @@ fun ReaderLayout(
|
||||||
progress = progress,
|
progress = progress,
|
||||||
progressBarPadding = progressBarPadding,
|
progressBarPadding = progressBarPadding,
|
||||||
progressBarAlignment = progressBarAlignment,
|
progressBarAlignment = progressBarAlignment,
|
||||||
|
progressBarFontSize = progressBarFontSize,
|
||||||
fontColor = fontColor,
|
fontColor = fontColor,
|
||||||
sidePadding = sidePadding
|
sidePadding = sidePadding
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -4,13 +4,13 @@ import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.fillMaxWidth
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.text.selection.DisableSelection
|
import androidx.compose.foundation.text.selection.DisableSelection
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
|
import androidx.compose.ui.unit.TextUnit
|
||||||
import ua.acclorite.book_story.domain.util.HorizontalAlignment
|
import ua.acclorite.book_story.domain.util.HorizontalAlignment
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -18,6 +18,7 @@ fun ReaderProgressBar(
|
||||||
progress: String,
|
progress: String,
|
||||||
progressBarPadding: Dp,
|
progressBarPadding: Dp,
|
||||||
progressBarAlignment: HorizontalAlignment,
|
progressBarAlignment: HorizontalAlignment,
|
||||||
|
progressBarFontSize: TextUnit,
|
||||||
fontColor: Color,
|
fontColor: Color,
|
||||||
sidePadding: Dp
|
sidePadding: Dp
|
||||||
) {
|
) {
|
||||||
|
|
@ -32,9 +33,10 @@ fun ReaderProgressBar(
|
||||||
) {
|
) {
|
||||||
DisableSelection {
|
DisableSelection {
|
||||||
Text(
|
Text(
|
||||||
progress,
|
text = progress,
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
|
||||||
color = fontColor,
|
color = fontColor,
|
||||||
|
fontSize = progressBarFontSize,
|
||||||
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -60,6 +60,7 @@ fun ReaderScaffold(
|
||||||
progressBar: Boolean,
|
progressBar: Boolean,
|
||||||
progressBarPadding: Dp,
|
progressBarPadding: Dp,
|
||||||
progressBarAlignment: HorizontalAlignment,
|
progressBarAlignment: HorizontalAlignment,
|
||||||
|
progressBarFontSize: TextUnit,
|
||||||
paragraphHeight: Dp,
|
paragraphHeight: Dp,
|
||||||
sidePadding: Dp,
|
sidePadding: Dp,
|
||||||
bottomBarPadding: Dp,
|
bottomBarPadding: Dp,
|
||||||
|
|
@ -161,6 +162,7 @@ fun ReaderScaffold(
|
||||||
progressBar = progressBar,
|
progressBar = progressBar,
|
||||||
progressBarPadding = progressBarPadding,
|
progressBarPadding = progressBarPadding,
|
||||||
progressBarAlignment = progressBarAlignment,
|
progressBarAlignment = progressBarAlignment,
|
||||||
|
progressBarFontSize = progressBarFontSize,
|
||||||
paragraphHeight = paragraphHeight,
|
paragraphHeight = paragraphHeight,
|
||||||
sidePadding = sidePadding,
|
sidePadding = sidePadding,
|
||||||
backgroundColor = backgroundColor,
|
backgroundColor = backgroundColor,
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import androidx.compose.ui.res.stringResource
|
||||||
import ua.acclorite.book_story.R
|
import ua.acclorite.book_story.R
|
||||||
import ua.acclorite.book_story.presentation.settings.components.SettingsSubcategory
|
import ua.acclorite.book_story.presentation.settings.components.SettingsSubcategory
|
||||||
import ua.acclorite.book_story.presentation.settings.reader.progress.components.ProgressBarAlignmentOption
|
import ua.acclorite.book_story.presentation.settings.reader.progress.components.ProgressBarAlignmentOption
|
||||||
|
import ua.acclorite.book_story.presentation.settings.reader.progress.components.ProgressBarFontSizeOption
|
||||||
import ua.acclorite.book_story.presentation.settings.reader.progress.components.ProgressBarOption
|
import ua.acclorite.book_story.presentation.settings.reader.progress.components.ProgressBarOption
|
||||||
import ua.acclorite.book_story.presentation.settings.reader.progress.components.ProgressBarPaddingOption
|
import ua.acclorite.book_story.presentation.settings.reader.progress.components.ProgressBarPaddingOption
|
||||||
|
|
||||||
|
|
@ -29,6 +30,10 @@ fun LazyListScope.ProgressSubcategory(
|
||||||
ProgressBarOption()
|
ProgressBarOption()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item {
|
||||||
|
ProgressBarFontSizeOption()
|
||||||
|
}
|
||||||
|
|
||||||
item {
|
item {
|
||||||
ProgressBarPaddingOption()
|
ProgressBarPaddingOption()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package ua.acclorite.book_story.presentation.settings.reader.progress.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
|
||||||
|
import ua.acclorite.book_story.ui.theme.ExpandingTransition
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ProgressBarFontSizeOption() {
|
||||||
|
val mainModel = hiltViewModel<MainModel>()
|
||||||
|
val state = mainModel.state.collectAsStateWithLifecycle()
|
||||||
|
|
||||||
|
ExpandingTransition(visible = state.value.progressBar) {
|
||||||
|
SliderWithTitle(
|
||||||
|
value = state.value.progressBarFontSize to "pt",
|
||||||
|
fromValue = 4,
|
||||||
|
toValue = 16,
|
||||||
|
title = stringResource(id = R.string.progress_bar_font_size_option),
|
||||||
|
onValueChange = {
|
||||||
|
mainModel.onEvent(
|
||||||
|
MainEvent.OnChangeProgressBarFontSize(it)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -17,6 +17,7 @@ fun ProgressBarOption() {
|
||||||
SwitchWithTitle(
|
SwitchWithTitle(
|
||||||
selected = state.value.progressBar,
|
selected = state.value.progressBar,
|
||||||
title = stringResource(id = R.string.progress_bar_option),
|
title = stringResource(id = R.string.progress_bar_option),
|
||||||
|
description = stringResource(id = R.string.progress_bar_option_desc),
|
||||||
onClick = {
|
onClick = {
|
||||||
mainModel.onEvent(
|
mainModel.onEvent(
|
||||||
MainEvent.OnChangeProgressBar(
|
MainEvent.OnChangeProgressBar(
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,5 @@ sealed class MainEvent {
|
||||||
data class OnChangeProgressBar(val value: Boolean) : MainEvent()
|
data class OnChangeProgressBar(val value: Boolean) : MainEvent()
|
||||||
data class OnChangeProgressBarPadding(val value: Int) : MainEvent()
|
data class OnChangeProgressBarPadding(val value: Int) : MainEvent()
|
||||||
data class OnChangeProgressBarAlignment(val value: String) : MainEvent()
|
data class OnChangeProgressBarAlignment(val value: String) : MainEvent()
|
||||||
|
data class OnChangeProgressBarFontSize(val value: Int) : MainEvent()
|
||||||
}
|
}
|
||||||
|
|
@ -488,6 +488,14 @@ class MainModel @Inject constructor(
|
||||||
it.copy(progressBarAlignment = this.toHorizontalAlignment())
|
it.copy(progressBarAlignment = this.toHorizontalAlignment())
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
is MainEvent.OnChangeProgressBarFontSize -> handleDatastoreUpdate(
|
||||||
|
key = DataStoreConstants.PROGRESS_BAR_FONT_SIZE,
|
||||||
|
value = event.value,
|
||||||
|
updateState = {
|
||||||
|
it.copy(progressBarFontSize = this)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ data class MainState(
|
||||||
val progressBar: Boolean = provideDefaultValue { false },
|
val progressBar: Boolean = provideDefaultValue { false },
|
||||||
val progressBarPadding: Int = provideDefaultValue { 4 },
|
val progressBarPadding: Int = provideDefaultValue { 4 },
|
||||||
val progressBarAlignment: HorizontalAlignment = provideDefaultValue { HorizontalAlignment.CENTER },
|
val progressBarAlignment: HorizontalAlignment = provideDefaultValue { HorizontalAlignment.CENTER },
|
||||||
|
val progressBarFontSize: Int = provideDefaultValue { 8 },
|
||||||
|
|
||||||
// Browse Settings
|
// Browse Settings
|
||||||
val browseFilesStructure: BrowseFilesStructure = provideDefaultValue {
|
val browseFilesStructure: BrowseFilesStructure = provideDefaultValue {
|
||||||
|
|
@ -354,6 +355,10 @@ data class MainState(
|
||||||
progressBarAlignment = provideValue(
|
progressBarAlignment = provideValue(
|
||||||
PROGRESS_BAR_ALIGNMENT, convert = { toHorizontalAlignment() }
|
PROGRESS_BAR_ALIGNMENT, convert = { toHorizontalAlignment() }
|
||||||
) { progressBarAlignment },
|
) { progressBarAlignment },
|
||||||
|
|
||||||
|
progressBarFontSize = provideValue(
|
||||||
|
PROGRESS_BAR_FONT_SIZE
|
||||||
|
) { progressBarFontSize },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -224,6 +224,9 @@ data class ReaderScreen(val bookId: Int) : Screen, Parcelable {
|
||||||
val progressBarPadding = remember(mainState.value.progressBarPadding) {
|
val progressBarPadding = remember(mainState.value.progressBarPadding) {
|
||||||
(mainState.value.progressBarPadding * 3).dp
|
(mainState.value.progressBarPadding * 3).dp
|
||||||
}
|
}
|
||||||
|
val progressBarFontSize = remember(mainState.value.progressBarFontSize) {
|
||||||
|
(mainState.value.progressBarFontSize * 2).sp
|
||||||
|
}
|
||||||
|
|
||||||
val layoutDirection = LocalLayoutDirection.current
|
val layoutDirection = LocalLayoutDirection.current
|
||||||
val cutoutInsets = WindowInsets.displayCutout
|
val cutoutInsets = WindowInsets.displayCutout
|
||||||
|
|
@ -396,6 +399,7 @@ data class ReaderScreen(val bookId: Int) : Screen, Parcelable {
|
||||||
progressBar = mainState.value.progressBar,
|
progressBar = mainState.value.progressBar,
|
||||||
progressBarPadding = progressBarPadding,
|
progressBarPadding = progressBarPadding,
|
||||||
progressBarAlignment = mainState.value.progressBarAlignment,
|
progressBarAlignment = mainState.value.progressBarAlignment,
|
||||||
|
progressBarFontSize = progressBarFontSize,
|
||||||
paragraphHeight = paragraphHeight,
|
paragraphHeight = paragraphHeight,
|
||||||
sidePadding = sidePadding,
|
sidePadding = sidePadding,
|
||||||
bottomBarPadding = bottomBarPadding,
|
bottomBarPadding = bottomBarPadding,
|
||||||
|
|
|
||||||
|
|
@ -203,8 +203,10 @@
|
||||||
<string name="images_width_option">Розмір</string>
|
<string name="images_width_option">Розмір</string>
|
||||||
<string name="images_color_effects_option">Ефекти кольору</string>
|
<string name="images_color_effects_option">Ефекти кольору</string>
|
||||||
<string name="progress_bar_option">Панель прогресу</string>
|
<string name="progress_bar_option">Панель прогресу</string>
|
||||||
|
<string name="progress_bar_option_desc">Показувати панель прогресу внизу</string>
|
||||||
<string name="progress_bar_padding_option">Поля</string>
|
<string name="progress_bar_padding_option">Поля</string>
|
||||||
<string name="progress_bar_alignment_option">Розташування</string>
|
<string name="progress_bar_alignment_option">Розташування</string>
|
||||||
|
<string name="progress_bar_font_size_option">Розмір шрифта</string>
|
||||||
|
|
||||||
<!-- Browse -->
|
<!-- Browse -->
|
||||||
<string name="browse_files_structure_option">Структура файлів</string>
|
<string name="browse_files_structure_option">Структура файлів</string>
|
||||||
|
|
|
||||||
|
|
@ -260,8 +260,10 @@
|
||||||
<string name="images_width_option">Size</string>
|
<string name="images_width_option">Size</string>
|
||||||
<string name="images_color_effects_option">Color effects</string>
|
<string name="images_color_effects_option">Color effects</string>
|
||||||
<string name="progress_bar_option">Progress bar</string>
|
<string name="progress_bar_option">Progress bar</string>
|
||||||
|
<string name="progress_bar_option_desc">Display progress bar at the bottom</string>
|
||||||
<string name="progress_bar_padding_option">Margins</string>
|
<string name="progress_bar_padding_option">Margins</string>
|
||||||
<string name="progress_bar_alignment_option">Alignment</string>
|
<string name="progress_bar_alignment_option">Alignment</string>
|
||||||
|
<string name="progress_bar_font_size_option">Font size</string>
|
||||||
|
|
||||||
<!-- Browse -->
|
<!-- Browse -->
|
||||||
<string name="browse_files_structure_option">Files structure</string>
|
<string name="browse_files_structure_option">Files structure</string>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue