Skip to content

Commit b634e06

Browse files
sample: voyager working android, desktop and web
feat: voyager module improvements
1 parent 8a16718 commit b634e06

File tree

43 files changed

+1860
-66
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1860
-66
lines changed

gradle/libs.versions.toml

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ junit = { group = "junit", name = "junit", version.ref = "junit" }
4848
androidx-test-ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "androidx-test-ext-junit" }
4949
espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso-core" }
5050
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
51+
activity-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "activity-compose" }
5152
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
5253
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
5354
ui = { group = "androidx.compose.ui", name = "ui" }

kotlin-js-store/yarn.lock

+842-19
Large diffs are not rendered by default.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/build
2+
/debug
3+
/release
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# multiplatform sample
2+
3+
### Running iOS
4+
- IPhone: `./gradlew :samples:multiplatform-voyager:iosDeployIPhone8Debug`
5+
- IPad: `./gradlew :samples:multiplatform-voyager:iosDeployIPadDebug`
6+
7+
### Running MacOS Native app (Desktop using Kotlin Native)
8+
```shell
9+
./gradlew :samples:multiplatform-voyager:runNativeDebug
10+
```
11+
12+
### Running JVM Native app (Desktop)
13+
```shell
14+
./gradlew :samples:multiplatform-voyager:run
15+
```
16+
17+
### Running Web Compose Canvas
18+
```shell
19+
./gradlew :samples:multiplatform-voyager:jsBrowserDevelopmentRun
20+
```
21+
22+
### Building Android App
23+
```shell
24+
./gradlew :samples:multiplatform-voyager:assembleDebug
25+
```
26+
27+
If you want to run Android sample in the emulator, you can open the project and run the application configuration `samples.multiplatform-voyager` on Android Studio.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat.Deb
2+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat.Dmg
3+
import org.jetbrains.compose.desktop.application.dsl.TargetFormat.Msi
4+
import org.jetbrains.compose.experimental.dsl.IOSDevices
5+
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
6+
7+
plugins {
8+
kotlin("multiplatform")
9+
kotlin("plugin.serialization") // required for type-safe routing
10+
id("com.android.application")
11+
id("org.jetbrains.compose")
12+
}
13+
14+
kotlin {
15+
android()
16+
17+
jvm("desktop")
18+
19+
js(IR) {
20+
browser()
21+
binaries.executable()
22+
}
23+
24+
val macOsConfiguation: KotlinNativeTarget.() -> Unit = {
25+
binaries {
26+
executable {
27+
entryPoint = "main"
28+
freeCompilerArgs += listOf(
29+
"-linker-option", "-framework", "-linker-option", "Metal"
30+
)
31+
}
32+
}
33+
}
34+
macosX64(macOsConfiguation)
35+
macosArm64(macOsConfiguation)
36+
val uikitConfiguration: KotlinNativeTarget.() -> Unit = {
37+
binaries {
38+
executable() {
39+
entryPoint = "main"
40+
freeCompilerArgs += listOf(
41+
"-linker-option", "-framework", "-linker-option", "Metal",
42+
"-linker-option", "-framework", "-linker-option", "CoreText",
43+
"-linker-option", "-framework", "-linker-option", "CoreGraphics"
44+
)
45+
}
46+
}
47+
}
48+
ios("uikit")
49+
iosX64("uikitX64", uikitConfiguration)
50+
iosArm64("uikitArm64", uikitConfiguration)
51+
iosSimulatorArm64("uikitSimulatorArm64", uikitConfiguration)
52+
53+
sourceSets {
54+
val commonMain by getting {
55+
dependencies {
56+
implementation(compose.material)
57+
implementation(compose.runtime)
58+
59+
implementation(projects.voyager)
60+
}
61+
}
62+
63+
val desktopMain by getting {
64+
dependsOn(commonMain)
65+
dependencies {
66+
implementation(compose.desktop.currentOs)
67+
}
68+
}
69+
70+
val androidMain by getting {
71+
dependsOn(commonMain)
72+
dependencies {
73+
implementation(libs.core.ktx)
74+
implementation(libs.lifecycle.runtime.ktx)
75+
implementation(libs.activity.appcompat)
76+
implementation(libs.activity.compose)
77+
}
78+
}
79+
80+
val jsMain by getting {
81+
dependencies { }
82+
}
83+
84+
val nativeMain by creating {
85+
dependsOn(commonMain)
86+
}
87+
88+
val macosMain by creating {
89+
dependsOn(nativeMain)
90+
}
91+
val macosX64Main by getting {
92+
dependsOn(macosMain)
93+
}
94+
val macosArm64Main by getting {
95+
dependsOn(macosMain)
96+
}
97+
val iosMain = getByName("uikitMain").apply {
98+
dependsOn(nativeMain)
99+
}
100+
val iosSimulatorArm64Main = getByName("uikitSimulatorArm64Main").apply {
101+
dependsOn(iosMain)
102+
}
103+
}
104+
}
105+
106+
compose.desktop {
107+
application {
108+
mainClass = "dev.programadorthi.routing.voyager.AppKt"
109+
nativeDistributions {
110+
targetFormats(Dmg, Msi, Deb)
111+
packageName = "jvm"
112+
packageVersion = "1.0.0"
113+
}
114+
}
115+
}
116+
117+
compose.experimental {
118+
web.application {}
119+
120+
uikit.application {
121+
bundleIdPrefix = "dev.programadorthi.routing.voyager"
122+
projectName = "RoutingVoyagerApplication"
123+
deployConfigurations {
124+
simulator("IPhone8") {
125+
device = IOSDevices.IPHONE_8
126+
}
127+
simulator("IPad") {
128+
device = IOSDevices.IPAD_MINI_6th_Gen
129+
}
130+
}
131+
}
132+
}
133+
134+
android {
135+
compileSdk = 33
136+
137+
defaultConfig {
138+
applicationId = "dev.programadorthi.routing.voyager.application"
139+
minSdk = 21
140+
targetSdk = 33
141+
versionCode = 1
142+
versionName = "1.0"
143+
}
144+
145+
compileOptions {
146+
sourceCompatibility = JavaVersion.VERSION_1_8
147+
targetCompatibility = JavaVersion.VERSION_1_8
148+
}
149+
}
150+
151+
compose.desktop.nativeApplication {
152+
targets(kotlin.targets.getByName("macosX64"))
153+
distributions {
154+
targetFormats(Dmg)
155+
packageName = "RoutingVoyagerApplication"
156+
packageVersion = "1.0.0"
157+
}
158+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="dev.programadorthi.routing.voyager">
4+
5+
<application
6+
android:label="Voyager Sample Multiplatform Routing"
7+
android:theme="@style/Theme.AppCompat.Light.NoActionBar"
8+
android:icon="@mipmap/ic_launcher"
9+
android:roundIcon="@mipmap/ic_launcher_round"
10+
android:allowBackup="true"
11+
android:supportsRtl="true">
12+
<activity
13+
android:name=".SampleActivity"
14+
android:exported="true">
15+
<intent-filter>
16+
<action android:name="android.intent.action.MAIN" />
17+
<category android:name="android.intent.category.LAUNCHER" />
18+
</intent-filter>
19+
</activity>
20+
21+
</application>
22+
23+
</manifest>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package dev.programadorthi.routing.voyager
2+
3+
import android.os.Bundle
4+
import androidx.activity.compose.setContent
5+
import androidx.appcompat.app.AppCompatActivity
6+
7+
public class SampleActivity : AppCompatActivity() {
8+
override fun onCreate(savedInstanceState: Bundle?) {
9+
super.onCreate(savedInstanceState)
10+
11+
setContent {
12+
SampleApplication()
13+
}
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:aapt="http://schemas.android.com/aapt"
3+
android:width="108dp"
4+
android:height="108dp"
5+
android:viewportWidth="108"
6+
android:viewportHeight="108">
7+
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
8+
<aapt:attr name="android:fillColor">
9+
<gradient
10+
android:endX="85.84757"
11+
android:endY="92.4963"
12+
android:startX="42.9492"
13+
android:startY="49.59793"
14+
android:type="linear">
15+
<item
16+
android:color="#44000000"
17+
android:offset="0.0" />
18+
<item
19+
android:color="#00000000"
20+
android:offset="1.0" />
21+
</gradient>
22+
</aapt:attr>
23+
</path>
24+
<path
25+
android:fillColor="#FFFFFF"
26+
android:fillType="nonZero"
27+
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
28+
android:strokeWidth="1"
29+
android:strokeColor="#00000000" />
30+
</vector>

0 commit comments

Comments
 (0)