From 2d01933c288f30e596a76763cc7bf93dd0c5c5c6 Mon Sep 17 00:00:00 2001 From: arkon Date: Sat, 23 Apr 2022 10:57:04 -0400 Subject: [PATCH] Lifted NestedScrollConnection to abstract Compose classes Since it'll likely be used in every controller. --- .../eu/kanade/presentation/history/HistoryScreen.kt | 5 +---- .../ui/base/controller/ComposeController.kt | 12 ++++++++---- .../kanade/tachiyomi/ui/more/LicensesController.kt | 6 ++---- .../tachiyomi/ui/recent/history/HistoryController.kt | 5 +++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt index 02bafed726..228c604789 100644 --- a/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt +++ b/app/src/main/java/eu/kanade/presentation/history/HistoryScreen.kt @@ -32,9 +32,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.nestedScroll -import androidx.compose.ui.platform.ComposeView import androidx.compose.ui.platform.LocalContext -import androidx.compose.ui.platform.rememberNestedScrollInteropConnection import androidx.compose.ui.res.stringResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow @@ -62,13 +60,12 @@ import java.util.Date @Composable fun HistoryScreen( - composeView: ComposeView, + nestedScrollInterop: NestedScrollConnection, presenter: HistoryPresenter, onClickItem: (HistoryWithRelations) -> Unit, onClickResume: (HistoryWithRelations) -> Unit, onClickDelete: (HistoryWithRelations, Boolean) -> Unit, ) { - val nestedScrollInterop = rememberNestedScrollInteropConnection(composeView) val state by presenter.state.collectAsState() val history = state.list?.collectAsLazyPagingItems() when { 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 9f24590eb3..8e2c9ed2e3 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,6 +3,8 @@ package eu.kanade.tachiyomi.ui.base.controller import android.view.LayoutInflater import android.view.View import androidx.compose.runtime.Composable +import androidx.compose.ui.input.nestedscroll.NestedScrollConnection +import androidx.compose.ui.platform.rememberNestedScrollInteropConnection import eu.kanade.presentation.theme.TachiyomiTheme import eu.kanade.tachiyomi.databinding.ComposeControllerBinding import nucleus.presenter.Presenter @@ -19,13 +21,14 @@ abstract class ComposeController

> : NucleusController super.onViewCreated(view) binding.root.setContent { + val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root) TachiyomiTheme { - ComposeContent() + ComposeContent(nestedScrollInterop) } } } - @Composable abstract fun ComposeContent() + @Composable abstract fun ComposeContent(nestedScrollInterop: NestedScrollConnection) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt index cf1661d6a0..9f8c9ef0fb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/LicensesController.kt @@ -5,8 +5,8 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.contentColorFor import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier +import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.nestedScroll -import androidx.compose.ui.platform.rememberNestedScrollInteropConnection import com.mikepenz.aboutlibraries.ui.compose.LibrariesContainer import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults.libraryColors import eu.kanade.tachiyomi.R @@ -17,9 +17,7 @@ class LicensesController : BasicComposeController() { override fun getTitle() = resources?.getString(R.string.licenses) @Composable - override fun ComposeContent() { - val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root) - + override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) { LibrariesContainer( modifier = Modifier .fillMaxSize() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt index f6877b1fca..d2a04a131b 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/recent/history/HistoryController.kt @@ -5,6 +5,7 @@ import android.view.MenuInflater import android.view.MenuItem import androidx.appcompat.widget.SearchView import androidx.compose.runtime.Composable +import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import eu.kanade.domain.chapter.model.Chapter import eu.kanade.presentation.history.HistoryScreen import eu.kanade.tachiyomi.R @@ -28,9 +29,9 @@ class HistoryController : ComposeController(), RootController override fun createPresenter() = HistoryPresenter() @Composable - override fun ComposeContent() { + override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) { HistoryScreen( - composeView = binding.root, + nestedScrollInterop = nestedScrollInterop, presenter = presenter, onClickItem = { history -> router.pushController(MangaController(history).withFadeTransaction())