🛠️ 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
|
package ua.acclorite.book_story.presentation.screens.reader.components
|
||||||
|
|
||||||
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
import androidx.compose.material.icons.rounded.Upgrade
|
import androidx.compose.material.icons.rounded.Upgrade
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import ua.acclorite.book_story.R
|
import ua.acclorite.book_story.R
|
||||||
import ua.acclorite.book_story.presentation.core.components.LocalReaderViewModel
|
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.components.custom_dialog.CustomDialogWithContent
|
||||||
import ua.acclorite.book_story.presentation.core.navigation.LocalOnNavigate
|
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
|
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
|
@Composable
|
||||||
fun ReaderUpdateDialog() {
|
fun ReaderUpdateDialog() {
|
||||||
val state = LocalReaderViewModel.current.state
|
|
||||||
val onEvent = LocalReaderViewModel.current.onEvent
|
val onEvent = LocalReaderViewModel.current.onEvent
|
||||||
val onNavigate = LocalOnNavigate.current
|
val onNavigate = LocalOnNavigate.current
|
||||||
|
val context = LocalContext.current
|
||||||
|
|
||||||
CustomDialogWithContent(
|
CustomDialogWithContent(
|
||||||
title = stringResource(id = R.string.update_book),
|
title = stringResource(id = R.string.update_book),
|
||||||
|
|
@ -31,16 +32,12 @@ fun ReaderUpdateDialog() {
|
||||||
isActionEnabled = true,
|
isActionEnabled = true,
|
||||||
onDismiss = { onEvent(ReaderEvent.OnShowHideUpdateDialog(false)) },
|
onDismiss = { onEvent(ReaderEvent.OnShowHideUpdateDialog(false)) },
|
||||||
onAction = {
|
onAction = {
|
||||||
onNavigate {
|
onEvent(
|
||||||
navigate(
|
ReaderEvent.OnUpdateText(
|
||||||
Screen.BookInfo(
|
activity = context as ComponentActivity,
|
||||||
bookId = state.value.book.id,
|
onNavigate = onNavigate
|
||||||
startUpdate = true
|
|
||||||
),
|
|
||||||
useBackAnimation = true,
|
|
||||||
saveInBackStack = false
|
|
||||||
)
|
)
|
||||||
}
|
)
|
||||||
},
|
},
|
||||||
withDivider = false
|
withDivider = false
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import androidx.activity.ComponentActivity
|
||||||
import androidx.compose.foundation.pager.PagerState
|
import androidx.compose.foundation.pager.PagerState
|
||||||
import androidx.compose.runtime.Immutable
|
import androidx.compose.runtime.Immutable
|
||||||
import ua.acclorite.book_story.domain.model.Book
|
import ua.acclorite.book_story.domain.model.Book
|
||||||
|
import ua.acclorite.book_story.domain.util.OnNavigate
|
||||||
import ua.acclorite.book_story.domain.util.UIText
|
import ua.acclorite.book_story.domain.util.UIText
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
|
|
@ -97,4 +98,9 @@ sealed class ReaderEvent {
|
||||||
) : ReaderEvent()
|
) : ReaderEvent()
|
||||||
|
|
||||||
data object OnCancelCheckTextForUpdate : 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(
|
private fun showSystemBars(
|
||||||
show: Boolean,
|
show: Boolean,
|
||||||
fullscreenMode: Boolean,
|
fullscreenMode: Boolean = true,
|
||||||
activity: ComponentActivity
|
activity: ComponentActivity
|
||||||
): Boolean {
|
): Boolean {
|
||||||
WindowCompat.getInsetsController(
|
WindowCompat.getInsetsController(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue