fix: 底栏显隐开关
This commit is contained in:
@@ -288,6 +288,7 @@ object ReadBookConfig {
|
||||
parseReadMenuCustomIcons(appCtx.getPrefString(PreferKey.titleBarCustomIcons))
|
||||
private var titleBarIconPositionValue = appCtx.getPrefInt(PreferKey.titleBarIconPosition)
|
||||
private var showTitleBarIconsValue = appCtx.getPrefBoolean(PreferKey.showTitleBarIcons, true)
|
||||
private var readSliderModeValue = appCtx.getPrefString(PreferKey.readSliderMode) ?: "0"
|
||||
|
||||
fun syncPreferences(preferences: ReadPreferences) {
|
||||
readBodyToLhValue = preferences.readBodyToLh
|
||||
@@ -329,6 +330,7 @@ object ReadBookConfig {
|
||||
titleBarCustomIconsValue = parseReadMenuCustomIcons(preferences.titleBarCustomIcons)
|
||||
titleBarIconPositionValue = preferences.titleBarIconPosition
|
||||
showTitleBarIconsValue = preferences.showTitleBarIcons
|
||||
readSliderModeValue = preferences.readSliderMode
|
||||
}
|
||||
|
||||
var readMenuBgColor: Int
|
||||
@@ -540,6 +542,12 @@ object ReadBookConfig {
|
||||
showTitleBarIconsValue = value
|
||||
}
|
||||
|
||||
var readSliderMode: String
|
||||
get() = readSliderModeValue
|
||||
set(value) {
|
||||
readSliderModeValue = value
|
||||
}
|
||||
|
||||
fun encodeReadMenuCustomIcons(value: Map<String, String>): String {
|
||||
return GSON.toJson(value.filterValues { it.isNotBlank() })
|
||||
}
|
||||
|
||||
@@ -178,6 +178,7 @@ data class ReadMenuConfig(
|
||||
val readMenuBottomBarBlurStyle: Int = ReadMenuBlurStyle.Solid,
|
||||
val readMenuIconStyle: Int = 0,
|
||||
val readMenuIconShowText: Boolean = true,
|
||||
val readSliderMode: String = "0",
|
||||
val titleBarCustomIcons: ImmutableMap<String, String> = persistentMapOf(),
|
||||
val readMenuCustomIcons: ImmutableMap<String, String> = persistentMapOf(),
|
||||
val titleBarButtons: ImmutableList<ReadBookButtonConfigItem> = persistentListOf(),
|
||||
|
||||
@@ -1400,51 +1400,53 @@ private fun MenuBottomBar(
|
||||
.animateContentSize(),
|
||||
) {
|
||||
// Seek bar row: prev + slider + next
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
.padding(horizontal = 16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
BottomBarGlassIconButton(
|
||||
onClick = { onIntent(ReadBookIntent.PrevChapter) },
|
||||
icon = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
colors = colors,
|
||||
backdrop = backdrop,
|
||||
menuConfig = state.menuConfig,
|
||||
glassEnabled = buttonGlassEnabled,
|
||||
)
|
||||
|
||||
ReadMenuSlider(
|
||||
value = sliderValue.coerceIn(0f, sliderMax),
|
||||
onValueChange = { value ->
|
||||
sliderDragging = true
|
||||
sliderValue = value.coerceIn(0f, sliderMax)
|
||||
},
|
||||
onValueChangeFinished = {
|
||||
commitSliderValue(sliderValue)
|
||||
},
|
||||
onValueCommit = ::commitSliderValue,
|
||||
valueRange = 0f..sliderMax,
|
||||
steps = (seekMax - 1).coerceAtLeast(0),
|
||||
enabled = seekMax > 0,
|
||||
backdrop = backdrop,
|
||||
glassThumbEnabled = buttonGlassEnabled,
|
||||
AnimatedVisibility(visible = state.menuConfig.readSliderMode != "1") {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 8.dp)
|
||||
)
|
||||
.fillMaxWidth()
|
||||
.padding(vertical = 4.dp)
|
||||
.padding(horizontal = 16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
||||
) {
|
||||
BottomBarGlassIconButton(
|
||||
onClick = { onIntent(ReadBookIntent.PrevChapter) },
|
||||
icon = Icons.AutoMirrored.Filled.ArrowBack,
|
||||
colors = colors,
|
||||
backdrop = backdrop,
|
||||
menuConfig = state.menuConfig,
|
||||
glassEnabled = buttonGlassEnabled,
|
||||
)
|
||||
|
||||
BottomBarGlassIconButton(
|
||||
onClick = { onIntent(ReadBookIntent.NextChapter) },
|
||||
icon = Icons.AutoMirrored.Filled.ArrowForward,
|
||||
colors = colors,
|
||||
backdrop = backdrop,
|
||||
menuConfig = state.menuConfig,
|
||||
glassEnabled = buttonGlassEnabled,
|
||||
)
|
||||
ReadMenuSlider(
|
||||
value = sliderValue.coerceIn(0f, sliderMax),
|
||||
onValueChange = { value ->
|
||||
sliderDragging = true
|
||||
sliderValue = value.coerceIn(0f, sliderMax)
|
||||
},
|
||||
onValueChangeFinished = {
|
||||
commitSliderValue(sliderValue)
|
||||
},
|
||||
onValueCommit = ::commitSliderValue,
|
||||
valueRange = 0f..sliderMax,
|
||||
steps = (seekMax - 1).coerceAtLeast(0),
|
||||
enabled = seekMax > 0,
|
||||
backdrop = backdrop,
|
||||
glassThumbEnabled = buttonGlassEnabled,
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.padding(horizontal = 8.dp)
|
||||
)
|
||||
|
||||
BottomBarGlassIconButton(
|
||||
onClick = { onIntent(ReadBookIntent.NextChapter) },
|
||||
icon = Icons.AutoMirrored.Filled.ArrowForward,
|
||||
colors = colors,
|
||||
backdrop = backdrop,
|
||||
menuConfig = state.menuConfig,
|
||||
glassEnabled = buttonGlassEnabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(8.dp))
|
||||
|
||||
@@ -1348,6 +1348,7 @@ class ReadBookViewModel(
|
||||
readMenuBottomBarBlurStyle = ReadBookConfig.readMenuBottomBarBlurStyle,
|
||||
readMenuIconStyle = ReadBookConfig.readMenuIconStyle,
|
||||
readMenuIconShowText = ReadBookConfig.readMenuIconShowText,
|
||||
readSliderMode = ReadBookConfig.readSliderMode,
|
||||
titleBarCustomIcons = ReadBookConfig.titleBarCustomIcons.toImmutableMap(),
|
||||
readMenuCustomIcons = ReadBookConfig.readMenuCustomIcons.toImmutableMap(),
|
||||
titleBarButtons = current.menuConfig.titleBarButtons,
|
||||
@@ -2518,10 +2519,13 @@ class ReadBookViewModel(
|
||||
}
|
||||
}
|
||||
is ConfigUpdate.ReadSliderMode -> {
|
||||
ReadBookConfig.readSliderMode = update.value
|
||||
viewModelScope.launch {
|
||||
readSettingsRepository.setReadSliderMode(update.value)
|
||||
}
|
||||
postEvent(EventBus.UPDATE_READ_ACTION_BAR, true)
|
||||
_uiState.update {
|
||||
it.copy(menuConfig = it.menuConfig.copy(readSliderMode = update.value))
|
||||
}
|
||||
}
|
||||
is ConfigUpdate.DoubleHorizontalPage -> {
|
||||
viewModelScope.launch {
|
||||
|
||||
@@ -97,9 +97,6 @@ fun MoreConfigSheet(
|
||||
SectionTitle(stringResource(R.string.page_control))
|
||||
PageControlSettings(
|
||||
preferences = preferences,
|
||||
onReadSliderModeChange = {
|
||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ReadSliderMode(it)))
|
||||
},
|
||||
onDoubleHorizontalPageChange = {
|
||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.DoubleHorizontalPage(it)))
|
||||
},
|
||||
@@ -248,7 +245,6 @@ private fun ScreenSettings(
|
||||
@Composable
|
||||
private fun PageControlSettings(
|
||||
preferences: ReadPreferences,
|
||||
onReadSliderModeChange: (String) -> Unit,
|
||||
onDoubleHorizontalPageChange: (String) -> Unit,
|
||||
onProgressBarBehaviorChange: (String) -> Unit,
|
||||
onMouseWheelPageChange: (Boolean) -> Unit,
|
||||
@@ -256,20 +252,11 @@ private fun PageControlSettings(
|
||||
onVolumeKeyPageOnPlayChange: (Boolean) -> Unit,
|
||||
onKeyPageOnLongPressChange: (Boolean) -> Unit,
|
||||
) {
|
||||
val readSliderModeEntries = stringArrayResource(R.array.read_slider_mode)
|
||||
val readSliderModeValues = stringArrayResource(R.array.read_slider_mode_value)
|
||||
val doublePageEntries = stringArrayResource(R.array.double_page_title)
|
||||
val doublePageValues = stringArrayResource(R.array.double_page_value)
|
||||
val progressBarEntries = stringArrayResource(R.array.progress_bar_behavior_title)
|
||||
val progressBarValues = stringArrayResource(R.array.progress_bar_behavior_value)
|
||||
|
||||
TinyDropdownSettingItem(
|
||||
title = stringResource(R.string.read_slider_mode),
|
||||
selectedValue = preferences.readSliderMode,
|
||||
displayEntries = readSliderModeEntries,
|
||||
entryValues = readSliderModeValues,
|
||||
onValueChange = onReadSliderModeChange,
|
||||
)
|
||||
TinyDropdownSettingItem(
|
||||
title = stringResource(R.string.double_page_horizontal),
|
||||
selectedValue = preferences.doubleHorizontalPage,
|
||||
|
||||
@@ -419,6 +419,7 @@ private fun BottomBarTab(
|
||||
onShowIconSheet: () -> Unit,
|
||||
onShowColorPicker: (Int, Int) -> Unit,
|
||||
) {
|
||||
var readSliderMode by remember { mutableStateOf(preferences.readSliderMode) }
|
||||
var showIconText by remember { mutableStateOf(preferences.readMenuIconShowText) }
|
||||
var iconStyle by remember { mutableIntStateOf(preferences.readMenuIconStyle) }
|
||||
var iconsPerRow by remember { mutableIntStateOf(preferences.readMenuIconItemsPerRow) }
|
||||
@@ -440,6 +441,20 @@ private fun BottomBarTab(
|
||||
.padding(horizontal = 16.dp)
|
||||
.verticalScroll(rememberScrollState()),
|
||||
) {
|
||||
val readSliderModeEntries = stringArrayResource(R.array.read_slider_mode)
|
||||
val readSliderModeValues = stringArrayResource(R.array.read_slider_mode_value)
|
||||
|
||||
TinyDropdownSettingItem(
|
||||
title = stringResource(R.string.read_slider_mode),
|
||||
selectedValue = readSliderMode,
|
||||
displayEntries = readSliderModeEntries,
|
||||
entryValues = readSliderModeValues,
|
||||
onValueChange = {
|
||||
readSliderMode = it
|
||||
onIntent(ReadBookIntent.UpdateConfig(ConfigUpdate.ReadSliderMode(it)))
|
||||
},
|
||||
)
|
||||
|
||||
SectionTitle(stringResource(R.string.read_menu_icon_style))
|
||||
|
||||
TinySwitchSettingItem(
|
||||
|
||||
@@ -210,9 +210,6 @@
|
||||
<string-array name="read_slider_mode">
|
||||
<item>常驻</item>
|
||||
<item>不显示</item>
|
||||
<item>按钮置左</item>
|
||||
<item>按钮置右</item>
|
||||
<item>仅显示滑动条</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="title_bar_mode">
|
||||
|
||||
@@ -123,9 +123,6 @@
|
||||
<string-array name="read_slider_mode_value">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
<item>3</item>
|
||||
<item>4</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="title_bar_mode_value">
|
||||
|
||||
@@ -103,9 +103,6 @@
|
||||
<string-array name="read_slider_mode">
|
||||
<item>Always</item>
|
||||
<item>Disable</item>
|
||||
<item>Left button</item>
|
||||
<item>Right button</item>
|
||||
<item>Only slider</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="title_bar_mode">
|
||||
|
||||
Reference in New Issue
Block a user