Browse Source

To MPP

app-api
Nikolay Igotti 3 years ago
parent
commit
aed48a902b
  1. 4
      components/App/demo/build.gradle.kts
  2. 4
      components/App/demo/src/desktopMain/kotlin/org/jetbrains/compose/app/demo/Main.kt
  3. 14
      components/App/library/src/commonMain/kotlin/org/jetbrains/compose/app/App.kt
  4. 16
      components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.desktop.kt
  5. 10
      components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.kt

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

@ -7,9 +7,9 @@ plugins {
}
kotlin {
jvm {}
jvm("desktop") {}
sourceSets {
named("jvmMain") {
named("desktopMain") {
dependencies {
implementation(compose.desktop.currentOs)
implementation(project(":App:library"))

4
components/App/demo/src/jvmMain/kotlin/org/jetbrains/compose/app/demo/Main.kt → components/App/demo/src/desktopMain/kotlin/org/jetbrains/compose/app/demo/Main.kt

@ -1,9 +1,9 @@
package org.jetbrains.compose.app.demo
import androidx.compose.material.Text
import org.jetbrains.compose.app.application
import org.jetbrains.compose.app.app
fun main() = application(
fun main() = app(
title = "App demo"
) {
Text("Hi")

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

@ -0,0 +1,14 @@
package org.jetbrains.compose.app
import androidx.compose.runtime.Composable
fun app(name: String = "application", title: String = "Compose Application", body: @Composable () -> Unit) {
appImpl(name, title, body)
}
internal expect fun appImpl(name: String, title: String, body: @Composable () -> Unit)
// TODO: not sure if having abstract here is a good idea
expect abstract class EmbedderContext
expect fun embed(context: EmbedderContext, body: @Composable () -> Unit)

16
components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.desktop.kt

@ -0,0 +1,16 @@
package org.jetbrains.compose.app
import androidx.compose.runtime.Composable
import androidx.compose.ui.window.singleWindowApplication
import javax.swing.JComponent
actual fun appImpl(name: String, title: String, body: @Composable () -> Unit) {
singleWindowApplication {
body()
}
}
actual typealias EmbedderContext = JComponent
actual fun embed(context: EmbedderContext, body: @Composable () -> Unit) {
TODO("implement me")
}

10
components/App/library/src/desktopMain/kotlin/org/jetbrains/compose/app/App.kt

@ -1,10 +0,0 @@
package org.jetbrains.compose.app
import androidx.compose.runtime.Composable
import androidx.compose.ui.window.singleWindowApplication
fun application(name: String = "application", title: String = "Compose Application", body: @Composable () -> Unit) {
singleWindowApplication {
body()
}
}
Loading…
Cancel
Save