Browse Source

iMove to 0.3.0-build135 and Kotlin 1.4.21.

pull/210/head
Nikolay Igotti 4 years ago
parent
commit
9354a554b4
  1. 5
      examples/codeviewer/build.gradle.kts
  2. 4
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt
  3. 12
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt
  4. 12
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LazyColumnFor.kt
  5. 4
      examples/imageviewer/build.gradle.kts
  6. 3
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullImageScreen.kt
  7. 20
      examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Zoomable.kt
  8. 4
      examples/issues/build.gradle.kts
  9. 4
      examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt
  10. 6
      examples/todoapp/common/main/src/commonMain/kotlin/example/todo/common/main/ui/TodoMainUi.kt
  11. 2
      examples/todoapp/common/utils/src/commonMain/kotlin/example/todo/common/utils/ShortcutHandler.kt

5
examples/codeviewer/build.gradle.kts

@ -9,9 +9,10 @@ buildscript {
dependencies { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:0.2.0-build132") classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build135")
classpath("com.android.tools.build:gradle:4.0.1") classpath("com.android.tools.build:gradle:4.0.1")
classpath(kotlin("gradle-plugin", version = "1.4.20")) // __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.4.21"))
} }
} }

4
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/CodeViewerView.kt

@ -13,7 +13,7 @@ import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.drawLayer import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import org.jetbrains.codeviewer.ui.editor.EditorEmptyView import org.jetbrains.codeviewer.ui.editor.EditorEmptyView
import org.jetbrains.codeviewer.ui.editor.EditorTabsView import org.jetbrains.codeviewer.ui.editor.EditorTabsView
@ -85,7 +85,7 @@ private fun ResizablePanel(
val alpha = animate(if (state.isExpanded) 1f else 0f, SpringSpec(stiffness = StiffnessLow)) val alpha = animate(if (state.isExpanded) 1f else 0f, SpringSpec(stiffness = StiffnessLow))
Box(modifier) { Box(modifier) {
Box(Modifier.fillMaxSize().drawLayer(alpha = alpha)) { Box(Modifier.fillMaxSize().graphicsLayer(alpha = alpha)) {
content() content()
} }

12
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorView.kt

@ -13,13 +13,11 @@ import androidx.compose.runtime.key
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.draw.drawOpacity import androidx.compose.ui.draw.drawOpacity
import androidx.compose.ui.platform.AmbientDensity import androidx.compose.ui.platform.AmbientDensity
import androidx.compose.ui.selection.DisableSelection import androidx.compose.ui.selection.DisableSelection
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.*
import androidx.compose.ui.text.SpanStyle
import androidx.compose.ui.text.annotatedString
import androidx.compose.ui.text.withStyle
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import org.jetbrains.codeviewer.platform.SelectionContainer import org.jetbrains.codeviewer.platform.SelectionContainer
import org.jetbrains.codeviewer.platform.VerticalScrollbar import org.jetbrains.codeviewer.platform.VerticalScrollbar
@ -104,7 +102,7 @@ private fun Line(modifier: Modifier, maxNum: String, line: Editor.Line, settings
Row(modifier = modifier) { Row(modifier = modifier) {
DisableSelection { DisableSelection {
Box { Box {
LineNumber(maxNum, Modifier.drawOpacity(0f), settings) LineNumber(maxNum, Modifier.alpha(0f), settings)
LineNumber(line.number.toString(), Modifier.align(Alignment.CenterEnd), settings) LineNumber(line.number.toString(), Modifier.align(Alignment.CenterEnd), settings)
} }
} }
@ -133,7 +131,7 @@ private fun LineContent(content: Editor.Content, modifier: Modifier, settings: S
text = if (content.isCode) { text = if (content.isCode) {
codeString(content.value.value) codeString(content.value.value)
} else { } else {
annotatedString { buildAnnotatedString {
withStyle(AppTheme.code.simple) { withStyle(AppTheme.code.simple) {
append(content.value.value) append(content.value.value)
} }
@ -145,7 +143,7 @@ private fun LineContent(content: Editor.Content, modifier: Modifier, settings: S
softWrap = false softWrap = false
) )
private fun codeString(str: String) = annotatedString { private fun codeString(str: String) = buildAnnotatedString {
withStyle(AppTheme.code.simple) { withStyle(AppTheme.code.simple) {
append(str.replace("\t", " ")) append(str.replace("\t", " "))
addStyle(AppTheme.code.punctuation, ":") addStyle(AppTheme.code.punctuation, ":")

12
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/LazyColumnFor.kt

@ -16,14 +16,14 @@ fun LazyColumnFor(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
state: LazyListState = rememberLazyListState(), state: LazyListState = rememberLazyListState(),
contentPadding: PaddingValues = PaddingValues(0.dp), contentPadding: PaddingValues = PaddingValues(0.dp),
horizontalGravity: Alignment.Horizontal = Alignment.Start, horizontalAlignment: Alignment.Horizontal = Alignment.Start,
itemContent: @Composable LazyItemScope.(index: Int) -> Unit itemContent: @Composable LazyItemScope.(index: Int) -> Unit
) = LazyColumnForIndexed( ) = LazyColumnForIndexed(
UnitList(size), items = UnitList(size),
modifier, modifier = modifier,
state, state = state,
contentPadding, contentPadding = contentPadding,
horizontalGravity, horizontalAlignment = horizontalAlignment,
) { index, _ -> ) { index, _ ->
itemContent(index) itemContent(index)
} }

4
examples/imageviewer/build.gradle.kts

@ -11,10 +11,10 @@ buildscript {
dependencies { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:0.2.0-build132") classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build135")
classpath("com.android.tools.build:gradle:4.0.1") classpath("com.android.tools.build:gradle:4.0.1")
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.4.20")) classpath(kotlin("gradle-plugin", version = "1.4.21"))
} }
} }

3
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/FullImageScreen.kt

@ -200,9 +200,6 @@ fun getFilterImage(type: FilterType, content: ContentState): ImageBitmap {
} }
} }
@OptIn(
ExperimentalKeyInput::class
)
@Composable @Composable
fun setImage(content: ContentState) { fun setImage(content: ContentState) {
val drag = DragHandler() val drag = DragHandler()

20
examples/imageviewer/common/src/desktopMain/kotlin/example/imageviewer/view/Zoomable.kt

@ -2,30 +2,22 @@ package example.imageviewer.view
import androidx.compose.foundation.clickable import androidx.compose.foundation.clickable
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.setValue
import androidx.compose.material.Surface import androidx.compose.material.Surface
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.mutableStateOf import androidx.compose.ui.focus.FocusReference
import androidx.compose.ui.focus
import androidx.compose.ui.focus.ExperimentalFocus
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focusRequester
import androidx.compose.ui.input.key.* import androidx.compose.ui.input.key.*
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.focusModifier
import androidx.compose.ui.focus.focusReference
import example.imageviewer.style.Transparent import example.imageviewer.style.Transparent
@OptIn(
ExperimentalKeyInput::class,
ExperimentalFocus::class
)
@Composable @Composable
fun Zoomable( fun Zoomable(
onScale: ScaleHandler, onScale: ScaleHandler,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
children: @Composable() () -> Unit children: @Composable() () -> Unit
) { ) {
val focusRequester = remember { FocusRequester() } val focusRequester = remember { FocusReference() }
Surface( Surface(
color = Transparent, color = Transparent,
@ -40,8 +32,8 @@ fun Zoomable(
onScale.resetFactor() onScale.resetFactor()
} }
} }
.focusRequester(focusRequester) .focusReference(focusRequester)
.focus() .focusModifier()
.clickable(indication = null) { focusRequester.requestFocus() } .clickable(indication = null) { focusRequester.requestFocus() }
) { ) {
children() children()

4
examples/issues/build.gradle.kts

@ -9,10 +9,10 @@ buildscript {
dependencies { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:0.2.0-build132") classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build135")
classpath("com.android.tools.build:gradle:4.0.1") classpath("com.android.tools.build:gradle:4.0.1")
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
classpath(kotlin("gradle-plugin", version = "1.4.20")) classpath(kotlin("gradle-plugin", version = "1.4.21"))
} }
} }

4
examples/todoapp/buildSrc/buildSrc/src/main/kotlin/Deps.kt

@ -3,7 +3,7 @@ object Deps {
object JetBrains { object JetBrains {
object Kotlin { object Kotlin {
// __KOTLIN_COMPOSE_VERSION__ // __KOTLIN_COMPOSE_VERSION__
private const val VERSION = "1.4.20" private const val VERSION = "1.4.21"
const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$VERSION" const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:$VERSION"
const val testCommon = "org.jetbrains.kotlin:kotlin-test-common:$VERSION" const val testCommon = "org.jetbrains.kotlin:kotlin-test-common:$VERSION"
const val testJunit = "org.jetbrains.kotlin:kotlin-test-junit:$VERSION" const val testJunit = "org.jetbrains.kotlin:kotlin-test-junit:$VERSION"
@ -12,7 +12,7 @@ object Deps {
object Compose { object Compose {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
private const val VERSION = "0.2.0-build132" private const val VERSION = "0.3.0-build135"
const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION" const val gradlePlugin = "org.jetbrains.compose:compose-gradle-plugin:$VERSION"
} }
} }

6
examples/todoapp/common/main/src/commonMain/kotlin/example/todo/common/main/ui/TodoMainUi.kt

@ -23,9 +23,8 @@ import androidx.compose.material.icons.filled.Delete
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.input.key.ExperimentalKeyInput
import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.keyInputFilter import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
@ -132,7 +131,6 @@ private fun Item(
} }
} }
@OptIn(ExperimentalKeyInput::class)
@Composable @Composable
private fun TodoInput( private fun TodoInput(
text: String, text: String,
@ -142,7 +140,7 @@ private fun TodoInput(
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(8.dp)) { Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(8.dp)) {
OutlinedTextField( OutlinedTextField(
value = text, value = text,
modifier = Modifier.weight(weight = 1F).keyInputFilter(onKeyUp(Key.Enter, onAddClicked)), modifier = Modifier.weight(weight = 1F).onKeyEvent(onKeyUp(Key.Enter, onAddClicked)),
onValueChange = onTextChanged, onValueChange = onTextChanged,
label = { Text(text = "Add a todo") } label = { Text(text = "Add a todo") }
) )

2
examples/todoapp/common/utils/src/commonMain/kotlin/example/todo/common/utils/ShortcutHandler.kt

@ -1,10 +1,8 @@
package example.todo.common.utils package example.todo.common.utils
import androidx.compose.ui.input.key.ExperimentalKeyInput
import androidx.compose.ui.input.key.Key import androidx.compose.ui.input.key.Key
import androidx.compose.ui.input.key.KeyEvent import androidx.compose.ui.input.key.KeyEvent
@OptIn(ExperimentalKeyInput::class)
fun onKeyUp(key: Key, onEvent: () -> Unit): (KeyEvent) -> Boolean = fun onKeyUp(key: Key, onEvent: () -> Unit): (KeyEvent) -> Boolean =
{ keyEvent -> { keyEvent ->
if (keyEvent.key == key) { if (keyEvent.key == key) {

Loading…
Cancel
Save