diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt
index cc3926e67..44f32c244 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/ComposeController.kt
@@ -3,8 +3,10 @@ package eu.kanade.tachiyomi.ui.base.controller
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
+import androidx.compose.foundation.layout.consumeWindowInsets
import androidx.compose.runtime.Composable
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
+import androidx.compose.ui.platform.ViewCompositionStrategy
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import eu.kanade.presentation.theme.TachiyomiTheme
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
@@ -14,62 +16,78 @@ import nucleus.presenter.Presenter
/**
* Compose controller with a Nucleus presenter.
*/
-abstract class ComposeController
>(bundle: Bundle? = null) : NucleusController(bundle) {
+abstract class ComposeController>(bundle: Bundle? = null) :
+ NucleusController(bundle),
+ ComposeContentController {
- override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
+ override fun createBinding(inflater: LayoutInflater) =
ComposeControllerBinding.inflate(inflater)
override fun onViewCreated(view: View) {
super.onViewCreated(view)
- binding.root.setContent {
- val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
- TachiyomiTheme {
- ComposeContent(nestedScrollInterop)
+ binding.root.apply {
+ consumeWindowInsets = false
+ setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
+ setContent {
+ val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
+ TachiyomiTheme {
+ ComposeContent(nestedScrollInterop)
+ }
}
}
}
-
- @Composable abstract fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
}
/**
* Basic Compose controller without a presenter.
*/
-abstract class BasicComposeController : BaseController() {
+abstract class BasicComposeController :
+ BaseController(),
+ ComposeContentController {
- override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
+ override fun createBinding(inflater: LayoutInflater) =
ComposeControllerBinding.inflate(inflater)
override fun onViewCreated(view: View) {
super.onViewCreated(view)
- binding.root.setContent {
- val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
- TachiyomiTheme {
- ComposeContent(nestedScrollInterop)
+ binding.root.apply {
+ consumeWindowInsets = false
+ setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
+ setContent {
+ val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
+ TachiyomiTheme {
+ ComposeContent(nestedScrollInterop)
+ }
}
}
}
-
- @Composable abstract fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
}
-abstract class SearchableComposeController>(bundle: Bundle? = null) : SearchableNucleusController(bundle) {
+abstract class SearchableComposeController>(bundle: Bundle? = null) :
+ SearchableNucleusController(bundle),
+ ComposeContentController {
- override fun createBinding(inflater: LayoutInflater): ComposeControllerBinding =
+ override fun createBinding(inflater: LayoutInflater) =
ComposeControllerBinding.inflate(inflater)
override fun onViewCreated(view: View) {
super.onViewCreated(view)
- binding.root.setContent {
- val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
- TachiyomiTheme {
- ComposeContent(nestedScrollInterop)
+ binding.root.apply {
+ consumeWindowInsets = false
+ setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
+ setContent {
+ val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
+ TachiyomiTheme {
+ ComposeContent(nestedScrollInterop)
+ }
}
}
}
-
- @Composable abstract fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
+}
+
+interface ComposeContentController {
+ @Composable fun ComposeContent(nestedScrollInterop: NestedScrollConnection)
}