Skip to content

Commit a43176f

Browse files
author
TEYSSANDIER Raphael
committed
feature: Add nav3
1 parent 1b207d6 commit a43176f

File tree

12 files changed

+195
-0
lines changed

12 files changed

+195
-0
lines changed

FloconDesktop/composeApp/src/commonMain/kotlin/io/github/openflocon/flocondesktop/App.kt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ import androidx.compose.foundation.layout.Box
44
import androidx.compose.foundation.layout.fillMaxSize
55
import androidx.compose.foundation.layout.safeContentPadding
66
import androidx.compose.runtime.Composable
7+
import androidx.compose.runtime.mutableStateListOf
8+
import androidx.compose.runtime.remember
79
import androidx.compose.ui.Modifier
10+
import androidx.navigation3.runtime.rememberSavedStateNavEntryDecorator
11+
import androidx.navigation3.ui.NavDisplay
12+
import androidx.navigation3.ui.rememberSceneSetupNavEntryDecorator
813
import com.flocon.data.remote.dataRemoteModule
914
import io.github.openflocon.data.core.dataCoreModule
1015
import io.github.openflocon.data.local.dataLocalModule
@@ -69,3 +74,18 @@ fun App() {
6974
}
7075
}
7176
}
77+
78+
@Composable
79+
private fun Navigation() {
80+
val backStack = remember { mutableStateListOf<Any>() }
81+
82+
NavDisplay(
83+
backStack = backStack,
84+
entryDecorators = listOf(
85+
rememberSceneSetupNavEntryDecorator(),
86+
rememberSavedStateNavEntryDecorator()
87+
)
88+
) {
89+
90+
}
91+
}

FloconDesktop/gradle/libs.versions.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ other-jsontree = "2.5.0"
3535
uiToolingPreviewDesktop = "1.8.2"
3636
buildconfig = "5.6.8"
3737

38+
# TODO Sort
39+
nav3Core = "1.0.0-alpha08"
40+
lifecycleViewmodelNav3 = "2.10.0-alpha03"
41+
kotlinxSerializationCore = "1.8.1"
42+
3843
[libraries]
3944
kermit = { module = "co.touchlab:kermit", version.ref = "kermit" }
4045
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
@@ -86,6 +91,14 @@ androidx-core = { group = "androidx.test", name = "core", version.ref = "core" }
8691
other-jsontree = { module = "com.sebastianneubauer.jsontree:jsontree", version.ref = "other-jsontree"}
8792
ui-tooling-preview-desktop = { module = "org.jetbrains.compose.ui:ui-tooling-preview-desktop", version.ref = "uiToolingPreviewDesktop" }
8893

94+
# TODO Sort
95+
androidx-navigation3-runtime = { module = "androidx.navigation3:navigation3-runtime", version.ref = "nav3Core" }
96+
androidx-navigation3-ui = { module = "androidx.navigation3:navigation3-ui", version.ref = "nav3Core" }
97+
98+
# Optional add-on libraries
99+
androidx-lifecycle-viewmodel-navigation3 = { module = "androidx.lifecycle:lifecycle-viewmodel-navigation3", version.ref = "lifecycleViewmodelNav3" }
100+
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinxSerializationCore" }
101+
89102
[plugins]
90103
composeHotReload = { id = "org.jetbrains.compose.hot-reload", version.ref = "composeHotReload" }
91104
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "composeMultiplatform" }

