🛠️ Show bars before update
* Fixed visual bug, where bars being shown after navigating to BookInfo screen for text update
This commit is contained in:
parent
621f9b11c5
commit
7e0e903a5c
3 changed files with 34 additions and 12 deletions
|
|
@ -1,14 +1,15 @@
|
|||
package ua.acclorite.book_story.presentation.screens.reader.components
|
||||
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Upgrade
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import ua.acclorite.book_story.R
|
||||
import ua.acclorite.book_story.presentation.core.components.LocalReaderViewModel
|
||||
import ua.acclorite.book_story.presentation.core.components.custom_dialog.CustomDialogWithContent
|
||||
import ua.acclorite.book_story.presentation.core.navigation.LocalOnNavigate
|
||||
import ua.acclorite.book_story.presentation.core.navigation.Screen
|
||||
import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
||||
|
||||
/**
|
||||
|
|
@ -17,9 +18,9 @@ import ua.acclorite.book_story.presentation.screens.reader.data.ReaderEvent
|
|||
*/
|
||||
@Composable
|
||||
fun ReaderUpdateDialog() {
|
||||
val state = LocalReaderViewModel.current.state
|
||||
val onEvent = LocalReaderViewModel.current.onEvent
|
||||
val onNavigate = LocalOnNavigate.current
|
||||
val context = LocalContext.current
|
||||
|
||||
CustomDialogWithContent(
|
||||
title = stringResource(id = R.string.update_book),
|
||||
|
|
@ -31,16 +32,12 @@ fun ReaderUpdateDialog() {
|
|||
isActionEnabled = true,
|
||||
onDismiss = { onEvent(ReaderEvent.OnShowHideUpdateDialog(false)) },
|
||||
onAction = {
|
||||
onNavigate {
|
||||
navigate(
|
||||
Screen.BookInfo(
|
||||
bookId = state.value.book.id,
|
||||
startUpdate = true
|
||||
),
|
||||
useBackAnimation = true,
|
||||
saveInBackStack = false
|
||||
onEvent(
|
||||
ReaderEvent.OnUpdateText(
|
||||
activity = context as ComponentActivity,
|
||||
onNavigate = onNavigate
|
||||
)
|
||||
)
|
||||
}
|
||||
},
|
||||
withDivider = false
|
||||
)
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import androidx.activity.ComponentActivity
|
|||
import androidx.compose.foundation.pager.PagerState
|
||||
import androidx.compose.runtime.Immutable
|
||||
import ua.acclorite.book_story.domain.model.Book
|
||||
import ua.acclorite.book_story.domain.util.OnNavigate
|
||||
import ua.acclorite.book_story.domain.util.UIText
|
||||
|
||||
@Immutable
|
||||
|
|
@ -97,4 +98,9 @@ sealed class ReaderEvent {
|
|||
) : ReaderEvent()
|
||||
|
||||
data object OnCancelCheckTextForUpdate : ReaderEvent()
|
||||
|
||||
data class OnUpdateText(
|
||||
val activity: ComponentActivity,
|
||||
val onNavigate: OnNavigate
|
||||
) : ReaderEvent()
|
||||
}
|
||||
|
|
@ -498,6 +498,25 @@ class ReaderViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
is ReaderEvent.OnUpdateText -> {
|
||||
launch {
|
||||
showSystemBars(
|
||||
show = true,
|
||||
activity = event.activity
|
||||
)
|
||||
event.onNavigate {
|
||||
navigate(
|
||||
Screen.BookInfo(
|
||||
bookId = _state.value.book.id,
|
||||
startUpdate = true
|
||||
),
|
||||
useBackAnimation = true,
|
||||
saveInBackStack = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -656,7 +675,7 @@ class ReaderViewModel @Inject constructor(
|
|||
|
||||
private fun showSystemBars(
|
||||
show: Boolean,
|
||||
fullscreenMode: Boolean,
|
||||
fullscreenMode: Boolean = true,
|
||||
activity: ComponentActivity
|
||||
): Boolean {
|
||||
WindowCompat.getInsetsController(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue