A fully functional Android app built entirely with Kotlin and Jetpack Compose
Remove string-based argument name from navigation code
Don Turnerfc58680c06ab
diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.ktindex 0ffa3a473..67cc8884f 100644--- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.kt+++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/InterestsViewModel.kt@@ -25,7 +25,6 @@ import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCaimport com.google.samples.apps.nowinandroid.core.domain.TopicSortFieldimport com.google.samples.apps.nowinandroid.core.model.data.FollowableTopicimport com.google.samples.apps.nowinandroid.feature.interests.navigation.InterestsRoute-import com.google.samples.apps.nowinandroid.feature.interests.navigation.TOPIC_ID_KEYimport dagger.hilt.android.lifecycle.HiltViewModelimport kotlinx.coroutines.flow.SharingStartedimport kotlinx.coroutines.flow.StateFlow@@ -41,9 +40,12 @@ class InterestsViewModel @Inject constructor(getFollowableTopics: GetFollowableTopicsUseCase,) : ViewModel() {+ // Key used to save and retrieve the currently selected topic id from saved state.+ private val selectedTopicIdKey = "selectedTopicIdKey"+private val interestsRoute: InterestsRoute = savedStateHandle.toRoute()private val selectedTopicId = savedStateHandle.getStateFlow(- key = TOPIC_ID_KEY,+ key = selectedTopicIdKey,initialValue = interestsRoute.initialTopicId,)@@ -64,7 +66,7 @@ class InterestsViewModel @Inject constructor(}fun onTopicClick(topicId: String?) {- savedStateHandle[TOPIC_ID_KEY] = topicId+ savedStateHandle[selectedTopicIdKey] = topicId}}diff --git a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.kt b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.ktindex b0a85a5be..be06333b5 100644--- a/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.kt+++ b/feature/interests/src/main/kotlin/com/google/samples/apps/nowinandroid/feature/interests/navigation/InterestsNavigation.kt@@ -20,8 +20,6 @@ import androidx.navigation.NavControllerimport androidx.navigation.NavOptionsimport kotlinx.serialization.Serializable-const val TOPIC_ID_KEY = "topicId"-@Serializable data class InterestsRoute(// The ID of the topic which will be initially selected at this destinationval initialTopicId: String?,