From 713f687b02760d2173040dd53c0e474a8c6b9372 Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Mon, 11 Apr 2022 12:47:45 +0400 Subject: [PATCH] SplitPane. Remove material dependency (#1979) SplitPane by design, shouldn't have default visual representation, because it mostly depends on the design system (material, material3, etc) Fixes https://github.com/JetBrains/compose-jb/issues/1975 RelNote: SplitPane no longer depends on compose.material. Now, by default, SplitPane has invisible 0px splitter, not 1px black/white splitter as it was before. If you want to preserve the previous behaviour, specify a splitter explicitly: ``` HorizontalSplitPane(splitterState) { splitter { visiblePart { Box( Modifier .height(1.dp) .fillMaxHeight() .background(MaterialTheme.colors.background) ) } } } ``` --- components/SplitPane/library/build.gradle.kts | 1 - .../compose/splitpane/DesktopSplitPane.kt | 17 ++++++++++--- .../compose/splitpane/DesktopSplitter.kt | 25 +------------------ 3 files changed, 14 insertions(+), 29 deletions(-) diff --git a/components/SplitPane/library/build.gradle.kts b/components/SplitPane/library/build.gradle.kts index 2a41478d7f..a5eccf755d 100644 --- a/components/SplitPane/library/build.gradle.kts +++ b/components/SplitPane/library/build.gradle.kts @@ -15,7 +15,6 @@ kotlin { dependencies { api(compose.runtime) api(compose.foundation) - api(compose.material) } } named("desktopMain") {} diff --git a/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitPane.kt b/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitPane.kt index 65451e440e..40f25249ae 100644 --- a/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitPane.kt +++ b/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitPane.kt @@ -1,5 +1,6 @@ package org.jetbrains.compose.splitpane +import androidx.compose.foundation.layout.Box import androidx.compose.runtime.Composable import androidx.compose.ui.Modifier import androidx.compose.ui.layout.Layout @@ -24,10 +25,18 @@ internal actual fun SplitPane( ) { Layout( { - first() - splitter.measuredPart() - second() - splitter.handlePart() + Box { + first() + } + Box { + splitter.measuredPart() + } + Box { + second() + } + Box { + splitter.handlePart() + } }, modifier, ) { measurables, constraints -> diff --git a/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitter.kt b/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitter.kt index c0ae71f661..15e5c6cccb 100644 --- a/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitter.kt +++ b/components/SplitPane/library/src/desktopMain/kotlin/org/jetbrains/compose/splitpane/DesktopSplitter.kt @@ -1,13 +1,10 @@ package org.jetbrains.compose.splitpane -import androidx.compose.foundation.background import androidx.compose.foundation.gestures.detectDragGestures import androidx.compose.foundation.layout.* -import androidx.compose.material.MaterialTheme import androidx.compose.runtime.Composable import androidx.compose.ui.ExperimentalComposeUiApi import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.Color import androidx.compose.ui.input.pointer.* import androidx.compose.ui.unit.dp import java.awt.Cursor @@ -16,24 +13,6 @@ import java.awt.Cursor private fun Modifier.cursorForHorizontalResize(isHorizontal: Boolean): Modifier = pointerHoverIcon(PointerIcon(Cursor(if (isHorizontal) Cursor.E_RESIZE_CURSOR else Cursor.S_RESIZE_CURSOR))) -@Composable -private fun DesktopSplitPaneSeparator( - isHorizontal: Boolean, - color: Color = MaterialTheme.colors.background -) = Box( - Modifier - .run { - if (isHorizontal) { - this.width(1.dp) - .fillMaxHeight() - } else { - this.height(1.dp) - .fillMaxWidth() - } - } - .background(color) -) - @OptIn(ExperimentalSplitPaneApi::class) @Composable private fun DesktopHandle( @@ -66,9 +45,7 @@ internal actual fun defaultSplitter( isHorizontal: Boolean, splitPaneState: SplitPaneState ): Splitter = Splitter( - measuredPart = { - DesktopSplitPaneSeparator(isHorizontal) - }, + measuredPart = {}, handlePart = { DesktopHandle(isHorizontal, splitPaneState) }