🛠️ Hide systemBars only after successfully loading a book in Reader
This commit is contained in:
parent
b637d9cac9
commit
c37fd7b06f
2 changed files with 18 additions and 15 deletions
|
|
@ -7,7 +7,10 @@ import ua.acclorite.book_story.domain.reader.ReaderText.Chapter
|
|||
@Immutable
|
||||
sealed class ReaderEvent {
|
||||
|
||||
data object OnLoadText : ReaderEvent()
|
||||
data class OnLoadText(
|
||||
val activity: ComponentActivity,
|
||||
val fullscreenMode: Boolean
|
||||
) : ReaderEvent()
|
||||
|
||||
data class OnMenuVisibility(
|
||||
val show: Boolean,
|
||||
|
|
|
|||
|
|
@ -80,14 +80,21 @@ class ReaderModel @Inject constructor(
|
|||
errorMessage = UIText.StringResource(R.string.error_could_not_get_text)
|
||||
)
|
||||
}
|
||||
systemBarsVisibility(show = true, activity = event.activity)
|
||||
return@launch
|
||||
}
|
||||
|
||||
systemBarsVisibility(
|
||||
show = !event.fullscreenMode,
|
||||
activity = event.activity
|
||||
)
|
||||
|
||||
val lastOpened = getLatestHistory.execute(_state.value.book.id)?.time
|
||||
yield()
|
||||
|
||||
_state.update {
|
||||
it.copy(
|
||||
showMenu = false,
|
||||
book = it.book.copy(
|
||||
lastOpened = lastOpened
|
||||
),
|
||||
|
|
@ -131,23 +138,19 @@ class ReaderModel @Inject constructor(
|
|||
|
||||
is ReaderEvent.OnMenuVisibility -> {
|
||||
launch {
|
||||
if (_state.value.lockMenu) {
|
||||
return@launch
|
||||
}
|
||||
|
||||
val shouldShow = event.show
|
||||
if (_state.value.lockMenu) return@launch
|
||||
|
||||
yield()
|
||||
|
||||
systemBarsVisibility(
|
||||
show = shouldShow || !event.fullscreenMode,
|
||||
show = event.show || !event.fullscreenMode,
|
||||
activity = event.activity
|
||||
)
|
||||
_state.update {
|
||||
it.copy(
|
||||
showMenu = shouldShow,
|
||||
showMenu = event.show,
|
||||
checkpoint = _state.value.listState.run {
|
||||
if (!shouldShow || !event.saveCheckpoint) return@run it.checkpoint
|
||||
if (!event.show || !event.saveCheckpoint) return@run it.checkpoint
|
||||
|
||||
Checkpoint(firstVisibleItemIndex, firstVisibleItemScrollOffset)
|
||||
}
|
||||
|
|
@ -475,14 +478,11 @@ class ReaderModel @Inject constructor(
|
|||
}
|
||||
|
||||
onEvent(
|
||||
ReaderEvent.OnMenuVisibility(
|
||||
show = false,
|
||||
fullscreenMode = fullscreenMode,
|
||||
saveCheckpoint = false,
|
||||
activity = activity
|
||||
ReaderEvent.OnLoadText(
|
||||
activity = activity,
|
||||
fullscreenMode = fullscreenMode
|
||||
)
|
||||
)
|
||||
onEvent(ReaderEvent.OnLoadText)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue