From 26e431cd7890271941ffbdd6a2c5440f82299d08 Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Fri, 30 Oct 2020 21:22:38 +0300 Subject: [PATCH] Move codeviewer to 0.1.0-m1-build57 --- .../src/main/assets/data/EditorView.kt | 4 ++-- examples/codeviewer/build.gradle.kts | 2 +- .../codeviewer/platform/Selection.kt | 11 ++--------- .../codeviewer/platform/Selection.kt | 5 +---- .../org/jetbrains/codeviewer/ui/MainView.kt | 4 ++-- .../codeviewer/ui/editor/EditorView.kt | 4 ++-- .../codeviewer/util/LayoutModifiers.kt | 2 +- .../codeviewer/util/VerticalSplittable.kt | 19 +++++++++---------- .../codeviewer/platform/Selection.kt | 9 --------- 9 files changed, 20 insertions(+), 40 deletions(-) diff --git a/examples/codeviewer/android/src/main/assets/data/EditorView.kt b/examples/codeviewer/android/src/main/assets/data/EditorView.kt index 68852cdbef..d6e3bfc926 100644 --- a/examples/codeviewer/android/src/main/assets/data/EditorView.kt +++ b/examples/codeviewer/android/src/main/assets/data/EditorView.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawOpacity import androidx.compose.ui.platform.DensityAmbient +import androidx.compose.ui.selection.DisableSelection import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.annotatedString @@ -26,7 +27,6 @@ import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import org.jetbrains.codeviewer.platform.SelectionContainer import org.jetbrains.codeviewer.platform.VerticalScrollbar -import org.jetbrains.codeviewer.platform.WithoutSelection import org.jetbrains.codeviewer.ui.common.AppTheme import org.jetbrains.codeviewer.ui.common.Fonts import org.jetbrains.codeviewer.ui.common.Settings @@ -110,7 +110,7 @@ private fun Lines(lines: Editor.Lines, settings: Settings) = with(DensityAmbient @Composable private fun Line(modifier: Modifier, maxNumber: String, line: Editor.Line, settings: Settings) { Row(modifier = modifier) { - WithoutSelection { + DisableSelection { Box { LineNumber(maxNumber, Modifier.drawOpacity(0f), settings) LineNumber(line.number.toString(), Modifier.align(Alignment.CenterEnd), settings) diff --git a/examples/codeviewer/build.gradle.kts b/examples/codeviewer/build.gradle.kts index 386db2e246..5a07e59003 100644 --- a/examples/codeviewer/build.gradle.kts +++ b/examples/codeviewer/build.gradle.kts @@ -8,7 +8,7 @@ buildscript { dependencies { // TODO/migrateToMaster 0.1.0-dev104 is built from "unmerged" branch, // replace it by version from androidx-master-dev when scrollbars will be merged - classpath("org.jetbrains.compose:compose-gradle-plugin:0.1.0-dev104") + classpath("org.jetbrains.compose:compose-gradle-plugin:0.1.0-m1-build57") classpath("com.android.tools.build:gradle:4.0.1") classpath(kotlin("gradle-plugin", version = "1.4.0")) } diff --git a/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt b/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt index c171e5bc61..938ad87474 100644 --- a/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt +++ b/examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt @@ -5,7 +5,9 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.ui.selection.Selection import androidx.compose.ui.selection.SelectionContainer +import androidx.compose.ui.text.InternalTextApi +@OptIn(InternalTextApi::class) @Composable actual fun SelectionContainer(children: @Composable () -> Unit) { val selection = remember { mutableStateOf(null) } @@ -14,13 +16,4 @@ actual fun SelectionContainer(children: @Composable () -> Unit) { onSelectionChange = { selection.value = it }, children = children ) -} - -@Composable -actual fun WithoutSelection(children: @Composable () -> Unit) { - SelectionContainer( - selection = null, - onSelectionChange = {}, - children = children - ) } \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt index f071f47dc6..f6c1c3a96d 100644 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt +++ b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt @@ -3,7 +3,4 @@ package org.jetbrains.codeviewer.platform import androidx.compose.runtime.Composable @Composable -expect fun SelectionContainer(children: @Composable () -> Unit) - -@Composable -expect fun WithoutSelection(children: @Composable () -> Unit) \ No newline at end of file +expect fun SelectionContainer(children: @Composable () -> Unit) \ No newline at end of file diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt index 5b257fd284..77dc829194 100644 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt +++ b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt @@ -4,9 +4,9 @@ import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.runtime.Composable import androidx.compose.runtime.remember +import androidx.compose.ui.selection.DisableSelection import org.jetbrains.codeviewer.platform.HomeFolder import org.jetbrains.codeviewer.platform.PlatformTheme -import org.jetbrains.codeviewer.platform.WithoutSelection import org.jetbrains.codeviewer.ui.common.AppTheme import org.jetbrains.codeviewer.ui.common.Settings import org.jetbrains.codeviewer.ui.editor.Editors @@ -24,7 +24,7 @@ fun MainView() { ) } - WithoutSelection { + DisableSelection { MaterialTheme( colors = AppTheme.colors.material ) { diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt index b362697a35..483655d091 100644 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt +++ b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt @@ -15,6 +15,7 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.drawOpacity import androidx.compose.ui.platform.DensityAmbient +import androidx.compose.ui.selection.DisableSelection import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.annotatedString @@ -22,7 +23,6 @@ import androidx.compose.ui.text.withStyle import androidx.compose.ui.unit.dp import org.jetbrains.codeviewer.platform.SelectionContainer import org.jetbrains.codeviewer.platform.VerticalScrollbar -import org.jetbrains.codeviewer.platform.WithoutSelection import org.jetbrains.codeviewer.ui.common.AppTheme import org.jetbrains.codeviewer.ui.common.Fonts import org.jetbrains.codeviewer.ui.common.Settings @@ -106,7 +106,7 @@ private fun Lines(lines: Editor.Lines, settings: Settings) = with(DensityAmbient @Composable private fun Line(modifier: Modifier, maxNum: String, line: Editor.Line, settings: Settings) { Row(modifier = modifier) { - WithoutSelection { + DisableSelection { Box { LineNumber(maxNum, Modifier.drawOpacity(0f), settings) LineNumber(line.number.toString(), Modifier.align(Alignment.CenterEnd), settings) diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt index 0a054d78a5..423abafa95 100644 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt +++ b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt @@ -1,7 +1,7 @@ package org.jetbrains.codeviewer.util import androidx.compose.ui.Modifier -import androidx.compose.ui.layout +import androidx.compose.ui.layout.layout fun Modifier.withoutWidthConstraints() = layout { measurable, constraints -> val placeable = measurable.measure(constraints.copy(maxWidth = Int.MAX_VALUE)) diff --git a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt index b6848a5523..76332b3a72 100644 --- a/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt +++ b/examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt @@ -9,10 +9,10 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue -import androidx.compose.ui.Layout import androidx.compose.ui.Modifier import androidx.compose.ui.gesture.scrollorientationlocking.Orientation import androidx.compose.ui.graphics.Color +import androidx.compose.ui.layout.Layout import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -66,15 +66,14 @@ fun VerticalSplitter( .fillMaxHeight() .run { if (splitterState.isResizeEnabled) { - this. - draggable( - Orientation.Horizontal, - startDragImmediately = true, - onDragStarted = { splitterState.isResizing = true }, - onDragStopped = { splitterState.isResizing = false } - ) { - onResize(it.toDp()) - } + this.draggable( + Orientation.Horizontal, + startDragImmediately = true, + onDragStarted = { splitterState.isResizing = true }, + onDragStopped = { splitterState.isResizing = false } + ) { + onResize(it.toDp()) + } .cursorForHorizontalResize() } else { this diff --git a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt index 2b30e0ee49..166eef99fe 100644 --- a/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt +++ b/examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt @@ -14,13 +14,4 @@ actual fun SelectionContainer(children: @Composable () -> Unit) { onSelectionChange = { selection.value = it }, children = children ) -} - -@Composable -actual fun WithoutSelection(children: @Composable () -> Unit) { - androidx.compose.ui.selection.SelectionContainer( - selection = null, - onSelectionChange = {}, - children = children - ) } \ No newline at end of file