From 5c983e52bd3946af24e073aea375d84be1c2cfaa Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Mon, 30 Sep 2024 17:56:10 +0600 Subject: [PATCH] add opportunity to add module with mermaid graph building --- mermaid/build.gradle | 18 ++++++++++++++++++ .../kotlin/NavigationMermaidBuilder.kt | 10 +++++----- sample/build.gradle | 1 + .../kotlin/ui/tree/CurrentTreeViewViewModel.kt | 5 +---- settings.gradle | 1 + 5 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 mermaid/build.gradle rename {sample => mermaid}/src/commonMain/kotlin/NavigationMermaidBuilder.kt (93%) diff --git a/mermaid/build.gradle b/mermaid/build.gradle new file mode 100644 index 00000000..1f82fff3 --- /dev/null +++ b/mermaid/build.gradle @@ -0,0 +1,18 @@ +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" + id "com.android.library" + id "org.jetbrains.dokka" +} + +apply from: "$mppProjectWithSerialization" + +kotlin { + sourceSets { + commonMain { + dependencies { + api project(":navigation.core") + } + } + } +} diff --git a/sample/src/commonMain/kotlin/NavigationMermaidBuilder.kt b/mermaid/src/commonMain/kotlin/NavigationMermaidBuilder.kt similarity index 93% rename from sample/src/commonMain/kotlin/NavigationMermaidBuilder.kt rename to mermaid/src/commonMain/kotlin/NavigationMermaidBuilder.kt index 3627d345..0ed9c93b 100644 --- a/sample/src/commonMain/kotlin/NavigationMermaidBuilder.kt +++ b/mermaid/src/commonMain/kotlin/NavigationMermaidBuilder.kt @@ -1,4 +1,4 @@ -package dev.inmo.navigation.sample +package dev.inmo.navigation.mermaid import dev.inmo.micro_utils.common.Either import dev.inmo.micro_utils.common.either @@ -11,10 +11,10 @@ object NavigationMermaidBuilder { internal const val startedClassName = "navigation_mermaid_started" internal val NavigationNodeState.className get() = when (this) { - NavigationNodeState.NEW -> newClassName - NavigationNodeState.CREATED -> createdClassName - NavigationNodeState.STARTED -> startedClassName - NavigationNodeState.RESUMED -> resumedClassName + NavigationNodeState.NEW -> NavigationMermaidBuilder.newClassName + NavigationNodeState.CREATED -> NavigationMermaidBuilder.createdClassName + NavigationNodeState.STARTED -> NavigationMermaidBuilder.startedClassName + NavigationNodeState.RESUMED -> NavigationMermaidBuilder.resumedClassName } fun className(state: NavigationNodeState) = state.className diff --git a/sample/build.gradle b/sample/build.gradle index d5602730..215d52f8 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -17,6 +17,7 @@ kotlin { commonMain { dependencies { api project(":navigation.core") + api project(":navigation.mermaid") api project(":navigation.mvvm") api libs.microutils.startup.launcher implementation compose.runtime diff --git a/sample/src/commonMain/kotlin/ui/tree/CurrentTreeViewViewModel.kt b/sample/src/commonMain/kotlin/ui/tree/CurrentTreeViewViewModel.kt index 3ee9a596..7c78b971 100644 --- a/sample/src/commonMain/kotlin/ui/tree/CurrentTreeViewViewModel.kt +++ b/sample/src/commonMain/kotlin/ui/tree/CurrentTreeViewViewModel.kt @@ -1,19 +1,16 @@ package dev.inmo.navigation.sample.ui.tree -import androidx.compose.runtime.mutableStateListOf import androidx.compose.runtime.mutableStateOf import dev.inmo.kslog.common.i import dev.inmo.kslog.common.logger -import dev.inmo.micro_utils.common.applyDiff import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions import dev.inmo.navigation.core.NavigationNode import dev.inmo.navigation.core.configs.NavigationNodeDefaultConfig import dev.inmo.navigation.core.extensions.onChangesInSubTree import dev.inmo.navigation.core.extensions.rootChain -import dev.inmo.navigation.core.visiter.walk import dev.inmo.navigation.core.visiter.walkOnNodes +import dev.inmo.navigation.mermaid.buildMermaidLines import dev.inmo.navigation.mvvm.ViewModel -import dev.inmo.navigation.sample.buildMermaidLines import kotlinx.coroutines.Job import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf diff --git a/settings.gradle b/settings.gradle index ae2a4d3f..63ba5fd2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -4,6 +4,7 @@ String[] includes = [ ":core", ":compose", ":mvvm", + ":mermaid", ":sample", ":sample:android_client", ]