Browse Source

Codeviewer. replace rememberScrollbarAdapterFixed by compose rememberScrollbarAdapter

pull/45/head
Igor Demin 4 years ago
parent
commit
726fa0119b
  1. 20
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt

20
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Scrollbar.kt

@ -1,14 +1,11 @@
package org.jetbrains.codeviewer.platform
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LazyScrollbarAdapter
import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.DensityAmbient
import androidx.compose.ui.unit.Dp
@Composable
@ -29,20 +26,5 @@ actual fun VerticalScrollbar(
averageItemSize: Dp
) = androidx.compose.foundation.VerticalScrollbar(
modifier,
adapter = rememberScrollbarAdapterFixed(scrollState, itemCount, averageItemSize)
adapter = rememberScrollbarAdapter(scrollState, itemCount, averageItemSize)
)
// TODO/migrateToMaster should be fixed in androidx-master-dev
@Composable
fun rememberScrollbarAdapterFixed(
scrollState: LazyListState,
itemCount: Int,
averageItemSize: Dp
): LazyScrollbarAdapter {
val density = DensityAmbient.current
return remember(density, scrollState, itemCount, averageItemSize) {
with(density) {
LazyScrollbarAdapter(scrollState, itemCount, averageItemSize.toPx())
}
}
}
Loading…
Cancel
Save