mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 16:25:08 +01:00
Lifted NestedScrollConnection to abstract Compose classes
Since it'll likely be used in every controller.
This commit is contained in:
parent
bf0bb5aa88
commit
2d01933c28
@ -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 {
|
||||
|
@ -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<P : Presenter<*>> : NucleusController<ComposeCo
|
||||
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)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,11 +43,12 @@ abstract class BasicComposeController : BaseController<ComposeControllerBinding>
|
||||
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)
|
||||
}
|
||||
|
@ -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()
|
||||
|
@ -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<HistoryPresenter>(), 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())
|
||||
|
Loading…
Reference in New Issue
Block a user