mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:09:19 +01:00
Adjust inset consumption in Compose controllers (fixes #7085)
Co-authored-by: jobobby04 <jobobby04@users.noreply.github.com>
This commit is contained in:
parent
681e9396b3
commit
6993e88265
@ -3,8 +3,10 @@ package eu.kanade.tachiyomi.ui.base.controller
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
|
import androidx.compose.ui.platform.ViewCompositionStrategy
|
||||||
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||||
import eu.kanade.presentation.theme.TachiyomiTheme
|
import eu.kanade.presentation.theme.TachiyomiTheme
|
||||||
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
||||||
@ -14,62 +16,78 @@ import nucleus.presenter.Presenter
|
|||||||
/**
|
/**
|
||||||
* Compose controller with a Nucleus presenter.
|
* Compose controller with a Nucleus presenter.
|
||||||
*/
|
*/
|
||||||
abstract class ComposeController<P : Presenter<*>>(bundle: Bundle? = null) : NucleusController<ComposeControllerBinding, P>(bundle) {
|
abstract class ComposeController<P : Presenter<*>>(bundle: Bundle? = null) :
|
||||||
|
NucleusController<ComposeControllerBinding, P>(bundle),
|
||||||
|
ComposeContentController {
|
||||||
|
|
||||||
override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
|
override fun createBinding(inflater: LayoutInflater) =
|
||||||
ComposeControllerBinding.inflate(inflater)
|
ComposeControllerBinding.inflate(inflater)
|
||||||
|
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
binding.root.setContent {
|
binding.root.apply {
|
||||||
|
consumeWindowInsets = false
|
||||||
|
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||||
|
setContent {
|
||||||
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
||||||
TachiyomiTheme {
|
TachiyomiTheme {
|
||||||
ComposeContent(nestedScrollInterop)
|
ComposeContent(nestedScrollInterop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Composable abstract fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic Compose controller without a presenter.
|
* Basic Compose controller without a presenter.
|
||||||
*/
|
*/
|
||||||
abstract class BasicComposeController : BaseController<ComposeControllerBinding>() {
|
abstract class BasicComposeController :
|
||||||
|
BaseController<ComposeControllerBinding>(),
|
||||||
|
ComposeContentController {
|
||||||
|
|
||||||
override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
|
override fun createBinding(inflater: LayoutInflater) =
|
||||||
ComposeControllerBinding.inflate(inflater)
|
ComposeControllerBinding.inflate(inflater)
|
||||||
|
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
binding.root.setContent {
|
binding.root.apply {
|
||||||
|
consumeWindowInsets = false
|
||||||
|
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||||
|
setContent {
|
||||||
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
||||||
TachiyomiTheme {
|
TachiyomiTheme {
|
||||||
ComposeContent(nestedScrollInterop)
|
ComposeContent(nestedScrollInterop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Composable abstract fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class SearchableComposeController<P : BasePresenter<*>>(bundle: Bundle? = null) : SearchableNucleusController<ComposeControllerBinding, P>(bundle) {
|
abstract class SearchableComposeController<P : BasePresenter<*>>(bundle: Bundle? = null) :
|
||||||
|
SearchableNucleusController<ComposeControllerBinding, P>(bundle),
|
||||||
|
ComposeContentController {
|
||||||
|
|
||||||
override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
|
override fun createBinding(inflater: LayoutInflater) =
|
||||||
ComposeControllerBinding.inflate(inflater)
|
ComposeControllerBinding.inflate(inflater)
|
||||||
|
|
||||||
override fun onViewCreated(view: View) {
|
override fun onViewCreated(view: View) {
|
||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
binding.root.setContent {
|
binding.root.apply {
|
||||||
|
consumeWindowInsets = false
|
||||||
|
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||||
|
setContent {
|
||||||
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
||||||
TachiyomiTheme {
|
TachiyomiTheme {
|
||||||
ComposeContent(nestedScrollInterop)
|
ComposeContent(nestedScrollInterop)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
@Composable abstract fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
|
}
|
||||||
|
|
||||||
|
interface ComposeContentController {
|
||||||
|
@Composable fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user