chore(library/compose): View<->Compose Interop

REF: https://developer.android.com/develop/ui/compose/touch-input/pointer-input/scroll#parent-view-child-compose
This commit is contained in:
Ahmad Ansori Palembani 2025-01-09 07:22:21 +07:00
parent 9cf1fbb118
commit c9a90f6847
Signed by: null2264
GPG key ID: BA64F8B60AF3EFB6
2 changed files with 10 additions and 4 deletions

View file

@ -6,6 +6,9 @@ import android.view.View
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.core.view.isVisible import androidx.core.view.isVisible
import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.PreferencesHelper
@ -69,12 +72,12 @@ class LibraryComposeController(
@Composable @Composable
fun ScreenContent() { fun ScreenContent() {
val nestedScrollInterop = rememberNestedScrollInteropConnection()
val state by presenter.state.collectAsState() val state by presenter.state.collectAsState()
LibraryContent( LibraryContent(
items = listOf( modifier = Modifier.nestedScroll(nestedScrollInterop),
LibraryItem.Blank(69), items = (0..50).map { LibraryItem.Blank(it) },
LibraryItem.Blank(420),
),
columns = 3, columns = 3,
) )
} }

View file

@ -3,6 +3,7 @@ package yokai.presentation.library
import androidx.compose.foundation.lazy.grid.items import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import eu.kanade.tachiyomi.ui.library.models.LibraryItem import eu.kanade.tachiyomi.ui.library.models.LibraryItem
import yokai.presentation.AppBarType import yokai.presentation.AppBarType
import yokai.presentation.YokaiScaffold import yokai.presentation.YokaiScaffold
@ -10,6 +11,7 @@ import yokai.presentation.library.components.LazyLibraryGrid
@Composable @Composable
fun LibraryContent( fun LibraryContent(
modifier: Modifier = Modifier,
items: List<LibraryItem>, items: List<LibraryItem>,
columns: Int, columns: Int,
) { ) {
@ -18,6 +20,7 @@ fun LibraryContent(
appBarType = AppBarType.NONE, appBarType = AppBarType.NONE,
) { contentPadding -> ) { contentPadding ->
LazyLibraryGrid( LazyLibraryGrid(
modifier = modifier,
columns = columns, columns = columns,
contentPadding = contentPadding, contentPadding = contentPadding,
) { ) {