mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 17:05:07 +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.Modifier
|
||||||
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||||
import androidx.compose.ui.platform.ComposeView
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.font.FontWeight
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
import androidx.compose.ui.text.style.TextOverflow
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
@ -62,13 +60,12 @@ import java.util.Date
|
|||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun HistoryScreen(
|
fun HistoryScreen(
|
||||||
composeView: ComposeView,
|
nestedScrollInterop: NestedScrollConnection,
|
||||||
presenter: HistoryPresenter,
|
presenter: HistoryPresenter,
|
||||||
onClickItem: (HistoryWithRelations) -> Unit,
|
onClickItem: (HistoryWithRelations) -> Unit,
|
||||||
onClickResume: (HistoryWithRelations) -> Unit,
|
onClickResume: (HistoryWithRelations) -> Unit,
|
||||||
onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
onClickDelete: (HistoryWithRelations, Boolean) -> Unit,
|
||||||
) {
|
) {
|
||||||
val nestedScrollInterop = rememberNestedScrollInteropConnection(composeView)
|
|
||||||
val state by presenter.state.collectAsState()
|
val state by presenter.state.collectAsState()
|
||||||
val history = state.list?.collectAsLazyPagingItems()
|
val history = state.list?.collectAsLazyPagingItems()
|
||||||
when {
|
when {
|
||||||
|
@ -3,6 +3,8 @@ package eu.kanade.tachiyomi.ui.base.controller
|
|||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.compose.runtime.Composable
|
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.presentation.theme.TachiyomiTheme
|
||||||
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
import eu.kanade.tachiyomi.databinding.ComposeControllerBinding
|
||||||
import nucleus.presenter.Presenter
|
import nucleus.presenter.Presenter
|
||||||
@ -19,13 +21,14 @@ abstract class ComposeController<P : Presenter<*>> : NucleusController<ComposeCo
|
|||||||
super.onViewCreated(view)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
binding.root.setContent {
|
binding.root.setContent {
|
||||||
|
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
||||||
TachiyomiTheme {
|
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)
|
super.onViewCreated(view)
|
||||||
|
|
||||||
binding.root.setContent {
|
binding.root.setContent {
|
||||||
|
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
||||||
TachiyomiTheme {
|
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.material3.contentColorFor
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
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.LibrariesContainer
|
||||||
import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults.libraryColors
|
import com.mikepenz.aboutlibraries.ui.compose.LibraryDefaults.libraryColors
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -17,9 +17,7 @@ class LicensesController : BasicComposeController() {
|
|||||||
override fun getTitle() = resources?.getString(R.string.licenses)
|
override fun getTitle() = resources?.getString(R.string.licenses)
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun ComposeContent() {
|
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
||||||
val nestedScrollInterop = rememberNestedScrollInteropConnection(binding.root)
|
|
||||||
|
|
||||||
LibrariesContainer(
|
LibrariesContainer(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
|
@ -5,6 +5,7 @@ import android.view.MenuInflater
|
|||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import androidx.appcompat.widget.SearchView
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
|
||||||
import eu.kanade.domain.chapter.model.Chapter
|
import eu.kanade.domain.chapter.model.Chapter
|
||||||
import eu.kanade.presentation.history.HistoryScreen
|
import eu.kanade.presentation.history.HistoryScreen
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -28,9 +29,9 @@ class HistoryController : ComposeController<HistoryPresenter>(), RootController
|
|||||||
override fun createPresenter() = HistoryPresenter()
|
override fun createPresenter() = HistoryPresenter()
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
override fun ComposeContent() {
|
override fun ComposeContent(nestedScrollInterop: NestedScrollConnection) {
|
||||||
HistoryScreen(
|
HistoryScreen(
|
||||||
composeView = binding.root,
|
nestedScrollInterop = nestedScrollInterop,
|
||||||
presenter = presenter,
|
presenter = presenter,
|
||||||
onClickItem = { history ->
|
onClickItem = { history ->
|
||||||
router.pushController(MangaController(history).withFadeTransaction())
|
router.pushController(MangaController(history).withFadeTransaction())
|
||||||
|
Loading…
Reference in New Issue
Block a user