Skip to content

Commit

Permalink
rename DestinationComponent (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielittner authored Jun 28, 2023
1 parent 200be7d commit 3fd781e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,8 @@ internal class FileGeneratorTestCompose {
import com.freeletics.mad.navigator.compose.ScreenDestination
import com.freeletics.mad.whetstone.NavEntry
import com.freeletics.mad.whetstone.ScopeTo
import com.freeletics.mad.whetstone.`internal`.DestinationComponent
import com.freeletics.mad.whetstone.`internal`.InternalWhetstoneApi
import com.freeletics.mad.whetstone.`internal`.NavDestinationComponent
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetter
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetterKey
import com.freeletics.mad.whetstone.`internal`.asComposeState
Expand Down Expand Up @@ -513,7 +513,7 @@ internal class FileGeneratorTestCompose {
@ContributesTo(TestDestinationScope::class)
@OptIn(InternalWhetstoneApi::class)
public interface WhetstoneTestScreenNavEntryDestinationComponent : DestinationComponent
public interface WhetstoneTestScreenNavEntryNavDestinationComponent : NavDestinationComponent
""".trimIndent()

Expand Down Expand Up @@ -574,8 +574,8 @@ internal class FileGeneratorTestCompose {
import com.freeletics.mad.whetstone.AppScope
import com.freeletics.mad.whetstone.NavEntry
import com.freeletics.mad.whetstone.ScopeTo
import com.freeletics.mad.whetstone.`internal`.DestinationComponent
import com.freeletics.mad.whetstone.`internal`.InternalWhetstoneApi
import com.freeletics.mad.whetstone.`internal`.NavDestinationComponent
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetter
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetterKey
import com.freeletics.mad.whetstone.`internal`.asComposeState
Expand Down Expand Up @@ -728,7 +728,7 @@ internal class FileGeneratorTestCompose {
@ContributesTo(AppScope::class)
@OptIn(InternalWhetstoneApi::class)
public interface WhetstoneTestScreenNavEntryDestinationComponent : DestinationComponent
public interface WhetstoneTestScreenNavEntryNavDestinationComponent : NavDestinationComponent
""".trimIndent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ internal class FileGeneratorTestComposeFragment {
import com.freeletics.mad.navigator.fragment.requireRoute
import com.freeletics.mad.whetstone.NavEntry
import com.freeletics.mad.whetstone.ScopeTo
import com.freeletics.mad.whetstone.`internal`.DestinationComponent
import com.freeletics.mad.whetstone.`internal`.InternalWhetstoneApi
import com.freeletics.mad.whetstone.`internal`.NavDestinationComponent
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetter
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetterKey
import com.freeletics.mad.whetstone.`internal`.asComposeState
Expand Down Expand Up @@ -585,7 +585,7 @@ internal class FileGeneratorTestComposeFragment {
@ContributesTo(TestDestinationScope::class)
@OptIn(InternalWhetstoneApi::class)
public interface WhetstoneTestScreenNavEntryDestinationComponent : DestinationComponent
public interface WhetstoneTestScreenNavEntryNavDestinationComponent : NavDestinationComponent
""".trimIndent()

Expand Down Expand Up @@ -654,8 +654,8 @@ internal class FileGeneratorTestComposeFragment {
import com.freeletics.mad.whetstone.AppScope
import com.freeletics.mad.whetstone.NavEntry
import com.freeletics.mad.whetstone.ScopeTo
import com.freeletics.mad.whetstone.`internal`.DestinationComponent
import com.freeletics.mad.whetstone.`internal`.InternalWhetstoneApi
import com.freeletics.mad.whetstone.`internal`.NavDestinationComponent
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetter
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetterKey
import com.freeletics.mad.whetstone.`internal`.asComposeState
Expand Down Expand Up @@ -825,7 +825,7 @@ internal class FileGeneratorTestComposeFragment {
@ContributesTo(AppScope::class)
@OptIn(InternalWhetstoneApi::class)
public interface WhetstoneTestScreenNavEntryDestinationComponent : DestinationComponent
public interface WhetstoneTestScreenNavEntryNavDestinationComponent : NavDestinationComponent
""".trimIndent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ internal class FileGeneratorTestRendererFragment {
import com.freeletics.mad.navigator.fragment.requireRoute
import com.freeletics.mad.whetstone.NavEntry
import com.freeletics.mad.whetstone.ScopeTo
import com.freeletics.mad.whetstone.`internal`.DestinationComponent
import com.freeletics.mad.whetstone.`internal`.InternalWhetstoneApi
import com.freeletics.mad.whetstone.`internal`.NavDestinationComponent
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetter
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetterKey
import com.freeletics.mad.whetstone.`internal`.navEntryComponent
Expand Down Expand Up @@ -503,7 +503,7 @@ internal class FileGeneratorTestRendererFragment {
@ContributesTo(TestDestinationScope::class)
@OptIn(InternalWhetstoneApi::class)
public interface WhetstoneTestScreenNavEntryDestinationComponent : DestinationComponent
public interface WhetstoneTestScreenNavEntryNavDestinationComponent : NavDestinationComponent
""".trimIndent()

Expand Down Expand Up @@ -567,8 +567,8 @@ internal class FileGeneratorTestRendererFragment {
import com.freeletics.mad.whetstone.AppScope
import com.freeletics.mad.whetstone.NavEntry
import com.freeletics.mad.whetstone.ScopeTo
import com.freeletics.mad.whetstone.`internal`.DestinationComponent
import com.freeletics.mad.whetstone.`internal`.InternalWhetstoneApi
import com.freeletics.mad.whetstone.`internal`.NavDestinationComponent
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetter
import com.freeletics.mad.whetstone.`internal`.NavEntryComponentGetterKey
import com.freeletics.mad.whetstone.`internal`.navEntryComponent
Expand Down Expand Up @@ -720,7 +720,7 @@ internal class FileGeneratorTestRendererFragment {
@ContributesTo(AppScope::class)
@OptIn(InternalWhetstoneApi::class)
public interface WhetstoneTestScreenNavEntryDestinationComponent : DestinationComponent
public interface WhetstoneTestScreenNavEntryNavDestinationComponent : NavDestinationComponent
""".trimIndent()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.freeletics.mad.whetstone.codegen.common.ModuleGenerator
import com.freeletics.mad.whetstone.codegen.compose.ComposeScreenGenerator
import com.freeletics.mad.whetstone.codegen.fragment.ComposeFragmentGenerator
import com.freeletics.mad.whetstone.codegen.fragment.RendererFragmentGenerator
import com.freeletics.mad.whetstone.codegen.nav.DestinationComponentGenerator
import com.freeletics.mad.whetstone.codegen.nav.NavDestinationComponentGenerator
import com.freeletics.mad.whetstone.codegen.nav.NavDestinationModuleGenerator
import com.freeletics.mad.whetstone.codegen.nav.NavEntryComponentGetterGenerator
import com.squareup.kotlinpoet.FileSpec
Expand Down Expand Up @@ -85,7 +85,7 @@ public class FileGenerator {
val componentGenerator = ComponentGenerator(data)
val moduleGenerator = ModuleGenerator(data)
val componentGetterGenerator = NavEntryComponentGetterGenerator(data)
val destinationComponentGenerator = DestinationComponentGenerator(data)
val destinationComponentGenerator = NavDestinationComponentGenerator(data)

addType(componentGenerator.generate())
addType(moduleGenerator.generate())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import com.freeletics.mad.whetstone.codegen.util.destinationComponent
import com.freeletics.mad.whetstone.codegen.util.optInAnnotation
import com.squareup.kotlinpoet.TypeSpec

internal class DestinationComponentGenerator(
internal class NavDestinationComponentGenerator(
override val data: BaseData,
) : Generator<BaseData>() {

fun generate(): TypeSpec {
return TypeSpec.interfaceBuilder("Whetstone${data.baseName}DestinationComponent")
return TypeSpec.interfaceBuilder("Whetstone${data.baseName}NavDestinationComponent")
.addAnnotation(contributesToAnnotation(data.navigation!!.destinationScope))
.addAnnotation(optInAnnotation())
.addSuperinterface(destinationComponent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal val navEntryComponentGetterKey = ClassName(
"com.freeletics.mad.whetstone.internal",
"NavEntryComponentGetterKey",
)
internal val destinationComponent = ClassName("com.freeletics.mad.whetstone.internal", "DestinationComponent")
internal val destinationComponent = ClassName("com.freeletics.mad.whetstone.internal", "NavDestinationComponent")

// Navigator
internal val navEventNavigator = ClassName("com.freeletics.mad.navigator", "NavEventNavigator")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.freeletics.mad.whetstone.internal

@InternalWhetstoneApi
public interface DestinationComponent {
public interface NavDestinationComponent {
public val navEntryComponentGetters: @JvmSuppressWildcards Map<Class<*>, NavEntryComponentGetter>
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public fun <T : Any> Context.findComponentByScope(
executor: NavigationExecutor,
): T {
if (scope != destinationScope) {
val destinationComponent = find(destinationScope) as? DestinationComponent
val destinationComponent = find(destinationScope) as? NavDestinationComponent
val getter = destinationComponent?.navEntryComponentGetters?.get(scope.java)
if (getter != null) {
@Suppress("UNCHECKED_CAST")
Expand Down

0 comments on commit 3fd781e

Please sign in to comment.