fix: 阅读界面相关优化
This commit is contained in:
5 files changed
+50
-13
No files matched your search
@@ -259,6 +259,8 @@ sealed interface ReadBookIntent {
|
|||||||
data class SetSearchResultIndex(val index: Int) : ReadBookIntent
|
data class SetSearchResultIndex(val index: Int) : ReadBookIntent
|
||||||
data class SetShowingSearchResult(val value: Boolean) : ReadBookIntent
|
data class SetShowingSearchResult(val value: Boolean) : ReadBookIntent
|
||||||
data class NavigateToSearchResult(val result: SearchResult, val index: Int) : ReadBookIntent
|
data class NavigateToSearchResult(val result: SearchResult, val index: Int) : ReadBookIntent
|
||||||
|
data object RestoreLastBookProgress : ReadBookIntent
|
||||||
|
data object KeepCurrentBookProgress : ReadBookIntent
|
||||||
|
|
||||||
// Read aloud
|
// Read aloud
|
||||||
data object ToggleReadAloud : ReadBookIntent
|
data object ToggleReadAloud : ReadBookIntent
|
||||||
@@ -670,6 +672,7 @@ sealed interface ReadBookSheet {
|
|||||||
sealed interface ReadBookDialog {
|
sealed interface ReadBookDialog {
|
||||||
data class ConfirmRestoreProgress(val progress: BookProgress) : ReadBookDialog
|
data class ConfirmRestoreProgress(val progress: BookProgress) : ReadBookDialog
|
||||||
data class SureSyncProgress(val progress: BookProgress) : ReadBookDialog
|
data class SureSyncProgress(val progress: BookProgress) : ReadBookDialog
|
||||||
|
data object RestoreLastBookProgress : ReadBookDialog
|
||||||
data object ConfirmSkipToChapter : ReadBookDialog
|
data object ConfirmSkipToChapter : ReadBookDialog
|
||||||
data class ConfirmChapterPay(val chapterTitle: String) : ReadBookDialog
|
data class ConfirmChapterPay(val chapterTitle: String) : ReadBookDialog
|
||||||
}
|
}
|
||||||
@@ -1070,7 +1073,10 @@ sealed interface ConfigUpdate {
|
|||||||
override val actions = emptySet<ConfigUpdateAction>()
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
}
|
}
|
||||||
data class DoubleHorizontalPage(val value: String) : ConfigUpdate {
|
data class DoubleHorizontalPage(val value: String) : ConfigUpdate {
|
||||||
override val actions = emptySet<ConfigUpdateAction>()
|
override val actions = setOf(
|
||||||
|
ConfigUpdateAction.UpdateLayout,
|
||||||
|
ConfigUpdateAction.ReloadContent,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
data class ProgressBarBehavior(val value: String) : ConfigUpdate {
|
data class ProgressBarBehavior(val value: String) : ConfigUpdate {
|
||||||
override val actions = emptySet<ConfigUpdateAction>()
|
override val actions = emptySet<ConfigUpdateAction>()
|
||||||
|
|||||||
@@ -682,7 +682,7 @@ class ReadBookController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
is ReadBookEffect.UpScreenTimeOut -> {
|
is ReadBookEffect.UpScreenTimeOut -> {
|
||||||
screenOffTimerStart()
|
upScreenTimeOut()
|
||||||
}
|
}
|
||||||
|
|
||||||
is ReadBookEffect.ToggleBrightnessAuto -> {
|
is ReadBookEffect.ToggleBrightnessAuto -> {
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ private fun MenuTitleBar(
|
|||||||
) {
|
) {
|
||||||
// Back button
|
// Back button
|
||||||
MenuTitleGlassButton(
|
MenuTitleGlassButton(
|
||||||
onClick = { onIntent(ReadBookIntent.ReadMenuBack) },
|
onClick = { onIntent(ReadBookIntent.CloseReadBook) },
|
||||||
icon = Icons.AutoMirrored.Filled.ArrowBack,
|
icon = Icons.AutoMirrored.Filled.ArrowBack,
|
||||||
contentDescription = "Back",
|
contentDescription = "Back",
|
||||||
state = state,
|
state = state,
|
||||||
@@ -1156,15 +1156,15 @@ private fun ReadMenuGlassButtonSurface(
|
|||||||
) {
|
) {
|
||||||
val shape = CircleShape
|
val shape = CircleShape
|
||||||
val tint = when {
|
val tint = when {
|
||||||
selected -> LegadoTheme.colorScheme.onPrimaryContainer
|
selected -> LegadoTheme.colorScheme.primary
|
||||||
else -> LegadoTheme.colorScheme.onSurfaceVariant
|
else -> LegadoTheme.colorScheme.onSurfaceVariant
|
||||||
}
|
}
|
||||||
val containerColor = when {
|
val containerColor = when {
|
||||||
selected -> LegadoTheme.colorScheme.primaryContainer
|
selected -> LegadoTheme.colorScheme.secondaryContainer
|
||||||
else -> LegadoTheme.colorScheme.surfaceContainerLow
|
else -> LegadoTheme.colorScheme.surfaceContainerLow
|
||||||
}
|
}
|
||||||
val border = if (selected) {
|
val border = if (selected) {
|
||||||
BorderStroke(1.5.dp, LegadoTheme.colorScheme.primary)
|
BorderStroke(1.5.dp, LegadoTheme.colorScheme.secondary)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
@@ -1973,6 +1973,7 @@ private fun ReadMenuLiquidSlider(
|
|||||||
val accentColor = LegadoTheme.colorScheme.secondary
|
val accentColor = LegadoTheme.colorScheme.secondary
|
||||||
val trackColor = LegadoTheme.colorScheme.surfaceContainerLow
|
val trackColor = LegadoTheme.colorScheme.surfaceContainerLow
|
||||||
val thumbColor = Color.White.copy(alpha = 0.9f).compositeOver(LegadoTheme.colorScheme.surfaceContainerLow)
|
val thumbColor = Color.White.copy(alpha = 0.9f).compositeOver(LegadoTheme.colorScheme.surfaceContainerLow)
|
||||||
|
val enabledAlpha = if (enabled) 1f else 0.38f
|
||||||
|
|
||||||
val trackBackdrop = rememberLayerBackdrop()
|
val trackBackdrop = rememberLayerBackdrop()
|
||||||
|
|
||||||
@@ -2051,7 +2052,7 @@ private fun ReadMenuLiquidSlider(
|
|||||||
},
|
},
|
||||||
innerShadow = null,
|
innerShadow = null,
|
||||||
onDrawSurface = {
|
onDrawSurface = {
|
||||||
drawRect(trackColor)
|
drawRect(trackColor.copy(alpha = enabledAlpha))
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.pointerInput(enabled, animationScope, isLtr, trackWidth) {
|
.pointerInput(enabled, animationScope, isLtr, trackWidth) {
|
||||||
@@ -2072,7 +2073,7 @@ private fun ReadMenuLiquidSlider(
|
|||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.clip(ContinuousCapsule)
|
.clip(ContinuousCapsule)
|
||||||
.background(accentColor)
|
.background(accentColor.copy(alpha = enabledAlpha))
|
||||||
.height(6f.dp)
|
.height(6f.dp)
|
||||||
.layout { measurable, constraints ->
|
.layout { measurable, constraints ->
|
||||||
val placeable = measurable.measure(constraints)
|
val placeable = measurable.measure(constraints)
|
||||||
@@ -2087,12 +2088,13 @@ private fun ReadMenuLiquidSlider(
|
|||||||
Box(
|
Box(
|
||||||
Modifier
|
Modifier
|
||||||
.graphicsLayer {
|
.graphicsLayer {
|
||||||
|
alpha = enabledAlpha
|
||||||
translationX =
|
translationX =
|
||||||
(-size.width / 2f + trackWidth * progress)
|
(-size.width / 2f + trackWidth * progress)
|
||||||
.coerceIn(-size.width / 4f, trackWidth - size.width * 3f / 4f) *
|
.coerceIn(-size.width / 4f, trackWidth - size.width * 3f / 4f) *
|
||||||
if (isLtr) 1f else -1f
|
if (isLtr) 1f else -1f
|
||||||
}
|
}
|
||||||
.then(dampedDragAnimation.modifier)
|
.then(if (enabled) dampedDragAnimation.modifier else Modifier)
|
||||||
.drawBackdrop(
|
.drawBackdrop(
|
||||||
backdrop = rememberCombinedBackdrop(
|
backdrop = rememberCombinedBackdrop(
|
||||||
backdrop,
|
backdrop,
|
||||||
@@ -2724,6 +2726,7 @@ private fun BrightnessBar(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun commitSliderValue(value: Float) {
|
fun commitSliderValue(value: Float) {
|
||||||
|
if (brightnessAuto) return
|
||||||
val target = value.roundToInt().coerceIn(0, 100)
|
val target = value.roundToInt().coerceIn(0, 100)
|
||||||
sliderDragging = false
|
sliderDragging = false
|
||||||
sliderValue = target.toFloat()
|
sliderValue = target.toFloat()
|
||||||
@@ -2751,6 +2754,7 @@ private fun BrightnessBar(
|
|||||||
AppVerticalSlider(
|
AppVerticalSlider(
|
||||||
value = sliderValue.coerceIn(0f, 100f),
|
value = sliderValue.coerceIn(0f, 100f),
|
||||||
onValueChange = { value ->
|
onValueChange = { value ->
|
||||||
|
if (brightnessAuto) return@AppVerticalSlider
|
||||||
sliderDragging = true
|
sliderDragging = true
|
||||||
sliderValue = value.coerceIn(0f, 100f)
|
sliderValue = value.coerceIn(0f, 100f)
|
||||||
},
|
},
|
||||||
@@ -2793,6 +2797,7 @@ private fun BrightnessBar(
|
|||||||
ReadMenuSlider(
|
ReadMenuSlider(
|
||||||
value = sliderValue.coerceIn(0f, 100f),
|
value = sliderValue.coerceIn(0f, 100f),
|
||||||
onValueChange = { value ->
|
onValueChange = { value ->
|
||||||
|
if (brightnessAuto) return@ReadMenuSlider
|
||||||
sliderDragging = true
|
sliderDragging = true
|
||||||
sliderValue = value.coerceIn(0f, 100f)
|
sliderValue = value.coerceIn(0f, 100f)
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ fun ReadBookScreen(
|
|||||||
// Dialogs driven by activeDialog state
|
// Dialogs driven by activeDialog state
|
||||||
val restoreDialog = state.activeDialog as? ReadBookDialog.ConfirmRestoreProgress
|
val restoreDialog = state.activeDialog as? ReadBookDialog.ConfirmRestoreProgress
|
||||||
val syncDialog = state.activeDialog as? ReadBookDialog.SureSyncProgress
|
val syncDialog = state.activeDialog as? ReadBookDialog.SureSyncProgress
|
||||||
|
val restoreLastProgressDialog = state.activeDialog as? ReadBookDialog.RestoreLastBookProgress
|
||||||
val skipDialog = state.activeDialog as? ReadBookDialog.ConfirmSkipToChapter
|
val skipDialog = state.activeDialog as? ReadBookDialog.ConfirmSkipToChapter
|
||||||
val payDialog = state.activeDialog as? ReadBookDialog.ConfirmChapterPay
|
val payDialog = state.activeDialog as? ReadBookDialog.ConfirmChapterPay
|
||||||
|
|
||||||