FloconDesktop/library/designsystem/build.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ kotlin {
3131
api(compose.components.resources)
3232
api(compose.components.uiToolingPreview)
3333
api(libs.other.jsontree)
34+
35+
api(libs.androidx.navigation3.ui)
36+
api(libs.androidx.navigation3.runtime)
37+
38+
// Not KMP yet
39+
// api(libs.androidx.lifecycle.viewmodel.navigation3)
40+
api(libs.kotlinx.serialization.core)
3441
api("com.composables:core:1.43.1")
3542
}
3643
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
plugins {
2+
alias(libs.plugins.kotlinMultiplatform)
3+
alias(libs.plugins.android.kotlin.multiplatform.library)
4+
alias(libs.plugins.android.lint)
5+
}
6+
7+
kotlin {
8+
9+
// Target declarations - add or remove as needed below. These define
10+
// which platforms this KMP module supports.
11+
// See: https://kotlinlang.org/docs/multiplatform-discover-project.html#targets
12+
androidLibrary {
13+
namespace = "io.github.openflocon.navigation"
14+
compileSdk = 36
15+
minSdk = 24
16+
17+
withHostTestBuilder {
18+
}
19+
20+
withDeviceTestBuilder {
21+
sourceSetTreeName = "test"
22+
}.configure {
23+
instrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
24+
}
25+
}
26+
27+
// For iOS targets, this is also where you should
28+
// configure native binary output. For more information, see:
29+
// https://kotlinlang.org/docs/multiplatform-build-native-binaries.html#build-xcframeworks
30+
31+
// A step-by-step guide on how to include this library in an XCode
32+
// project can be found here:
33+
// https://developer.android.com/kotlin/multiplatform/migrate
34+
val xcfName = "navigationKit"
35+
36+
iosX64 {
37+
binaries.framework {
38+
baseName = xcfName
39+
}
40+
}
41+
42+
iosArm64 {
43+
binaries.framework {
44+
baseName = xcfName
45+
}
46+
}
47+
48+
iosSimulatorArm64 {
49+
binaries.framework {
50+
baseName = xcfName
51+
}
52+
}
53+
54+
// Source set declarations.
55+
// Declaring a target automatically creates a source set with the same name. By default, the
56+
// Kotlin Gradle Plugin creates additional source sets that depend on each other, since it is
57+
// common to share sources between related targets.
58+
// See: https://kotlinlang.org/docs/multiplatform-hierarchy.html
59+
sourceSets {
60+
commonMain {
61+
dependencies {
62+
implementation(libs.kotlin.stdlib)
63+
// Add KMP dependencies here
64+
}
65+
}
66+
67+
commonTest {
68+
dependencies {
69+
implementation(libs.kotlin.test)
70+
}
71+
}
72+
73+
androidMain {
74+
dependencies {
75+
// Add Android-specific dependencies here. Note that this source set depends on
76+
// commonMain by default and will correctly pull the Android artifacts of any KMP
77+
// dependencies declared in commonMain.
78+
}
79+
}
80+
81+
getByName("androidDeviceTest") {
82+
dependencies {
83+
implementation(libs.androidx.runner)
84+
implementation(libs.androidx.core)
85+
implementation(libs.androidx.testExt.junit)
86+
}
87+
}
88+
89+
iosMain {
90+
dependencies {
91+
// Add iOS-specific dependencies here. This a source set created by Kotlin Gradle
92+
// Plugin (KGP) that each specific iOS target (e.g., iosX64) depends on as
93+
// part of KMP’s default source set hierarchy. Note that this source set depends
94+
// on common by default and will correctly pull the iOS artifacts of any
95+
// KMP dependencies declared in commonMain.
96+
}
97+
}
98+
}
99+
100+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package io.github.openflocon.navigation
2+
3+
import android.support.test.InstrumentationRegistry
4+
import android.support.test.runner.AndroidJUnit4
5+
6+
import org.junit.Test
7+
import org.junit.runner.RunWith
8+
9+
import org.junit.Assert.*
10+
11+
/**
12+
* Instrumented test, which will execute on an Android device.
13+
*
14+
* See [testing documentation](http://d.android.com/tools/testing).
15+
*/
16+
@RunWith(AndroidJUnit4::class)
17+
class ExampleInstrumentedTest {
18+
@Test
19+
fun useAppContext() {
20+
// Context of the app under test.
21+
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22+
assertEquals("io.github.openflocon.navigation.test", appContext.packageName)
23+
}
24+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package io.github.openflocon.navigation
2+
3+
import kotlin.test.Test
4+
import kotlin.test.assertEquals
5+
6+
/**
7+
* Example local unit test, which will execute on the development machine (host).
8+
*
9+
* See [testing documentation](http://d.android.com/tools/testing).
10+
*/
11+
class ExampleUnitTest {
12+
@Test
13+
fun addition_isCorrect() {
14+
assertEquals(4, 2 + 2)
15+
}
16+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
3+
4+
</manifest>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package io.github.openflocon.navigation
2+
3+
actual fun platform() = "Android"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package io.github.openflocon.navigation
2+
3+
expect fun platform(): String

0 commit comments

Comments
 (0)