Browse Source

Move codeviewer to 0.1.0-m1-build57

pull/43/head
Igor Demin 4 years ago
parent
commit
26e431cd78
  1. 4
      examples/codeviewer/android/src/main/assets/data/EditorView.kt
  2. 2
      examples/codeviewer/build.gradle.kts
  3. 11
      examples/codeviewer/common/src/androidMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt
  4. 3
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt
  5. 4
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/MainView.kt
  6. 4
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt
  7. 2
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LayoutModifiers.kt
  8. 5
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/VerticalSplittable.kt
  9. 9
      examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt

4
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)

2
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"))
}

11
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<Selection?>(null) }
@ -15,12 +17,3 @@ actual fun SelectionContainer(children: @Composable () -> Unit) {
children = children
)
}
@Composable
actual fun WithoutSelection(children: @Composable () -> Unit) {
SelectionContainer(
selection = null,
onSelectionChange = {},
children = children
)
}

3
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt

@ -4,6 +4,3 @@ import androidx.compose.runtime.Composable
@Composable
expect fun SelectionContainer(children: @Composable () -> Unit)
@Composable
expect fun WithoutSelection(children: @Composable () -> Unit)

4
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
) {

4
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)

2
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))

5
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,8 +66,7 @@ fun VerticalSplitter(
.fillMaxHeight()
.run {
if (splitterState.isResizeEnabled) {
this.
draggable(
this.draggable(
Orientation.Horizontal,
startDragImmediately = true,
onDragStarted = { splitterState.isResizing = true },

9
examples/codeviewer/common/src/desktopMain/kotlin/org/jetbrains/codeviewer/platform/Selection.kt

@ -15,12 +15,3 @@ actual fun SelectionContainer(children: @Composable () -> Unit) {
children = children
)
}
@Composable
actual fun WithoutSelection(children: @Composable () -> Unit) {
androidx.compose.ui.selection.SelectionContainer(
selection = null,
onSelectionChange = {},
children = children
)
}
Loading…
Cancel
Save