Skip to content

Commit b740618

Browse files
committed
add desktop app
1 parent dcf2aa6 commit b740618

File tree

6 files changed

+100
-0
lines changed

6 files changed

+100
-0
lines changed

app/.run/desktop.run.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<component name="ProjectRunConfigurationManager">
2+
<configuration default="false" name="desktop" type="GradleRunConfiguration" factoryName="Gradle">
3+
<ExternalSystemSettings>
4+
<option name="executionName" />
5+
<option name="externalProjectPath" value="$PROJECT_DIR$" />
6+
<option name="externalSystemIdString" value="GRADLE" />
7+
<option name="scriptParameters" value="" />
8+
<option name="taskDescriptions">
9+
<list />
10+
</option>
11+
<option name="taskNames">
12+
<list>
13+
<option value="app:run" />
14+
</list>
15+
</option>
16+
<option name="vmOptions" value="" />
17+
</ExternalSystemSettings>
18+
<ExternalSystemDebugServerProcess>true</ExternalSystemDebugServerProcess>
19+
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
20+
<DebugAllEnabled>false</DebugAllEnabled>
21+
<RunAsTest>false</RunAsTest>
22+
<method v="2" />
23+
</configuration>
24+
</component>

app/build.gradle.kts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2+
3+
plugins {
4+
alias(libs.plugins.kotlin.multiplatform)
5+
alias(libs.plugins.compose.runtime)
6+
alias(libs.plugins.compose.compiler)
7+
}
8+
9+
group = "com.mfriend"
10+
version = "1.0-SNAPSHOT"
11+
12+
repositories {
13+
mavenCentral()
14+
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
15+
google()
16+
}
17+
18+
kotlin {
19+
jvm("desktop")
20+
21+
sourceSets {
22+
val desktopMain by getting
23+
desktopMain.dependencies {
24+
implementation(compose.desktop.currentOs)
25+
}
26+
}
27+
}
28+
29+
compose.desktop {
30+
application {
31+
mainClass = "MainKt"
32+
33+
nativeDistributions {
34+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
35+
packageName = "app"
36+
packageVersion = "1.0.0"
37+
}
38+
}
39+
}

app/src/desktopMain/kotlin/Main.kt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import androidx.compose.desktop.ui.tooling.preview.Preview
2+
import androidx.compose.material.Button
3+
import androidx.compose.material.MaterialTheme
4+
import androidx.compose.material.Text
5+
import androidx.compose.runtime.Composable
6+
import androidx.compose.runtime.getValue
7+
import androidx.compose.runtime.mutableStateOf
8+
import androidx.compose.runtime.remember
9+
import androidx.compose.runtime.setValue
10+
import androidx.compose.ui.window.Window
11+
import androidx.compose.ui.window.application
12+
13+
@Composable
14+
@Preview
15+
fun App() {
16+
var text by remember { mutableStateOf("Hello, World!") }
17+
18+
MaterialTheme {
19+
Button(onClick = {
20+
text = "Hello, bozotwsf!"
21+
}) {
22+
Text(text)
23+
}
24+
}
25+
}
26+
27+
fun main() = application {
28+
Window(onCloseRequest = ::exitApplication) {
29+
App()
30+
}
31+
}

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ plugins {
22
alias(libs.plugins.kotlin.multiplatform) apply false
33
alias(libs.plugins.kotlin.serialization) apply false
44
alias(libs.plugins.sqlDelight) apply false
5+
alias(libs.plugins.compose.compiler) apply false
6+
alias(libs.plugins.compose.runtime) apply false
7+
58
}
69

710
group = "org.example"

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref
3636
sqlDelight = { id = "app.cash.sqldelight", version.ref = "sqlDelight" }
3737
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
3838
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
39+
compose-runtime = { id = "org.jetbrains.compose", version.ref = "jetbrains-compose"}
3940

4041
[bundles]
4142
base = [

settings.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ include("scryfall")
44
include("discord-bot")
55
include(":collection-import")
66
include(":cli")
7+
include(":app")
78

89
pluginManagement {
910
repositories {
1011
gradlePluginPortal()
12+
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
1113
google()
1214
mavenCentral()
1315
}

0 commit comments

Comments
 (0)