From 57519219ea2e5e4b50030750ef1466cf9ac5eedd Mon Sep 17 00:00:00 2001 From: y9san9 Date: Sat, 4 May 2024 08:19:13 +0300 Subject: [PATCH] fix: changed ComposeWrapper api --- gradle/libs.versions.toml | 2 +- .../compose/interceptor/CombinedComposeInterceptor.kt | 7 +++---- .../navigation/compose/interceptor/ComposeInterceptor.kt | 6 +----- .../ksm/navigation/compose/plugin/ComposeContent.kt | 2 +- .../ksm/navigation/compose/plugin/ComposePlugin.kt | 2 +- .../ksm/navigation/compose/wrapper/ComposeWrapper.kt | 9 ++------- 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 29fdfb3..833e624 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -11,7 +11,7 @@ androidx-lifecycle = "2.7.0" ktgbotapi = "11.0.0" mdi = "0.0.38" -ksm = "0.0.29" +ksm = "0.0.30" [libraries] diff --git a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/CombinedComposeInterceptor.kt b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/CombinedComposeInterceptor.kt index 775ef36..bf90914 100644 --- a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/CombinedComposeInterceptor.kt +++ b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/CombinedComposeInterceptor.kt @@ -1,16 +1,15 @@ package ksm.navigation.compose.interceptor -import ksm.context.StateContext import ksm.navigation.compose.plugin.ComposeContent internal class CombinedComposeInterceptor( private val first: ComposeInterceptor?, private val second: ComposeInterceptor ) : ComposeInterceptor { - override fun intercept(context: StateContext, base: ComposeContent): ComposeContent { + override fun intercept(base: ComposeContent): ComposeContent { var applied = base - applied = first?.intercept(context, applied) ?: applied - applied = second.intercept(context, applied) + applied = first?.intercept(applied) ?: applied + applied = second.intercept(applied) return applied } } diff --git a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/ComposeInterceptor.kt b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/ComposeInterceptor.kt index e3f97f5..3950fcd 100644 --- a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/ComposeInterceptor.kt +++ b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/interceptor/ComposeInterceptor.kt @@ -1,13 +1,9 @@ package ksm.navigation.compose.interceptor -import ksm.context.StateContext import ksm.navigation.compose.plugin.ComposeContent public fun interface ComposeInterceptor { - public fun intercept( - context: StateContext, - base: ComposeContent - ): ComposeContent + public fun intercept(base: ComposeContent): ComposeContent } public operator fun ComposeInterceptor?.plus(other: ComposeInterceptor): ComposeInterceptor { diff --git a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposeContent.kt b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposeContent.kt index 4183fcf..ecbdd19 100644 --- a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposeContent.kt +++ b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposeContent.kt @@ -5,5 +5,5 @@ import ksm.StateController public fun interface ComposeContent { @Composable - public fun Content(controller: StateController) + public fun StateController.Content() } diff --git a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposePlugin.kt b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposePlugin.kt index 27bc9b9..b5ab759 100644 --- a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposePlugin.kt +++ b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/plugin/ComposePlugin.kt @@ -61,7 +61,7 @@ public class ComposePlugin( val entry = context.require(ComposeEntry) val interceptor = entry.interceptor val base = ComposeContent(content) - entry.content = interceptor?.intercept(context, base) ?: base + entry.content = interceptor?.intercept(base) ?: base } public fun content(context: StateContext): ComposeContent? { diff --git a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/wrapper/ComposeWrapper.kt b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/wrapper/ComposeWrapper.kt index 176b3bb..4a4c94e 100644 --- a/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/wrapper/ComposeWrapper.kt +++ b/navigation/navigation-compose/src/main/kotlin/ksm/navigation/compose/wrapper/ComposeWrapper.kt @@ -1,17 +1,12 @@ package ksm.navigation.compose.wrapper -import ksm.StateController -import ksm.asStateController import ksm.navigation.compose.interceptor.ComposeInterceptor import ksm.navigation.compose.plugin.ComposeContent public fun interface ComposeWrapper { - public fun StateController.wrap(content: ComposeContent): ComposeContent + public fun wrap(content: ComposeContent): ComposeContent } public fun ComposeWrapper.toInterceptor(): ComposeInterceptor { - return ComposeInterceptor { context, base -> - val controller = context.asStateController() - controller.wrap(base) - } + return ComposeInterceptor(::wrap) }