Skip to content

Commit c627d7b

Browse files
committed
Initial commit
0 parents  commit c627d7b

File tree

17 files changed

+649
-0
lines changed

17 files changed

+649
-0
lines changed

.gitignore

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
*.iml
2+
.kotlin
3+
.gradle
4+
**/build/
5+
xcuserdata
6+
!src/**/build/
7+
local.properties
8+
.idea
9+
.DS_Store
10+
captures
11+
.externalNativeBuild
12+
.cxx
13+
*.xcodeproj/*
14+
!*.xcodeproj/project.pbxproj
15+
!*.xcodeproj/xcshareddata/
16+
!*.xcodeproj/project.xcworkspace/
17+
!*.xcworkspace/contents.xcworkspacedata
18+
**/xcshareddata/WorkspaceSettings.xcsettings
19+
node_modules/

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
This is a Kotlin Multiplatform project targeting Desktop (JVM).
2+
3+
* [/composeApp](./composeApp/src) is for code that will be shared across your Compose Multiplatform applications.
4+
It contains several subfolders:
5+
- [commonMain](./composeApp/src/commonMain/kotlin) is for code that’s common for all targets.
6+
- Other folders are for Kotlin code that will be compiled for only the platform indicated in the folder name.
7+
For example, if you want to use Apple’s CoreCrypto for the iOS part of your Kotlin app,
8+
the [iosMain](./composeApp/src/iosMain/kotlin) folder would be the right place for such calls.
9+
Similarly, if you want to edit the Desktop (JVM) specific part, the [jvmMain](./composeApp/src/jvmMain/kotlin)
10+
folder is the appropriate location.
11+
12+
### Build and Run Desktop (JVM) Application
13+
14+
To build and run the development version of the desktop app, use the run configuration from the run widget
15+
in your IDE’s toolbar or run it directly from the terminal:
16+
- on macOS/Linux
17+
```shell
18+
./gradlew :composeApp:run
19+
```
20+
- on Windows
21+
```shell
22+
.\gradlew.bat :composeApp:run
23+
```
24+
25+
---
26+
27+
Learn more about [Kotlin Multiplatform](https://www.jetbrains.com/help/kotlin-multiplatform-dev/get-started.html)

build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
plugins {
2+
// this is necessary to avoid the plugins to be loaded multiple times
3+
// in each subproject's classloader
4+
alias(libs.plugins.composeHotReload) apply false
5+
alias(libs.plugins.composeMultiplatform) apply false
6+
alias(libs.plugins.composeCompiler) apply false
7+
alias(libs.plugins.kotlinMultiplatform) apply false
8+
}

composeApp/build.gradle.kts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
2+
3+
plugins {
4+
alias(libs.plugins.kotlinMultiplatform)
5+
alias(libs.plugins.composeMultiplatform)
6+
alias(libs.plugins.composeCompiler)
7+
alias(libs.plugins.composeHotReload)
8+
}
9+
10+
kotlin {
11+
jvm()
12+
13+
sourceSets {
14+
commonMain.dependencies {
15+
implementation(compose.runtime)
16+
implementation(compose.foundation)
17+
implementation(compose.material3)
18+
implementation(compose.ui)
19+
implementation(compose.components.resources)
20+
implementation(compose.components.uiToolingPreview)
21+
implementation(libs.androidx.lifecycle.viewmodelCompose)
22+
implementation(libs.androidx.lifecycle.runtimeCompose)
23+
}
24+
commonTest.dependencies {
25+
implementation(libs.kotlin.test)
26+
}
27+
jvmMain.dependencies {
28+
implementation(compose.desktop.currentOs)
29+
implementation(libs.kotlinx.coroutinesSwing)
30+
}
31+
}
32+
}
33+
34+
35+
compose.desktop {
36+
application {
37+
mainClass = "com.meet.gitbackup.hub.MainKt"
38+
39+
nativeDistributions {
40+
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
41+
packageName = "com.meet.gitbackup.hub"
42+
packageVersion = "1.0.0"
43+
}
44+
}
45+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<vector
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:aapt="http://schemas.android.com/aapt"
4+
android:width="450dp"
5+
android:height="450dp"
6+
android:viewportWidth="64"
7+
android:viewportHeight="64">
8+
<path
9+
android:pathData="M56.25,18V46L32,60 7.75,46V18L32,4Z"
10+
android:fillColor="#6075f2"/>
11+
<path
12+
android:pathData="m41.5,26.5v11L32,43V60L56.25,46V18Z"
13+
android:fillColor="#6b57ff"/>
14+
<path
15+
android:pathData="m32,43 l-9.5,-5.5v-11L7.75,18V46L32,60Z">
16+
<aapt:attr name="android:fillColor">
17+
<gradient
18+
android:centerX="23.131"
19+
android:centerY="18.441"
20+
android:gradientRadius="42.132"
21+
android:type="radial">
22+
<item android:offset="0" android:color="#FF5383EC"/>
23+
<item android:offset="0.867" android:color="#FF7F52FF"/>
24+
</gradient>
25+
</aapt:attr>
26+
</path>
27+
<path
28+
android:pathData="M22.5,26.5 L32,21 41.5,26.5 56.25,18 32,4 7.75,18Z">
29+
<aapt:attr name="android:fillColor">
30+
<gradient
31+
android:startX="44.172"
32+
android:startY="4.377"
33+
android:endX="17.973"
34+
android:endY="34.035"
35+
android:type="linear">
36+
<item android:offset="0" android:color="#FF33C3FF"/>
37+
<item android:offset="0.878" android:color="#FF5383EC"/>
38+
</gradient>
39+
</aapt:attr>
40+
</path>
41+
<path
42+
android:pathData="m32,21 l9.526,5.5v11L32,43 22.474,37.5v-11z"
43+
android:fillColor="#000000"/>
44+
</vector>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.meet.gitbackup.hub
2+
3+
import androidx.compose.animation.AnimatedVisibility
4+
import androidx.compose.foundation.Image
5+
import androidx.compose.foundation.background
6+
import androidx.compose.foundation.layout.Column
7+
import androidx.compose.foundation.layout.fillMaxSize
8+
import androidx.compose.foundation.layout.fillMaxWidth
9+
import androidx.compose.foundation.layout.safeContentPadding
10+
import androidx.compose.material3.Button
11+
import androidx.compose.material3.MaterialTheme
12+
import androidx.compose.material3.Text
13+
import androidx.compose.runtime.*
14+
import androidx.compose.ui.Alignment
15+
import androidx.compose.ui.Modifier
16+
import org.jetbrains.compose.resources.painterResource
17+
import org.jetbrains.compose.ui.tooling.preview.Preview
18+
19+
import git_backup_hub.composeapp.generated.resources.Res
20+
import git_backup_hub.composeapp.generated.resources.compose_multiplatform
21+
22+
@Composable
23+
@Preview
24+
fun App() {
25+
MaterialTheme {
26+
var showContent by remember { mutableStateOf(false) }
27+
Column(
28+
modifier = Modifier
29+
.background(MaterialTheme.colorScheme.primaryContainer)
30+
.safeContentPadding()
31+
.fillMaxSize(),
32+
horizontalAlignment = Alignment.CenterHorizontally,
33+
) {
34+
Button(onClick = { showContent = !showContent }) {
35+
Text("Click me!")
36+
}
37+
AnimatedVisibility(showContent) {
38+
val greeting = remember { Greeting().greet() }
39+
Column(
40+
modifier = Modifier.fillMaxWidth(),
41+
horizontalAlignment = Alignment.CenterHorizontally,
42+
) {
43+
Image(painterResource(Res.drawable.compose_multiplatform), null)
44+
Text("Compose: $greeting")
45+
}
46+
}
47+
}
48+
}
49+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.meet.gitbackup.hub
2+
3+
class Greeting {
4+
private val platform = getPlatform()
5+
6+
fun greet(): String {
7+
return "Hello, ${platform.name}!"
8+
}
9+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.meet.gitbackup.hub
2+
3+
class JVMPlatform {
4+
val name: String = "Java ${System.getProperty("java.version")}"
5+
}
6+
7+
fun getPlatform() = JVMPlatform()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.meet.gitbackup.hub
2+
3+
import androidx.compose.ui.window.Window
4+
import androidx.compose.ui.window.application
5+
6+
fun main() = application {
7+
Window(
8+
onCloseRequest = ::exitApplication,
9+
title = "Git-Backup-Hub",
10+
) {
11+
App()
12+
}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.meet.gitbackup.hub
2+
3+
import kotlin.test.Test
4+
import kotlin.test.assertEquals
5+
6+
class ComposeAppDesktopTest {
7+
8+
@Test
9+
fun example() {
10+
assertEquals(3, 1 + 2)
11+
}
12+
}

0 commit comments

Comments
 (0)