diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/commons/RawNavGraphTreeBuilder.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/commons/RawNavGraphTreeBuilder.kt index d94cd99b..2bfe7977 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/commons/RawNavGraphTreeBuilder.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/commons/RawNavGraphTreeBuilder.kt @@ -125,7 +125,7 @@ private fun RawNavGraphTree.addStartRouteTreeToParticipantsOfPublicAPIs() { if (startDestination != null || startNestedGraph != null) { throw IllegalDestinationsSetup( "${annotationType.preferredSimpleName} defines external route with `start = true` but " + - "'${(startDestination?.composableName ?: startNestedGraph?.annotationType?.preferredSimpleName)}' is also defined " + + "'${(startDestination?.annotatedName ?: startNestedGraph?.annotationType?.preferredSimpleName)}' is also defined " + "as its start. Use external annotations with `start = true` only when start route is not in the current module!" ) } diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/DestinationGeneratingParams.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/DestinationGeneratingParams.kt index 8e8c786e..893421d7 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/DestinationGeneratingParams.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/DestinationGeneratingParams.kt @@ -1,10 +1,15 @@ package com.ramcosta.composedestinations.codegen.model +import com.ramcosta.composedestinations.codegen.commons.GENERATED_DESTINATION_SUFFIX +import com.ramcosta.composedestinations.codegen.commons.toSnakeCase +import com.ramcosta.composedestinations.codegen.commons.toValidClassName +import com.ramcosta.composedestinations.codegen.moduleName + interface DestinationGeneratingParams { val sourceIds: List val name: String - val composableName: String - val composableQualifiedName: String + val annotatedName: String + val annotatedQualifiedName: String val visibility: Visibility val baseRoute: String val parameters: List @@ -21,11 +26,9 @@ interface DestinationGeneratingParams { data class RawDestinationGenParams( override val sourceIds: List, - override val name: String, - override val composableName: String, - override val composableQualifiedName: String, + override val annotatedName: String, + override val annotatedQualifiedName: String, override val visibility: Visibility, - override val baseRoute: String, override val parameters: List, override val deepLinks: List, override val navGraphInfo: NavGraphInfo?, @@ -36,4 +39,37 @@ data class RawDestinationGenParams( override val activityDestinationParams: ActivityDestinationParams? = null, override val composableWrappers: List, override val isParentStart: Boolean, -): DestinationGeneratingParams \ No newline at end of file + private val hasMultipleDestinations: Boolean, + private val routeOverride: String?, +) : DestinationGeneratingParams { + + private val destinationNames: DestinationNames by lazy { + if (routeOverride != null) { + return@lazy DestinationNames( + route = routeOverride, + destination = routeOverride.toValidClassName() + GENERATED_DESTINATION_SUFFIX + ) + } + + val moduleNamePrefix = moduleName.takeIf { it.isNotBlank() }?.let { "${it.toSnakeCase()}/" } ?: "" + val routeWithNoModule = if (hasMultipleDestinations) { + val navGraphName = navGraphInfo?.graphType?.simpleName + ?.removeSuffix("NavGraph") + ?.removeSuffix("Graph") + .orEmpty() + "${navGraphName.toSnakeCase()}/${annotatedName.toSnakeCase()}" + } else { + annotatedName.toSnakeCase() + } + + DestinationNames( + route = "$moduleNamePrefix$routeWithNoModule", + destination = routeWithNoModule.toValidClassName() + GENERATED_DESTINATION_SUFFIX + ) + } + + override val name: String get() = destinationNames.destination + override val baseRoute: String get() = destinationNames.route + + private class DestinationNames(val route: String, val destination: String) +} \ No newline at end of file diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/NavGraphGenParams.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/NavGraphGenParams.kt index e72a608f..172ab398 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/NavGraphGenParams.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/model/NavGraphGenParams.kt @@ -1,6 +1,8 @@ package com.ramcosta.composedestinations.codegen.model import com.ramcosta.composedestinations.codegen.commons.toSnakeCase +import com.ramcosta.composedestinations.codegen.moduleName +import java.util.Locale interface NavGraphGenParams { val sourceIds: List @@ -31,7 +33,7 @@ data class RawNavGraphGenParams( override val isParentStart: Boolean? = null, override val visibility: Visibility, override val externalRoutes: List, - private val routeOverride: String? = null, + private val routeOverride: String? = null ) : NavGraphGenParams { override val externalNavGraphs: List = externalRoutes.filterIsInstance() @@ -49,9 +51,14 @@ data class RawNavGraphGenParams( } override val baseRoute: String by lazy(LazyThreadSafetyMode.NONE) { - routeOverride ?: name + routeOverride ?: nameWithModuleName() .replace("(?i)navgraph".toRegex(), "") .replace("(?i)graph".toRegex(), "") .toSnakeCase() } + + private fun nameWithModuleName(): String { + val moduleNamePrefix = moduleName.takeIf { it.isNotBlank() }?.let { "${it.toSnakeCase()}/" } ?: "" + return "$moduleNamePrefix${name.replaceFirstChar { it.lowercase(Locale.US) }}" + } } diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/validators/InitialValidator.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/validators/InitialValidator.kt index 5e99ce8b..22cb4051 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/validators/InitialValidator.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/validators/InitialValidator.kt @@ -102,13 +102,13 @@ internal class InitialValidator( return if (navArgsDelegateTypeLocal == null) { parameters.filter { it.isNavArg() } } else { - navArgsDelegateTypeLocal.validateNavArgs("Composable '${composableName}': ") + navArgsDelegateTypeLocal.validateNavArgs("Composable '${annotatedName}': ") val navArgInFuncParams = parameters.firstOrNull { it.isNavArg() && it.type.value.importable != navArgsDelegateTypeLocal.type } if (navArgInFuncParams != null) { throw IllegalDestinationsSetup( - "Composable '${composableName}': annotated " + + "Composable '${annotatedName}': annotated " + "function cannot define arguments of navigation type if using a '$DESTINATION_ANNOTATION_NAV_ARGS_DELEGATE_ARGUMENT' class. (check argument '${navArgInFuncParams.name})'" ) } @@ -145,7 +145,7 @@ internal class InitialValidator( if (!codeGenConfig.generateNavGraphs) { Logger.instance.warn( - "'${composableName}' composable: is annotated with a `NavGraph` annotation, but it will be ignored." + + "'${annotatedName}' composable: is annotated with a `NavGraph` annotation, but it will be ignored." + "Reason: nav graphs generation was disabled by ksp gradle configuration." ) } @@ -155,7 +155,7 @@ internal class InitialValidator( if (composableReceiverType?.importable?.qualifiedName == ANIMATED_VISIBILITY_SCOPE_QUALIFIED_NAME) { if (destinationStyleType !is DestinationStyleType.Animated && destinationStyleType !is DestinationStyleType.Default) { throw IllegalDestinationsSetup( - "'${composableName}' composable: " + + "'${annotatedName}' composable: " + "Only destinations with a DestinationStyle.Animated or DestinationStyle.Default style may have a $ANIMATED_VISIBILITY_SCOPE_SIMPLE_NAME receiver!" ) } @@ -166,14 +166,14 @@ internal class InitialValidator( if (composableReceiverType?.importable?.qualifiedName == COLUMN_SCOPE_QUALIFIED_NAME) { if (!isBottomSheetDependencyPresent) { throw MissingRequiredDependency( - "'${composableName}' composable: " + + "'${annotatedName}' composable: " + "You need to include $BOTTOM_SHEET_DEPENDENCY dependency to use a $COLUMN_SCOPE_SIMPLE_NAME receiver!" ) } if (destinationStyleType !is DestinationStyleType.BottomSheet) { throw IllegalDestinationsSetup( - "'${composableName}' composable: " + + "'${annotatedName}' composable: " + "Only destinations with a DestinationStyleBottomSheet style may have a $COLUMN_SCOPE_SIMPLE_NAME receiver!" ) } @@ -189,7 +189,7 @@ internal class InitialValidator( } if (navGraphRoutes.contains(baseRoute)) { - throw IllegalDestinationsSetup("There is a NavGraph with same base route as destination '$composableName'") + throw IllegalDestinationsSetup("There is a NavGraph with same base route as destination '$annotatedName'") } } @@ -203,7 +203,7 @@ internal class InitialValidator( val destinationResultOriginForAllResultTypes = mutableSetOf() resultRecipientParams.forEach { parameter -> - Logger.instance.info("validateClosedResultRecipients | checking param $composableName ${parameter.name}") + Logger.instance.info("validateClosedResultRecipients | checking param $annotatedName ${parameter.name}") val resultType = (parameter.type.typeArguments[1] as? TypeArgument.Typed)?.type ?: throw IllegalDestinationsSetup( @@ -222,7 +222,7 @@ internal class InitialValidator( if (info == null || info.resultTypeQualifiedName != resultType.importable.qualifiedName || info.isResultTypeNullable != resultType.isNullable) { throw IllegalDestinationsSetup( "Composable correspondent to '${resultOriginQualifiedName}' must receive a 'ResultBackNavigator<${resultType.toTypeCode()}>'" + - " parameter in order to be used as result originator for '${composableName}'" + " parameter in order to be used as result originator for '${annotatedName}'" ) } @@ -235,22 +235,22 @@ internal class InitialValidator( val resultOriginDestinationParams = destinationsByName.value[resultOriginDestinationName] - ?: throw IllegalDestinationsSetup("Non existent Destination ('$resultOriginDestinationName') as the ResultRecipient's result origin (type aliases are not allowed here) for '$composableName'.") + ?: throw IllegalDestinationsSetup("Non existent Destination ('$resultOriginDestinationName') as the ResultRecipient's result origin (type aliases are not allowed here) for '$annotatedName'.") resultOriginDestinationParams.parameters.firstOrNull { it.type.importable.qualifiedName == RESULT_BACK_NAVIGATOR_QUALIFIED_NAME && (it.type.typeArguments.firstOrNull() as? TypeArgument.Typed)?.type == resultType } ?: throw IllegalDestinationsSetup( - "Composable '${resultOriginDestinationParams.composableName}' must receive a ResultBackNavigator" + - " of type '${resultType.toTypeCode()}' in order to be used as result originator for '${composableName}'" + "Composable '${resultOriginDestinationParams.annotatedName}' must receive a ResultBackNavigator" + + " of type '${resultType.toTypeCode()}' in order to be used as result originator for '${annotatedName}'" ) } } if (destinationResultOriginForAllResultTypes.size != resultRecipientParams.size) { throw IllegalDestinationsSetup( - "Composable '${composableName}': " + + "Composable '${annotatedName}': " + "has multiple ResultRecipients with the same Destination, only one recipient is allowed for a given destination!" ) } @@ -259,7 +259,7 @@ internal class InitialValidator( parameters.filter { it.type.importable.qualifiedName == RESULT_BACK_NAVIGATOR_QUALIFIED_NAME } if (resultBackNavigatorParams.size > 1) { throw IllegalDestinationsSetup( - "Composable '${composableName}': " + + "Composable '${annotatedName}': " + "Destination annotated Composables must have at most one ResultBackNavigator" ) } @@ -324,7 +324,7 @@ internal class InitialValidator( private fun DestinationGeneratingParams.validateResultType(resultType: TypeInfo) { if (resultType.typeArguments.isNotEmpty()) { - throw IllegalDestinationsSetup("Composable $composableName, ${resultType.toTypeCode()}: Result types cannot have type arguments!") + throw IllegalDestinationsSetup("Composable $annotatedName, ${resultType.toTypeCode()}: Result types cannot have type arguments!") } val primitives = listOf( @@ -336,7 +336,7 @@ internal class InitialValidator( ) if (resultType.importable.qualifiedName !in primitives && !resultType.isSerializable && !resultType.isParcelable) { throw IllegalDestinationsSetup( - "Composable $composableName, ${resultType.toTypeCode()}: " + + "Composable $annotatedName, ${resultType.toTypeCode()}: " + "Result types must be one of: ${ listOf( "String", @@ -355,7 +355,7 @@ internal class InitialValidator( private fun DestinationGeneratingParams.checkVisibilityToNavGraph() { if (navGraphInfo == null && visibility != Visibility.PUBLIC) { throw IllegalDestinationsSetup( - "$composableName has visibility $visibility but it's using 'ExternalModuleGraph'. In order for it to be included in an external module graph, it has to be public!" + "$annotatedName has visibility $visibility but it's using 'ExternalModuleGraph'. In order for it to be included in an external module graph, it has to be public!" ) } } diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt index 4a7abbd2..5ec59264 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/MermaidGraphWriter.kt @@ -193,7 +193,7 @@ internal class MermaidGraphWriter( private val ExternalRoute.Destination.mermaidVisualName get() = generatedType.simpleName.removeSuffix("Destination") private val CodeGenProcessedDestination.mermaidId get() = baseRoute.replace("graph", "g") - private val CodeGenProcessedDestination.mermaidVisualName get() = composableName + private val CodeGenProcessedDestination.mermaidVisualName get() = annotatedName private val NavGraphGenParams.mermaidId get() = baseRoute.replace("graph", "g") private val NavGraphGenParams.mermaidVisualName get() = annotationType.simpleName diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/SingleDestinationWriter.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/SingleDestinationWriter.kt index 4927f069..4905e7fc 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/SingleDestinationWriter.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/SingleDestinationWriter.kt @@ -59,16 +59,16 @@ internal class SingleDestinationWriter( importableHelper, navArgResolver, navArgs, - "Composable '${destination.composableName}'" + "Composable '${destination.annotatedName}'" ) init { if (destination.isParentStart && destination.navGraphInfo?.isNavHostGraph == true && destination.navArgs.any { it.isMandatory }) { - throw IllegalDestinationsSetup("\"'${destination.composableName}' composable: Start destinations of NavHostGraphs cannot have mandatory navigation arguments!") + throw IllegalDestinationsSetup("\"'${destination.annotatedName}' composable: Start destinations of NavHostGraphs cannot have mandatory navigation arguments!") } importableHelper.addAll(destinationTemplate.imports) - importableHelper.addPriorityQualifiedImport(destination.composableQualifiedName, destination.composableName) + importableHelper.addPriorityQualifiedImport(destination.annotatedQualifiedName, destination.annotatedName) } fun write() = with(destination) { @@ -81,7 +81,7 @@ internal class SingleDestinationWriter( importableHelper = importableHelper, sourceCode = destinationTemplate.sourceCode .replace(DESTINATION_NAME, name) - .replace(USER_COMPOSABLE_DESTINATION, composableName) + .replace(USER_COMPOSABLE_DESTINATION, annotatedName) .replaceSuperclassDestination() .addNavArgsDataClass() .replace(REQUIRE_OPT_IN_ANNOTATIONS_PLACEHOLDER, objectWideRequireOptInAnnotationsCode()) @@ -192,8 +192,8 @@ internal class SingleDestinationWriter( ) val activityClassImportable = Importable( - composableName, - composableQualifiedName + annotatedName, + annotatedQualifiedName ) return """override val targetPackage: String? = @targetPackage@ diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/DestinationContentFunctionWriter.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/DestinationContentFunctionWriter.kt index 7060b70f..ab35161d 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/DestinationContentFunctionWriter.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/DestinationContentFunctionWriter.kt @@ -78,7 +78,7 @@ class DestinationContentFunctionWriter( functionCallCode += wrappingPrefix() - val composableCall = "\t\t$receiverCode${composableName}($args)" + val composableCall = "\t\t$receiverCode${annotatedName}($args)" functionCallCode += if (composableWrappers.isEmpty()) composableCall else "\t" + composableCall.replace("\n", "\n\t") diff --git a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/NavGraphsPrettyKdocWriter.kt b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/NavGraphsPrettyKdocWriter.kt index cad5adf8..395e7918 100644 --- a/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/NavGraphsPrettyKdocWriter.kt +++ b/compose-destinations-codegen/src/main/java/com/ramcosta/composedestinations/codegen/writers/sub/NavGraphsPrettyKdocWriter.kt @@ -69,7 +69,7 @@ internal class NavGraphsPrettyKdocWriter( KdocRoute( false, it.isParentStart, - Importable(it.composableName, it.composableQualifiedName), + Importable(it.annotatedName, it.annotatedQualifiedName), true ) } + diff --git a/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/KspToCodeGenDestinationsMapper.kt b/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/KspToCodeGenDestinationsMapper.kt index fd2dc00c..65196ca2 100644 --- a/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/KspToCodeGenDestinationsMapper.kt +++ b/compose-destinations-ksp/src/main/kotlin/com/ramcosta/composedestinations/ksp/processors/KspToCodeGenDestinationsMapper.kt @@ -10,11 +10,8 @@ import com.ramcosta.composedestinations.codegen.commons.ACTIVITY_DESTINATION_ANN import com.ramcosta.composedestinations.codegen.commons.DESTINATION_ANNOTATION_DEEP_LINKS_ARGUMENT import com.ramcosta.composedestinations.codegen.commons.DESTINATION_ANNOTATION_DEFAULT_ROUTE_PLACEHOLDER import com.ramcosta.composedestinations.codegen.commons.DESTINATION_ANNOTATION_ROUTE_ARGUMENT -import com.ramcosta.composedestinations.codegen.commons.GENERATED_DESTINATION_SUFFIX import com.ramcosta.composedestinations.codegen.commons.IllegalDestinationsSetup import com.ramcosta.composedestinations.codegen.commons.JAVA_ACTIVITY_DESTINATION_ANNOTATION -import com.ramcosta.composedestinations.codegen.commons.toSnakeCase -import com.ramcosta.composedestinations.codegen.commons.toValidClassName import com.ramcosta.composedestinations.codegen.model.ActivityDestinationParams import com.ramcosta.composedestinations.codegen.model.DestinationStyleType import com.ramcosta.composedestinations.codegen.model.Importable @@ -64,8 +61,7 @@ internal class KspToCodeGenDestinationsMapper( val isStart = annotations.findOverridingArgumentValue { findArgumentValue("start") }!! val navGraphInfo = annotations.getNavGraphInfo("Composable '$composableName'") - val cleanRoute = annotations.findOverridingArgumentValue { prepareRoute(composableName, hasMultipleDestinations, navGraphInfo) }!! - val name = cleanRoute.toValidClassName() + GENERATED_DESTINATION_SUFFIX + val route = annotations.findOverridingArgumentValue { findArgumentValue(DESTINATION_ANNOTATION_ROUTE_ARGUMENT) }!! val navArgsDelegateTypeAndFile = annotations.findOverridingArgumentValue { getNavArgsDelegateType(resolver, navTypeSerializersByType) } if (navArgsDelegateTypeAndFile?.file != null) { @@ -75,12 +71,12 @@ internal class KspToCodeGenDestinationsMapper( return RawDestinationGenParams( sourceIds = listOfNotNull(function.containingFile!!.filePath, navArgsDelegateTypeAndFile?.file?.filePath), - name = name, isParentStart = isStart, - composableName = composableName, - composableQualifiedName = function.qualifiedName!!.asString(), + annotatedName = composableName, + annotatedQualifiedName = function.qualifiedName!!.asString(), visibility = annotations.findOverridingArgumentValue { getDestinationVisibility() }!!, - baseRoute = cleanRoute, + routeOverride = route.takeIf { it != DESTINATION_ANNOTATION_DEFAULT_ROUTE_PLACEHOLDER }, + hasMultipleDestinations = hasMultipleDestinations, destinationStyleType = annotations.findOverridingArgumentValue { destinationMappingUtils.getDestinationStyleType(this, "composable $composableName") }!!, parameters = function.parameters.map { it.toParameter(resolver, navTypeSerializersByType) }, composableWrappers = annotations.findCumulativeArgumentValue { destinationMappingUtils.getDestinationWrappers(this) }, @@ -126,13 +122,13 @@ internal class KspToCodeGenDestinationsMapper( val isStart = activityDestinationAnnotations.findOverridingArgumentValue { findArgumentValue("start") }!! + val route = activityDestinationAnnotations.findOverridingArgumentValue { findArgumentValue(DESTINATION_ANNOTATION_ROUTE_ARGUMENT) }!! + return RawDestinationGenParams( sourceIds = listOf(containingFile!!.filePath), - name = finalActivityClass.simpleName + GENERATED_DESTINATION_SUFFIX, - composableName = finalActivityClass.simpleName, - composableQualifiedName = finalActivityClass.qualifiedName, + annotatedName = finalActivityClass.simpleName, + annotatedQualifiedName = finalActivityClass.qualifiedName, visibility = activityDestinationAnnotations.findOverridingArgumentValue { getDestinationVisibility() }!!, - baseRoute = activityDestinationAnnotations.findOverridingArgumentValue { prepareRoute(finalActivityClass.simpleName) }!!, parameters = emptyList(), deepLinks = deepLinksAnnotations.map { it.toDeepLink() }, navGraphInfo = activityDestinationAnnotations.getNavGraphInfo("Activity '${simpleName.asString()}'"), @@ -148,6 +144,8 @@ internal class KspToCodeGenDestinationsMapper( ), composableWrappers = emptyList(), isParentStart = isStart, + routeOverride = route.takeIf { it != DESTINATION_ANNOTATION_DEFAULT_ROUTE_PLACEHOLDER }, + hasMultipleDestinations = false ) } @@ -209,27 +207,6 @@ internal class KspToCodeGenDestinationsMapper( return findArgumentValue("visibility")?.toGenVisibility() } - private fun KSAnnotation.prepareRoute( - composableName: String, - hasMultipleDestinations: Boolean = false, - navGraphInfo: NavGraphInfo? = null - ): String? { - val cleanRoute = findArgumentValue(DESTINATION_ANNOTATION_ROUTE_ARGUMENT) - return if (cleanRoute == DESTINATION_ANNOTATION_DEFAULT_ROUTE_PLACEHOLDER) { - if (hasMultipleDestinations) { - val navGraphName = navGraphInfo?.graphType?.simpleName - ?.removeSuffix("NavGraph") - ?.removeSuffix("Graph") - .orEmpty() - "${navGraphName.toSnakeCase()}/${composableName.toSnakeCase()}" - } else { - composableName.toSnakeCase() - } - } else { - cleanRoute - } - } - private val activityType by lazy { resolver.getClassDeclarationByName("android.app.Activity")!!.asType(emptyList()) } diff --git a/playground/docs/FeatureXNavGraph.mmd b/playground/docs/FeatureXNavGraph.mmd index be14379c..88811e43 100644 --- a/playground/docs/FeatureXNavGraph.mmd +++ b/playground/docs/FeatureXNavGraph.mmd @@ -1,13 +1,13 @@ --- -title: FeatureX Navigation Graph +title: FeatureX/featureX Navigation Graph --- %%{init: {'theme':'base', 'themeVariables': { 'primaryTextColor': '#fff' }}%% graph TD -feature_x(["FeatureXGraph"]) -- "start" --- feature_x_home("FeatureXHome") -feature_x(["FeatureXGraph"]) --- internal_args_screen("InternalArgsScreen") +feature_x/feature_x(["FeatureXGraph"]) -- "start" --- feature_x/feature_x_home("FeatureXHome") +feature_x/feature_x(["FeatureXGraph"]) --- feature_x/internal_args_screen("InternalArgsScreen") classDef destination fill:#5383EC,stroke:#ffffff; -class feature_x_home,internal_args_screen destination; +class feature_x/feature_x_home,feature_x/internal_args_screen destination; classDef navgraph fill:#63BC76,stroke:#ffffff; -class feature_x navgraph; +class feature_x/feature_x navgraph; diff --git a/playground/docs/FeatureYNavGraph.mmd b/playground/docs/FeatureYNavGraph.mmd index 243847ab..155d60f4 100644 --- a/playground/docs/FeatureYNavGraph.mmd +++ b/playground/docs/FeatureYNavGraph.mmd @@ -1,16 +1,16 @@ --- -title: FeatureY Navigation Graph +title: FeatureY/featureY Navigation Graph --- %%{init: {'theme':'base', 'themeVariables': { 'primaryTextColor': '#fff' }}%% graph TD -feature_y(["FeatureYGraph"]) -- "start" --- feature_y_home("FeatureYHome") -feature_y(["FeatureYGraph"]) --- feature_y_internal_args_screen("FeatureYInternalArgsScreen") -feature_y(["FeatureYGraph"]) --- sub_feature_y_public_side_screen_destination("SubFeatureYPublicSideScreen 🧩") -feature_y(["FeatureYGraph"]) --- sub_feature_y_nav_g(["SubFeatureYGraph 🧩"]) +feature_y/feature_y(["FeatureYGraph"]) -- "start" --- feature_y/feature_y_home("FeatureYHome") +feature_y/feature_y(["FeatureYGraph"]) --- feature_y/feature_y_internal_args_screen("FeatureYInternalArgsScreen") +feature_y/feature_y(["FeatureYGraph"]) --- sub_feature_y_public_side_screen_destination("SubFeatureYPublicSideScreen 🧩") +feature_y/feature_y(["FeatureYGraph"]) --- sub_feature_y_nav_g(["SubFeatureYGraph 🧩"]) click sub_feature_y_nav_g "SubFeatureYNavGraph.mmd" "See SubFeatureYGraph details" _blank classDef destination fill:#5383EC,stroke:#ffffff; -class feature_y_home,feature_y_internal_args_screen,sub_feature_y_public_side_screen_destination destination; +class feature_y/feature_y_home,feature_y/feature_y_internal_args_screen,sub_feature_y_public_side_screen_destination destination; classDef navgraph fill:#63BC76,stroke:#ffffff; -class feature_y,sub_feature_y_nav_g navgraph; +class feature_y/feature_y,sub_feature_y_nav_g navgraph; diff --git a/playground/docs/SubFeatureYNavGraph.mmd b/playground/docs/SubFeatureYNavGraph.mmd index 7114cddb..6912f87e 100644 --- a/playground/docs/SubFeatureYNavGraph.mmd +++ b/playground/docs/SubFeatureYNavGraph.mmd @@ -1,13 +1,13 @@ --- -title: SubFeatureY Navigation Graph +title: SubFeatureY/subFeatureY Navigation Graph --- %%{init: {'theme':'base', 'themeVariables': { 'primaryTextColor': '#fff' }}%% graph TD -sub_feature_y(["SubFeatureYGraph"]) -- "start" --- sub_feature_y_home("SubFeatureYHome") -sub_feature_y(["SubFeatureYGraph"]) --- sub_feature_y_internal_args_screen("SubFeatureYInternalArgsScreen") +sub_feature_y/sub_feature_y(["SubFeatureYGraph"]) -- "start" --- sub_feature_y/sub_feature_y_home("SubFeatureYHome") +sub_feature_y/sub_feature_y(["SubFeatureYGraph"]) --- sub_feature_y/sub_feature_y_internal_args_screen("SubFeatureYInternalArgsScreen") classDef destination fill:#5383EC,stroke:#ffffff; -class sub_feature_y_home,sub_feature_y_internal_args_screen destination; +class sub_feature_y/sub_feature_y_home,sub_feature_y/sub_feature_y_internal_args_screen destination; classDef navgraph fill:#63BC76,stroke:#ffffff; -class sub_feature_y navgraph; +class sub_feature_y/sub_feature_y navgraph;