Browse Source

Rename

app-api
Nikolay Igotti 3 years ago
parent
commit
bde14ceb5c
  1. 21
      components/App/library/src/commonMain/kotlin/org/jetbrains/compose/app/App.kt
  2. 4
      components/Kapp/demo/build.gradle.kts
  3. 6
      components/Kapp/demo/src/desktopMain/kotlin/org/jetbrains/compose/kapp/demo/Main.kt
  4. 4
      components/Kapp/demo/src/desktopMain/kotlin/org/jetbrains/compose/kapp/demo/MainSimple.kt
  5. 0
      components/Kapp/library/build.gradle.kts
  6. 21
      components/Kapp/library/src/commonMain/kotlin/org/jetbrains/compose/kapp/KApp.kt
  7. 10
      components/Kapp/library/src/desktopMain/kotlin/org/jetbrains/compose/kapp/App.desktop.kt
  8. 4
      components/settings.gradle.kts

21
components/App/library/src/commonMain/kotlin/org/jetbrains/compose/app/App.kt

@ -1,21 +0,0 @@
package org.jetbrains.compose.app
import androidx.compose.runtime.Composable
interface ComposeAppScope
@Composable
expect fun ComposeAppScope.Frame(content: @Composable () -> Unit)
// Complex multi-frame application
fun composeApplication(name: String = "application", title: String = "Compose Application", content: @Composable ComposeAppScope.() -> Unit) {
composeApplicationImpl(name, title, content)
}
// Simple single-frame application.
fun composeApp(name: String = "application", content: @Composable () -> Unit) {
composeAppImpl(name, content)
}
internal expect fun composeApplicationImpl(name: String, title: String, content: @Composable ComposeAppScope.() -> Unit)
internal expect fun composeAppImpl(name: String, content: @Composable () -> Unit)

4
components/App/demo/build.gradle.kts → components/Kapp/demo/build.gradle.kts

@ -12,7 +12,7 @@ kotlin {
named("desktopMain") { named("desktopMain") {
dependencies { dependencies {
implementation(compose.desktop.currentOs) implementation(compose.desktop.currentOs)
implementation(project(":App:library")) implementation(project(":Kapp:library"))
} }
} }
} }
@ -20,7 +20,7 @@ kotlin {
compose.desktop { compose.desktop {
application { application {
mainClass = "org.jetbrains.compose.app.demo.MainKt" mainClass = "org.jetbrains.compose.kapp.demo.MainKt"
} }
} }

6
components/App/demo/src/desktopMain/kotlin/org/jetbrains/compose/app/demo/Main.kt → components/Kapp/demo/src/desktopMain/kotlin/org/jetbrains/compose/kapp/demo/Main.kt

@ -1,13 +1,13 @@
package org.jetbrains.compose.app.demo package org.jetbrains.compose.kapp.demo
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.material.Button import androidx.compose.material.Button
import androidx.compose.material.Text import androidx.compose.material.Text
import androidx.compose.runtime.* import androidx.compose.runtime.*
import org.jetbrains.compose.app.* import org.jetbrains.compose.kapp.*
fun main() = composeApplication( fun main() = kapp(
title = "App demo" title = "App demo"
) { ) {
var visible by remember { mutableStateOf(5) } var visible by remember { mutableStateOf(5) }

4
components/App/demo/src/desktopMain/kotlin/org/jetbrains/compose/app/demo/MainSimple.kt → components/Kapp/demo/src/desktopMain/kotlin/org/jetbrains/compose/kapp/demo/MainSimple.kt

@ -7,9 +7,9 @@ import androidx.compose.material.Text
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import org.jetbrains.compose.app.composeApp import org.jetbrains.compose.kapp.simpleKapp
fun main() = composeApp(name = "App demo") { fun main() = simpleKapp(name = "Kapp demo") {
Content() Content()
} }

0
components/App/library/build.gradle.kts → components/Kapp/library/build.gradle.kts

21
components/Kapp/library/src/commonMain/kotlin/org/jetbrains/compose/kapp/KApp.kt

@ -0,0 +1,21 @@
package org.jetbrains.compose.kapp
import androidx.compose.runtime.Composable
interface KAppScope
@Composable
expect fun KAppScope.Frame(content: @Composable () -> Unit)
// Complex multi-frame application
fun kapp(name: String = "application", title: String = "Compose Application", content: @Composable KAppScope.() -> Unit) {
kappImpl(name, title, content)
}
// Simple single-frame application.
fun simpleKapp(name: String = "application", content: @Composable () -> Unit) {
simpleKappImpl(name, content)
}
internal expect fun kappImpl(name: String, title: String, content: @Composable KAppScope.() -> Unit)
internal expect fun simpleKappImpl(name: String, content: @Composable () -> Unit)

10
components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.desktop.kt → components/Kapp/library/src/desktopMain/kotlin/org/jetbrains/compose/kapp/App.desktop.kt

@ -1,4 +1,4 @@
package org.jetbrains.compose.app package org.jetbrains.compose.kapp
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.runtime.getValue import androidx.compose.runtime.getValue
@ -15,7 +15,7 @@ class AppWindowScope : FrameWindowScope {
} }
@Composable @Composable
actual fun ComposeAppScope.Frame(content: @Composable () -> Unit) { actual fun KAppScope.Frame(content: @Composable () -> Unit) {
val scope by remember { mutableStateOf(AppWindowScope()) } val scope by remember { mutableStateOf(AppWindowScope()) }
scope.apply { scope.apply {
Window(onCloseRequest = { scope.onClose() }, state = scope.state, Window(onCloseRequest = { scope.onClose() }, state = scope.state,
@ -23,7 +23,7 @@ actual fun ComposeAppScope.Frame(content: @Composable () -> Unit) {
} }
} }
class AppAppScope : ComposeAppScope, androidx.compose.ui.window.ApplicationScope { class AppAppScope : KAppScope, androidx.compose.ui.window.ApplicationScope {
override fun exitApplication() { override fun exitApplication() {
println("Exit application") println("Exit application")
SwingUtilities.invokeLater { SwingUtilities.invokeLater {
@ -32,14 +32,14 @@ class AppAppScope : ComposeAppScope, androidx.compose.ui.window.ApplicationScope
} }
} }
internal actual fun composeApplicationImpl(name: String, title: String, content: @Composable ComposeAppScope.() -> Unit) { internal actual fun kappImpl(name: String, title: String, content: @Composable KAppScope.() -> Unit) {
val scope = AppAppScope() val scope = AppAppScope()
scope.apply { scope.apply {
application(exitProcessOnExit = true, content = @Composable { content() }) application(exitProcessOnExit = true, content = @Composable { content() })
} }
} }
internal actual fun composeAppImpl(name: String, content: @Composable () -> Unit) { internal actual fun simpleKappImpl(name: String, content: @Composable () -> Unit) {
val appScope = AppAppScope() val appScope = AppAppScope()
val winScope = AppWindowScope() val winScope = AppWindowScope()
appScope.apply { appScope.apply {

4
components/settings.gradle.kts

@ -16,5 +16,5 @@ pluginManagement {
include(":SplitPane:library") include(":SplitPane:library")
include(":SplitPane:demo") include(":SplitPane:demo")
include(":App:library") include(":Kapp:library")
include(":App:demo") include(":Kapp:demo")

Loading…
Cancel
Save