diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f8a19a26..d9271d0c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,14 @@ Change Log ========== +## 0.24.0 **UNRELEASED** + +### Codegen + +- Removed `experimentalNavigation` option and `@UseExperimentalNavigation`. The generated + code will now always use Khonshu's built-in navigation instead of androidx.navigation. + + ## 0.23.1 *(2024-03-08)* ### Navigation diff --git a/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt b/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt index f3aece53d..3eca642d3 100644 --- a/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt +++ b/codegen-compiler-test/src/test/kotlin/com/freeletics/khonshu/codegen/codegen/NavHostActivityCodegenTest.kt @@ -26,7 +26,6 @@ internal class NavHostActivityCodegenTest { parentScope = ClassName("com.test.parent", "TestParentScope"), stateMachine = ClassName("com.test", "TestStateMachine"), activityBaseClass = ClassName("androidx.activity", "ComponentActivity"), - experimentalNavigation = false, navHostParameter = ComposableParameter( "navHost", ClassName("com.freeletics.khonshu.codegen", "SimpleNavHost"), @@ -93,8 +92,7 @@ internal class NavHostActivityCodegenTest { import com.freeletics.khonshu.codegen.`internal`.component import com.freeletics.khonshu.navigation.NavDestination import com.freeletics.khonshu.navigation.NavEventNavigator - import com.freeletics.khonshu.navigation.androidx.NavHost - import com.freeletics.khonshu.navigation.androidx.NavHostTransitionAnimations + import com.freeletics.khonshu.navigation.NavHost import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler import com.squareup.anvil.annotations.ContributesSubcomponent import com.squareup.anvil.annotations.ContributesTo @@ -221,7 +219,6 @@ internal class NavHostActivityCodegenTest { deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, navEventNavigator = remember(component) { component.navEventNavigator }, destinationChangedCallback = destinationChangedCallback, - transitionAnimations = NavHostTransitionAnimations.noAnimations(), ) } } @@ -309,8 +306,7 @@ internal class NavHostActivityCodegenTest { import com.freeletics.khonshu.codegen.`internal`.component import com.freeletics.khonshu.navigation.NavDestination import com.freeletics.khonshu.navigation.NavEventNavigator - import com.freeletics.khonshu.navigation.androidx.NavHost - import com.freeletics.khonshu.navigation.androidx.NavHostTransitionAnimations + import com.freeletics.khonshu.navigation.NavHost import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler import com.squareup.anvil.annotations.ContributesSubcomponent import com.squareup.anvil.annotations.ContributesTo @@ -435,7 +431,6 @@ internal class NavHostActivityCodegenTest { deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, navEventNavigator = remember(component) { component.navEventNavigator }, destinationChangedCallback = destinationChangedCallback, - transitionAnimations = NavHostTransitionAnimations.noAnimations(), ) } } @@ -545,8 +540,7 @@ internal class NavHostActivityCodegenTest { import com.freeletics.khonshu.codegen.`internal`.component import com.freeletics.khonshu.navigation.NavDestination import com.freeletics.khonshu.navigation.NavEventNavigator - import com.freeletics.khonshu.navigation.androidx.NavHost - import com.freeletics.khonshu.navigation.androidx.NavHostTransitionAnimations + import com.freeletics.khonshu.navigation.NavHost import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler import com.squareup.anvil.annotations.ContributesSubcomponent import com.squareup.anvil.annotations.ContributesTo @@ -685,7 +679,6 @@ internal class NavHostActivityCodegenTest { deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, navEventNavigator = remember(component) { component.navEventNavigator }, destinationChangedCallback = destinationChangedCallback, - transitionAnimations = NavHostTransitionAnimations.noAnimations(), ) } } @@ -778,8 +771,7 @@ internal class NavHostActivityCodegenTest { import com.freeletics.khonshu.codegen.`internal`.component import com.freeletics.khonshu.navigation.NavDestination import com.freeletics.khonshu.navigation.NavEventNavigator - import com.freeletics.khonshu.navigation.androidx.NavHost - import com.freeletics.khonshu.navigation.androidx.NavHostTransitionAnimations + import com.freeletics.khonshu.navigation.NavHost import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler import com.squareup.anvil.annotations.ContributesSubcomponent import com.squareup.anvil.annotations.ContributesTo @@ -904,7 +896,6 @@ internal class NavHostActivityCodegenTest { deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, navEventNavigator = remember(component) { component.navEventNavigator }, destinationChangedCallback = destinationChangedCallback, - transitionAnimations = NavHostTransitionAnimations.noAnimations(), ) } } @@ -985,8 +976,7 @@ internal class NavHostActivityCodegenTest { import com.freeletics.khonshu.codegen.`internal`.component import com.freeletics.khonshu.navigation.NavDestination import com.freeletics.khonshu.navigation.NavEventNavigator - import com.freeletics.khonshu.navigation.androidx.NavHost - import com.freeletics.khonshu.navigation.androidx.NavHostTransitionAnimations + import com.freeletics.khonshu.navigation.NavHost import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler import com.squareup.anvil.annotations.ContributesSubcomponent import com.squareup.anvil.annotations.ContributesTo @@ -1113,7 +1103,6 @@ internal class NavHostActivityCodegenTest { deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, navEventNavigator = remember(component) { component.navEventNavigator }, destinationChangedCallback = destinationChangedCallback, - transitionAnimations = NavHostTransitionAnimations.noAnimations(), ) } } @@ -1199,8 +1188,7 @@ internal class NavHostActivityCodegenTest { import com.freeletics.khonshu.codegen.`internal`.component import com.freeletics.khonshu.navigation.NavDestination import com.freeletics.khonshu.navigation.NavEventNavigator - import com.freeletics.khonshu.navigation.androidx.NavHost - import com.freeletics.khonshu.navigation.androidx.NavHostTransitionAnimations + import com.freeletics.khonshu.navigation.NavHost import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler import com.squareup.anvil.annotations.ContributesSubcomponent import com.squareup.anvil.annotations.ContributesTo @@ -1327,7 +1315,6 @@ internal class NavHostActivityCodegenTest { deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, navEventNavigator = remember(component) { component.navEventNavigator }, destinationChangedCallback = destinationChangedCallback, - transitionAnimations = NavHostTransitionAnimations.noAnimations(), ) } } @@ -1358,242 +1345,4 @@ internal class NavHostActivityCodegenTest { test(withLambdaParameter, "com/test/Test.kt", source, expected) } - - @Test - fun `generates code for experimental navigation`() { - val withExperimentalNavigation = data.copy(experimentalNavigation = true) - - @Language("kotlin") - val source = """ - package com.test - - import androidx.activity.ComponentActivity - import androidx.compose.runtime.Composable - import androidx.compose.ui.Modifier - import com.freeletics.khonshu.codegen.NavHostActivity - import com.freeletics.khonshu.codegen.SimpleNavHost - import com.freeletics.khonshu.navigation.BaseRoute - import com.freeletics.khonshu.navigation.NavRoot - import com.freeletics.khonshu.navigation.NavDestination - import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler - import com.test.parent.TestParentScope - - @NavHostActivity( - scope = TestScreen::class, - parentScope = TestParentScope::class, - stateMachine = TestStateMachine::class, - activityBaseClass = ComponentActivity::class, - experimentalNavigation = true, - ) - @Composable - @Suppress("unused_parameter") - public fun Test( - state: TestState, - sendAction: (TestAction) -> Unit, - navHost: SimpleNavHost, - ) { - navHost(TestRoot(), Modifier) {} - } - """.trimIndent() - - @Language("kotlin") - val expected = """ - package com.test - - import android.os.Bundle - import androidx.activity.ComponentActivity - import androidx.activity.compose.setContent - import androidx.compose.runtime.Composable - import androidx.compose.runtime.CompositionLocalProvider - import androidx.compose.runtime.remember - import androidx.compose.runtime.rememberCoroutineScope - import androidx.lifecycle.SavedStateHandle - import com.freeletics.khonshu.codegen.SimpleNavHost - import com.freeletics.khonshu.codegen.UseExperimentalNavigation - import com.freeletics.khonshu.codegen.`internal`.ActivityComponentProvider - import com.freeletics.khonshu.codegen.`internal`.InternalCodegenApi - import com.freeletics.khonshu.codegen.`internal`.LocalActivityComponentProvider - import com.freeletics.khonshu.codegen.`internal`.asComposeState - import com.freeletics.khonshu.codegen.`internal`.component - import com.freeletics.khonshu.navigation.NavDestination - import com.freeletics.khonshu.navigation.NavEventNavigator - import com.freeletics.khonshu.navigation.androidx.NavHostTransitionAnimations - import com.freeletics.khonshu.navigation.deeplinks.DeepLinkHandler - import com.squareup.anvil.annotations.ContributesSubcomponent - import com.squareup.anvil.annotations.ContributesTo - import com.squareup.anvil.annotations.optional.ForScope - import com.squareup.anvil.annotations.optional.SingleIn - import com.test.parent.TestParentScope - import dagger.BindsInstance - import dagger.Module - import dagger.Provides - import dagger.multibindings.Multibinds - import java.io.Closeable - import kotlin.Boolean - import kotlin.OptIn - import kotlin.Unit - import kotlin.collections.Set - import kotlin.jvm.JvmSuppressWildcards - import kotlin.reflect.KClass - import kotlinx.collections.immutable.ImmutableSet - import kotlinx.collections.immutable.toImmutableSet - import kotlinx.coroutines.launch - import com.freeletics.khonshu.navigation.NavHost as navigationNavHost - import com.freeletics.khonshu.navigation.androidx.NavHost as androidxNavHost - - @OptIn(InternalCodegenApi::class) - @SingleIn(TestScreen::class) - @ContributesSubcomponent( - scope = TestScreen::class, - parentScope = TestParentScope::class, - ) - public interface KhonshuTestComponent : Closeable { - public val testStateMachine: TestStateMachine - - @get:ForScope(TestScreen::class) - public val navEventNavigator: NavEventNavigator - - public val destinations: ImmutableSet - - public val deepLinkHandlers: ImmutableSet - - public val deepLinkPrefixes: ImmutableSet - - @get:UseExperimentalNavigation - public val useExperimentalNavigation: Boolean - - @get:ForScope(TestScreen::class) - public val closeables: Set - - override fun close() { - closeables.forEach { - it.close() - } - } - - @ContributesSubcomponent.Factory - public interface Factory { - public fun create(@BindsInstance @ForScope(TestScreen::class) - savedStateHandle: SavedStateHandle, @BindsInstance @ForScope(TestScreen::class) - arguments: Bundle): KhonshuTestComponent - } - - @ContributesTo(TestParentScope::class) - public interface ParentComponent { - public fun khonshuTestComponentFactory(): Factory - } - } - - @OptIn(InternalCodegenApi::class) - public class KhonshuTestComponentProvider( - private final val activity: ComponentActivity, - ) : ActivityComponentProvider { - override fun provide(scope: KClass<*>): C = component(activity, scope, TestScreen::class, - TestParentScope::class) { parentComponent: KhonshuTestComponent.ParentComponent, - savedStateHandle -> - parentComponent.khonshuTestComponentFactory().create(savedStateHandle, activity.intent.extras ?: - Bundle.EMPTY) - } - } - - @Module - @ContributesTo(TestScreen::class) - public interface KhonshuTestModule { - @Multibinds - @ForScope(TestScreen::class) - public fun bindCloseables(): Set - } - - @Module - @ContributesTo(TestScreen::class) - public interface KhonshuTestActivityModule { - @Multibinds - public fun bindDeepLinkHandler(): Set - - @Multibinds - public fun bindDeepLinkPrefix(): Set - - public companion object { - @Provides - public fun provideImmutableNavDestinations(destinations: @JvmSuppressWildcards - Set): ImmutableSet = destinations.toImmutableSet() - - @Provides - public fun provideImmutableDeepLinkHandlers(handlers: @JvmSuppressWildcards - Set): ImmutableSet = handlers.toImmutableSet() - - @Provides - public fun provideImmutableDeepLinkPrefixes(prefixes: @JvmSuppressWildcards - Set): ImmutableSet = - prefixes.toImmutableSet() - } - } - - @OptIn(InternalCodegenApi::class) - public class KhonshuTestActivity : ComponentActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - setContent { - val componentProvider = remember { - KhonshuTestComponentProvider(this) - } - val component = remember(componentProvider) { - componentProvider.provide(TestScreen::class) - } - KhonshuTest(component) { startRoute, modifier, destinationChangedCallback -> - CompositionLocalProvider(LocalActivityComponentProvider provides componentProvider) { - val useExperimentalNavigation = remember(component) { - component.useExperimentalNavigation - } - if (useExperimentalNavigation) { - navigationNavHost( - startRoute = startRoute, - destinations = remember(component) { component.destinations }, - modifier = modifier, - deepLinkHandlers = remember(component) { component.deepLinkHandlers }, - deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, - navEventNavigator = remember(component) { component.navEventNavigator }, - destinationChangedCallback = destinationChangedCallback, - ) - } else { - androidxNavHost( - startRoute = startRoute, - destinations = remember(component) { component.destinations }, - modifier = modifier, - deepLinkHandlers = remember(component) { component.deepLinkHandlers }, - deepLinkPrefixes = remember(component) { component.deepLinkPrefixes }, - navEventNavigator = remember(component) { component.navEventNavigator }, - destinationChangedCallback = destinationChangedCallback, - transitionAnimations = NavHostTransitionAnimations.noAnimations(), - ) - } - } - } - } - } - } - - @Composable - @OptIn(InternalCodegenApi::class) - private fun KhonshuTest(component: KhonshuTestComponent, navHost: SimpleNavHost) { - val stateMachine = remember { component.testStateMachine } - val scope = rememberCoroutineScope() - val sendAction: (TestAction) -> Unit = remember(stateMachine, scope) { - { scope.launch { stateMachine.dispatch(it) } } - } - val state = stateMachine.asComposeState() - val currentState = state.value - if (currentState != null) { - Test( - state = currentState, - sendAction = sendAction, - navHost = navHost, - ) - } - } - - """.trimIndent() - - test(withExperimentalNavigation, "com/test/Test.kt", source, expected) - } } diff --git a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/Data.kt b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/Data.kt index 26b2e22ad..7933f1d14 100644 --- a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/Data.kt +++ b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/Data.kt @@ -57,7 +57,6 @@ public data class NavHostActivityData( public val activityBaseClass: ClassName, - val experimentalNavigation: Boolean, val navHostParameter: ComposableParameter, override val stateParameter: ComposableParameter?, override val sendActionParameter: ComposableParameter?, diff --git a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ActivityGenerator.kt b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ActivityGenerator.kt index 968a82561..55bcf4e34 100644 --- a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ActivityGenerator.kt +++ b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ActivityGenerator.kt @@ -2,16 +2,13 @@ package com.freeletics.khonshu.codegen.codegen import com.freeletics.khonshu.codegen.BaseData import com.freeletics.khonshu.codegen.NavHostActivityData -import com.freeletics.khonshu.codegen.util.androidxNavHost import com.freeletics.khonshu.codegen.util.bundle import com.freeletics.khonshu.codegen.util.compositionLocalProvider -import com.freeletics.khonshu.codegen.util.experimentalNavHost import com.freeletics.khonshu.codegen.util.localActivityComponentProvider -import com.freeletics.khonshu.codegen.util.navHostTransitionAnimations +import com.freeletics.khonshu.codegen.util.navHost import com.freeletics.khonshu.codegen.util.optInAnnotation import com.freeletics.khonshu.codegen.util.remember import com.freeletics.khonshu.codegen.util.setContent -import com.squareup.kotlinpoet.CodeBlock import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier.OVERRIDE import com.squareup.kotlinpoet.TypeSpec @@ -49,35 +46,7 @@ internal class ActivityGenerator( compositionLocalProvider, localActivityComponentProvider, ) - .apply { - if (data.experimentalNavigation) { - beginControlFlow("val useExperimentalNavigation = %M(component)", remember) - .addStatement("component.useExperimentalNavigation") - .endControlFlow() - .beginControlFlow("if (useExperimentalNavigation)") - .addCode(callNavHost(true)) - .nextControlFlow("else") - .addCode(callNavHost(false)) - .endControlFlow() - } else { - addCode(callNavHost(false)) - } - } - .endControlFlow() - .endControlFlow() - .endControlFlow() - .build() - } - - private fun callNavHost(experimental: Boolean): CodeBlock { - return CodeBlock.builder() - .apply { - if (experimental) { - addStatement("%M(", experimentalNavHost) - } else { - addStatement("%M(", androidxNavHost) - } - } + .addStatement("%M(", navHost) .addStatement(" startRoute = startRoute,") .addStatement(" destinations = %M(component) { component.destinations },", remember) .addStatement(" modifier = modifier,") @@ -85,12 +54,10 @@ internal class ActivityGenerator( .addStatement(" deepLinkPrefixes = %M(component) { component.deepLinkPrefixes },", remember) .addStatement(" navEventNavigator = %M(component) { component.navEventNavigator },", remember) .addStatement(" destinationChangedCallback = destinationChangedCallback,") - .apply { - if (!experimental) { - addStatement(" transitionAnimations = %T.noAnimations(),", navHostTransitionAnimations) - } - } .addStatement(")") + .endControlFlow() + .endControlFlow() + .endControlFlow() .build() } } diff --git a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ComponentGenerator.kt b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ComponentGenerator.kt index 4dfdeba53..aef0712bc 100644 --- a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ComponentGenerator.kt +++ b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/codegen/ComponentGenerator.kt @@ -2,7 +2,6 @@ package com.freeletics.khonshu.codegen.codegen import com.freeletics.khonshu.codegen.BaseData import com.freeletics.khonshu.codegen.NavHostActivityData -import com.freeletics.khonshu.codegen.UseExperimentalNavigation import com.freeletics.khonshu.codegen.util.asParameter import com.freeletics.khonshu.codegen.util.bindsInstanceParameter import com.freeletics.khonshu.codegen.util.contributesToAnnotation @@ -19,9 +18,7 @@ import com.freeletics.khonshu.codegen.util.simplePropertySpec import com.freeletics.khonshu.codegen.util.subcomponentAnnotation import com.freeletics.khonshu.codegen.util.subcomponentFactoryAnnotation import com.squareup.anvil.compiler.internal.decapitalize -import com.squareup.kotlinpoet.AnnotationSpec import com.squareup.kotlinpoet.AnnotationSpec.UseSiteTarget.GET -import com.squareup.kotlinpoet.BOOLEAN import com.squareup.kotlinpoet.FunSpec import com.squareup.kotlinpoet.KModifier.ABSTRACT import com.squareup.kotlinpoet.KModifier.OVERRIDE @@ -83,11 +80,6 @@ internal class ComponentGenerator( PropertySpec.builder("deepLinkHandlers", immutableSet.parameterizedBy(deepLinkHandler)).build(), PropertySpec.builder("deepLinkPrefixes", immutableSet.parameterizedBy(deepLinkPrefix)).build(), ) - if (data.experimentalNavigation) { - properties += PropertySpec.builder("useExperimentalNavigation", BOOLEAN) - .addAnnotation(AnnotationSpec.builder(UseExperimentalNavigation::class).useSiteTarget(GET).build()) - .build() - } } properties += PropertySpec.builder(closeableSetPropertyName, SET.parameterizedBy(Closeable::class.asTypeName())) .addAnnotation(forScope(data.scope, GET)) diff --git a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/AnvilParser.kt b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/AnvilParser.kt index 3eaf1c2aa..d4eb2ba6a 100644 --- a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/AnvilParser.kt +++ b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/AnvilParser.kt @@ -92,7 +92,6 @@ internal fun TopLevelFunctionReference.toNavHostActivityData(annotation: Annotat parentScope = annotation.parentScope, stateMachine = stateMachine.asClassName(), activityBaseClass = annotation.activityBaseClass, - experimentalNavigation = annotation.experimentalNavigation, navHostParameter = navHostParameter, composableParameter = getInjectedParameters(stateParameter, actionParameter, navHostParameter.typeName), stateParameter = getParameterWithType(stateParameter), @@ -124,9 +123,6 @@ private val AnnotationReference.destinationScope: ClassName private val AnnotationReference.activityBaseClass: ClassName get() = requireClassReferenceArgument("activityBaseClass", 3).asClassName() -internal val AnnotationReference.experimentalNavigation: Boolean - get() = argumentAt("experimentalNavigation", 4)?.value() ?: false - private fun TopLevelFunctionReference.getParameterWithType(expectedType: TypeName): ComposableParameter? { return parameters.firstNotNullOfOrNull { parameter -> parameter.toComposableParameter { it == expectedType } diff --git a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/KspParser.kt b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/KspParser.kt index 82893bd2f..4c911b872 100644 --- a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/KspParser.kt +++ b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/parser/KspParser.kt @@ -75,7 +75,6 @@ internal fun KSFunctionDeclaration.toNavHostActivityData( parentScope = annotation.parentScope, stateMachine = annotation.stateMachine, activityBaseClass = annotation.activityBaseClass, - experimentalNavigation = annotation.experimentalNavigation, navHostParameter = navHostParameter, composableParameter = getInjectedParameters(stateParameter, actionParameter, navHostParameter.typeName), stateParameter = getParameterWithType(stateParameter), @@ -101,9 +100,6 @@ private val KSAnnotation.destinationScope: ClassName private val KSAnnotation.activityBaseClass: ClassName get() = (findArgument("activityBaseClass").value as KSType).toClassName() -internal val KSAnnotation.experimentalNavigation: Boolean - get() = findArgument("experimentalNavigation").value as Boolean - private fun KSAnnotation.findArgument(name: String): KSValueArgument { return arguments.find { it.name?.asString() == name } ?: defaultArguments.find { it.name?.asString() == name }!! diff --git a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/util/External.kt b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/util/External.kt index 3cab4dd8f..8306b71b1 100644 --- a/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/util/External.kt +++ b/codegen-compiler/src/main/kotlin/com/freeletics/khonshu/codegen/util/External.kt @@ -34,10 +34,7 @@ internal val baseRoute = ClassName("com.freeletics.khonshu.navigation", "BaseRou internal val baseRouteFqName = FqName(baseRoute.canonicalName) internal val navEventNavigator = ClassName("com.freeletics.khonshu.navigation", "NavEventNavigator") internal val navigationExecutor = ClassName("com.freeletics.khonshu.navigation.internal", "NavigationExecutor") -internal val androidxNavHost = MemberName("com.freeletics.khonshu.navigation.androidx", "NavHost") -internal val navHostTransitionAnimations = - ClassName("com.freeletics.khonshu.navigation.androidx", "NavHostTransitionAnimations") -internal val experimentalNavHost = MemberName("com.freeletics.khonshu.navigation", "NavHost") +internal val navHost = MemberName("com.freeletics.khonshu.navigation", "NavHost") internal val navigationSetup = MemberName("com.freeletics.khonshu.navigation", "NavigationSetup") internal val navigationDestination = ClassName("com.freeletics.khonshu.navigation", "NavDestination") internal val screenDestination = MemberName("com.freeletics.khonshu.navigation", "ScreenDestination") diff --git a/codegen/api/android/codegen.api b/codegen/api/android/codegen.api index e4d5ad8d2..a062a6ec1 100644 --- a/codegen/api/android/codegen.api +++ b/codegen/api/android/codegen.api @@ -13,7 +13,6 @@ public abstract interface annotation class com/freeletics/khonshu/codegen/NavDes public abstract interface annotation class com/freeletics/khonshu/codegen/NavHostActivity : java/lang/annotation/Annotation { public abstract fun activityBaseClass ()Ljava/lang/Class; - public abstract fun experimentalNavigation ()Z public abstract fun parentScope ()Ljava/lang/Class; public abstract fun scope ()Ljava/lang/Class; public abstract fun stateMachine ()Ljava/lang/Class; @@ -22,9 +21,6 @@ public abstract interface annotation class com/freeletics/khonshu/codegen/NavHos public abstract interface class com/freeletics/khonshu/codegen/Overlay { } -public abstract interface annotation class com/freeletics/khonshu/codegen/UseExperimentalNavigation : java/lang/annotation/Annotation { -} - public final class com/freeletics/khonshu/codegen/internal/ActivityComponentLookupKt { public static final fun findComponentByScope (Landroid/content/Context;Lkotlin/reflect/KClass;)Ljava/lang/Object; } diff --git a/codegen/api/jvm/codegen.api b/codegen/api/jvm/codegen.api index 518da285d..65d98d56e 100644 --- a/codegen/api/jvm/codegen.api +++ b/codegen/api/jvm/codegen.api @@ -13,7 +13,6 @@ public abstract interface annotation class com/freeletics/khonshu/codegen/NavDes public abstract interface annotation class com/freeletics/khonshu/codegen/NavHostActivity : java/lang/annotation/Annotation { public abstract fun activityBaseClass ()Ljava/lang/Class; - public abstract fun experimentalNavigation ()Z public abstract fun parentScope ()Ljava/lang/Class; public abstract fun scope ()Ljava/lang/Class; public abstract fun stateMachine ()Ljava/lang/Class; @@ -22,9 +21,6 @@ public abstract interface annotation class com/freeletics/khonshu/codegen/NavHos public abstract interface class com/freeletics/khonshu/codegen/Overlay { } -public abstract interface annotation class com/freeletics/khonshu/codegen/UseExperimentalNavigation : java/lang/annotation/Annotation { -} - public abstract interface annotation class com/freeletics/khonshu/codegen/internal/InternalCodegenApi : java/lang/annotation/Annotation { } diff --git a/codegen/src/commonMain/kotlin/com/freeletics/khonshu/codegen/NavHostActivity.kt b/codegen/src/commonMain/kotlin/com/freeletics/khonshu/codegen/NavHostActivity.kt index 8ddf4e003..3ee979d2b 100644 --- a/codegen/src/commonMain/kotlin/com/freeletics/khonshu/codegen/NavHostActivity.kt +++ b/codegen/src/commonMain/kotlin/com/freeletics/khonshu/codegen/NavHostActivity.kt @@ -25,7 +25,6 @@ public annotation class NavHostActivity( val parentScope: KClass<*> = AppScope::class, val stateMachine: KClass>, val activityBaseClass: KClass<*>, - val experimentalNavigation: Boolean = false, ) /** diff --git a/codegen/src/commonMain/kotlin/com/freeletics/khonshu/codegen/UseExperimentalNavigation.kt b/codegen/src/commonMain/kotlin/com/freeletics/khonshu/codegen/UseExperimentalNavigation.kt deleted file mode 100644 index e83febad1..000000000 --- a/codegen/src/commonMain/kotlin/com/freeletics/khonshu/codegen/UseExperimentalNavigation.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.freeletics.khonshu.codegen - -import javax.inject.Qualifier - -/** - * Qualifier used to provide a boolean that indicated whether experimental navigation should be - * enabled or not. Only considered if [NavHostActivity.experimentalNavigation] is `true`. - */ -@Qualifier -@Retention(AnnotationRetention.RUNTIME) -public annotation class UseExperimentalNavigation diff --git a/sample/simple/feature/main/src/main/kotlin/com/freeletics/khonshu/sample/feature/main/MainModule.kt b/sample/simple/feature/main/src/main/kotlin/com/freeletics/khonshu/sample/feature/main/MainModule.kt deleted file mode 100644 index 0dfd9037f..000000000 --- a/sample/simple/feature/main/src/main/kotlin/com/freeletics/khonshu/sample/feature/main/MainModule.kt +++ /dev/null @@ -1,15 +0,0 @@ -package com.freeletics.khonshu.sample.feature.main - -import com.freeletics.khonshu.codegen.ActivityScope -import com.freeletics.khonshu.codegen.UseExperimentalNavigation -import com.squareup.anvil.annotations.ContributesTo -import dagger.Module -import dagger.Provides - -@Module -@ContributesTo(ActivityScope::class) -object MainModule { - @Provides - @UseExperimentalNavigation - fun provideUseExperimentalNavigation(): Boolean = true -} diff --git a/sample/simple/feature/main/src/main/kotlin/com/freeletics/khonshu/sample/feature/main/MainScreen.kt b/sample/simple/feature/main/src/main/kotlin/com/freeletics/khonshu/sample/feature/main/MainScreen.kt index 0536b215a..d2d64682c 100644 --- a/sample/simple/feature/main/src/main/kotlin/com/freeletics/khonshu/sample/feature/main/MainScreen.kt +++ b/sample/simple/feature/main/src/main/kotlin/com/freeletics/khonshu/sample/feature/main/MainScreen.kt @@ -11,7 +11,6 @@ import com.freeletics.khonshu.sample.feature.root.nav.RootRoute @NavHostActivity( stateMachine = MainStateMachine::class, activityBaseClass = ComponentActivity::class, - experimentalNavigation = true, ) @Composable internal fun MainScreen(