Browse Source

Move codeviewer to 0.3.0-build141

pull/297/head
Nikolay Igotti 3 years ago
parent
commit
860acb907a
  1. 2
      examples/codeviewer/build.gradle.kts
  2. 2
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt
  3. 4
      examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt

2
examples/codeviewer/build.gradle.kts

@ -9,7 +9,7 @@ buildscript {
dependencies { dependencies {
// __LATEST_COMPOSE_RELEASE_VERSION__ // __LATEST_COMPOSE_RELEASE_VERSION__
classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build135") classpath("org.jetbrains.compose:compose-gradle-plugin:0.3.0-build141")
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.21")) classpath(kotlin("gradle-plugin", version = "1.4.21"))

2
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/ui/editor/EditorEmptyView.kt

@ -19,7 +19,7 @@ import androidx.compose.ui.unit.sp
fun EditorEmptyView() = Box(Modifier.fillMaxSize()) { fun EditorEmptyView() = Box(Modifier.fillMaxSize()) {
Column(Modifier.align(Alignment.Center)) { Column(Modifier.align(Alignment.Center)) {
Icon( Icon(
Icons.Default.Code.copy(defaultWidth = 48.dp, defaultHeight = 48.dp), Icons.Default.Code,
tint = AmbientContentColor.current.copy(alpha = 0.60f), tint = AmbientContentColor.current.copy(alpha = 0.60f),
modifier = Modifier.align(Alignment.CenterHorizontally) modifier = Modifier.align(Alignment.CenterHorizontally)
) )

4
examples/codeviewer/common/src/commonMain/kotlin/org/jetbrains/codeviewer/util/Loadable.kt

@ -9,10 +9,12 @@ fun <T : Any> loadable(load: () -> T): MutableState<T?> {
return loadableScoped { load() } return loadableScoped { load() }
} }
private val loadingKey = Any()
@Composable @Composable
fun <T : Any> loadableScoped(load: CoroutineScope.() -> T): MutableState<T?> { fun <T : Any> loadableScoped(load: CoroutineScope.() -> T): MutableState<T?> {
val state: MutableState<T?> = remember { mutableStateOf(null) } val state: MutableState<T?> = remember { mutableStateOf(null) }
LaunchedTask { LaunchedEffect(loadingKey) {
try { try {
state.value = load() state.value = load()
} catch (e: CancellationException) { } catch (e: CancellationException) {

Loading…
Cancel
Save