Add new Kotlin Multiplatform project to gui.

This commit is contained in:
me committed 2026-10-30 07:02:43 -07:00
1 parent ac88d08213
commit eeda4a18c5
47 files changed
+3635

No files matched your search

@@ -0,0 +1,44 @@
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="450dp"
android:height="450dp"
android:viewportWidth="64"
android:viewportHeight="64">
<path
android:pathData="M56.25,18V46L32,60 7.75,46V18L32,4Z"
android:fillColor="#6075f2"/>
<path
android:pathData="m41.5,26.5v11L32,43V60L56.25,46V18Z"
android:fillColor="#6b57ff"/>
<path
android:pathData="m32,43 l-9.5,-5.5v-11L7.75,18V46L32,60Z">
<aapt:attr name="android:fillColor">
<gradient
android:centerX="23.131"
android:centerY="18.441"
android:gradientRadius="42.132"
android:type="radial">
<item android:offset="0" android:color="#FF5383EC"/>
<item android:offset="0.867" android:color="#FF7F52FF"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="M22.5,26.5 L32,21 41.5,26.5 56.25,18 32,4 7.75,18Z">
<aapt:attr name="android:fillColor">
<gradient
android:startX="44.172"
android:startY="4.377"
android:endX="17.973"
android:endY="34.035"
android:type="linear">
<item android:offset="0" android:color="#FF33C3FF"/>
<item android:offset="0.878" android:color="#FF5383EC"/>
</gradient>
</aapt:attr>
</path>
<path
android:pathData="m32,21 l9.526,5.5v11L32,43 22.474,37.5v-11z"
android:fillColor="#000000"/>
</vector>
+25
View File
@@ -0,0 +1,25 @@
product:
type: kmp/lib
platforms: [ jvm, android ]
dependencies:
- $compose.runtime
- $compose.foundation
- $compose.material3
- $compose.ui
- $compose.components.resources
- $compose.preview
- $compose.hotReload.runtimeApi
- $libs.androidx.lifecycle.viewmodel.compose
- $libs.androidx.lifecycle.runtime.compose
dependencies@android:
- $compose.uiTooling
settings:
compose:
enabled: true
resources:
packageName: com.hyperling.weather.resources
# Generate public accessors so other modules (and previews) can use Res.*
exposedAccessors: true
+51
View File
@@ -0,0 +1,51 @@
package com.hyperling.weather
import androidx.compose.animation.AnimatedVisibility
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.safeContentPadding
import androidx.compose.material3.Button
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import org.jetbrains.compose.reload.DevelopmentEntryPoint
import org.jetbrains.compose.resources.painterResource
import com.hyperling.weather.resources.Res
import com.hyperling.weather.resources.compose_multiplatform
@Composable
@Preview
@DevelopmentEntryPoint
fun App() {
MaterialTheme {
var showContent by remember { mutableStateOf(false) }
Column(
modifier = Modifier
.background(MaterialTheme.colorScheme.primaryContainer)
.safeContentPadding()
.fillMaxSize(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Button(onClick = { showContent = !showContent }) {
Text("Click me!")
}
AnimatedVisibility(showContent) {
val greeting = remember { Greeting().greet() }
Column(
modifier = Modifier.fillMaxWidth(),
horizontalAlignment = Alignment.CenterHorizontally,
) {
Image(painterResource(Res.drawable.compose_multiplatform), null)
Text("Compose: $greeting")
}
}
}
}
}
+9
View File
@@ -0,0 +1,9 @@
package com.hyperling.weather
class Greeting {
private val platform = getPlatform()
fun greet(): String {
return "Hello, ${platform.name}!"
}
}
+7
View File
@@ -0,0 +1,7 @@
package com.hyperling.weather
interface Platform {
val name: String
}
expect fun getPlatform(): Platform
@@ -0,0 +1,9 @@
package com.hyperling.weather
import android.os.Build
class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}"
}
actual fun getPlatform(): Platform = AndroidPlatform()
+7
View File
@@ -0,0 +1,7 @@
package com.hyperling.weather
class JVMPlatform: Platform {
override val name: String = "Java ${System.getProperty("java.version")}"
}
actual fun getPlatform(): Platform = JVMPlatform()
+17
View File
@@ -0,0 +1,17 @@
package com.hyperling.weather
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertTrue
class PlatformTest {
@Test
fun `platform name is reported`() {
assertTrue(getPlatform().name.isNotBlank())
}
@Test
fun `greeting is built from the platform name`() {
assertEquals("Hello, ${getPlatform().name}!", Greeting().greet())
}
}
@@ -0,0 +1,11 @@
package com.hyperling.weather
import kotlin.test.Test
import kotlin.test.assertTrue
class PlatformAndroidTest {
@Test
fun `platform name is reported`() {
assertTrue(getPlatform().name.isNotBlank())
}
}
+11
View File
@@ -0,0 +1,11 @@
package com.hyperling.weather
import kotlin.test.Test
import kotlin.test.assertTrue
class PlatformJvmTest {
@Test
fun `platform name is reported`() {
assertTrue(getPlatform().name.isNotBlank())
}
}