fix: Ui not visible if Control Panel show
This commit is contained in:
@@ -374,6 +374,9 @@ class ReaderActivity :
|
||||
viewBinding.infoBar.isTimeVisible = isFullscreen
|
||||
updateScrollTimerButton()
|
||||
systemUiController.setSystemUiVisible(isUiVisible || !isFullscreen)
|
||||
val topOffset = if (isUiVisible) viewBinding.appbarTop.height else 0
|
||||
val bottomOffset = if (isUiVisible) (viewBinding.toolbarDocked?.height ?: 0) else 0
|
||||
viewModel.setReaderUiOffsets(topOffset, bottomOffset)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,6 +398,10 @@ class ReaderActivity :
|
||||
viewBinding.infoBar.updatePadding(
|
||||
top = systemBars.top,
|
||||
)
|
||||
viewModel.setReaderUiOffsets(
|
||||
(if (viewBinding.appbarTop.isVisible) viewBinding.appbarTop.height else 0) + systemBars.top,
|
||||
(if (viewBinding.toolbarDocked?.isVisible == true) (viewBinding.toolbarDocked?.height ?: 0) else 0) + systemBars.bottom,
|
||||
)
|
||||
return WindowInsetsCompat.Builder(insets)
|
||||
.setInsets(WindowInsetsCompat.Type.systemBars(), Insets.NONE)
|
||||
.build()
|
||||
|
||||
@@ -120,6 +120,9 @@ class ReaderViewModel @Inject constructor(
|
||||
val onAskNsfwIncognito = MutableEventFlow<Unit>()
|
||||
val uiState = MutableStateFlow<ReaderUiState?>(null)
|
||||
|
||||
val readerUiTopOffset = MutableStateFlow(0)
|
||||
val readerUiBottomOffset = MutableStateFlow(0)
|
||||
|
||||
val isIncognitoMode = MutableStateFlow(savedStateHandle.get<Boolean>(ReaderIntent.EXTRA_INCOGNITO))
|
||||
|
||||
val content = MutableStateFlow(ReaderContent(emptyList(), null))
|
||||
@@ -227,6 +230,11 @@ class ReaderViewModel @Inject constructor(
|
||||
discordRpc.setIdle()
|
||||
}
|
||||
|
||||
fun setReaderUiOffsets(top: Int, bottom: Int) {
|
||||
readerUiTopOffset.value = top
|
||||
readerUiBottomOffset.value = bottom
|
||||
}
|
||||
|
||||
fun switchMode(newMode: ReaderMode) {
|
||||
launchJob {
|
||||
val manga = checkNotNull(getMangaOrNull())
|
||||
|
||||
@@ -49,6 +49,12 @@ class WebtoonReaderFragment : BaseReaderFragment<FragmentReaderWebtoonBinding>()
|
||||
super.onViewBindingCreated(binding, savedInstanceState)
|
||||
var canGoPrev = true
|
||||
var canGoNext = true
|
||||
viewModel.readerUiTopOffset.observe(viewLifecycleOwner) { top ->
|
||||
binding.feedbackTop.translationY = top.toFloat()
|
||||
}
|
||||
viewModel.readerUiBottomOffset.observe(viewLifecycleOwner) { bottom ->
|
||||
binding.feedbackBottom.translationY = -bottom.toFloat()
|
||||
}
|
||||
with(binding.recyclerView) {
|
||||
setHasFixedSize(true)
|
||||
adapter = readerAdapter
|
||||
@@ -59,17 +65,17 @@ class WebtoonReaderFragment : BaseReaderFragment<FragmentReaderWebtoonBinding>()
|
||||
setOnPullGestureListener(object : WebtoonRecyclerView.OnPullGestureListener {
|
||||
override fun onPullProgressTop(progress: Float) {
|
||||
if (canGoPrev) {
|
||||
binding.feedbackTop.setText(R.string.pull_to_prev_chapter)
|
||||
setFeedbackText(binding.feedbackTop, getString(R.string.pull_to_prev_chapter))
|
||||
} else {
|
||||
binding.feedbackTop.setText(R.string.pull_top_no_prev)
|
||||
setFeedbackText(binding.feedbackTop, getString(R.string.pull_top_no_prev))
|
||||
}
|
||||
updateFeedback(binding.feedbackTop, progress)
|
||||
}
|
||||
override fun onPullProgressBottom(progress: Float) {
|
||||
if (canGoNext) {
|
||||
binding.feedbackBottom.setText(R.string.pull_to_next_chapter)
|
||||
setFeedbackText(binding.feedbackBottom, getString(R.string.pull_to_next_chapter))
|
||||
} else {
|
||||
binding.feedbackBottom.setText(R.string.pull_bottom_no_next)
|
||||
setFeedbackText(binding.feedbackBottom, getString(R.string.pull_bottom_no_next))
|
||||
}
|
||||
updateFeedback(binding.feedbackBottom, progress)
|
||||
}
|
||||
@@ -241,3 +247,13 @@ private fun updateFeedback(tv: TextView, progress: Float) {
|
||||
private fun fadeOut(tv: TextView) {
|
||||
tv.animate().alpha(0f).setDuration(150L).start()
|
||||
}
|
||||
|
||||
private fun setFeedbackText(tv: TextView, text: CharSequence) {
|
||||
if (tv.alpha <= 0f && text.isNotEmpty()) {
|
||||
tv.alpha = 0f
|
||||
tv.text = text
|
||||
tv.animate().alpha(1f).setDuration(120L).start()
|
||||
} else {
|
||||
tv.text = text
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user