Fix spotless

Change-Id: I7dcd7fa9544c873edeb8270f8d89b3bcb7211428
dt/nav-safe-args
Don Turner 2 months ago
parent 2d45b84031
commit 924391cd22

@ -97,7 +97,7 @@ class NiaAppState(
.currentBackStackEntryAsState().value?.destination
val currentTopLevelDestination: TopLevelDestination?
@Composable get(){
@Composable get() {
with(currentDestination) {
if (this?.hasRoute<ForYouDestination>() == true) return FOR_YOU
if (this?.hasRoute<BookmarksDestination>() == true) return BOOKMARKS

@ -41,17 +41,18 @@ import com.google.samples.apps.nowinandroid.feature.topic.navigation.topicScreen
import kotlinx.serialization.Serializable
@Serializable object TopicPlaceholderDestination
@Serializable object DetailPaneNavHostDestination
fun NavGraphBuilder.interestsListDetailScreen() {
composable<InterestsDestination>{
composable<InterestsDestination> {
InterestsListDetailScreen()
}
}
@Composable
internal fun InterestsListDetailScreen() {
var selectedTopicId : String? by rememberSaveable { mutableStateOf(null) }
var selectedTopicId: String? by rememberSaveable { mutableStateOf(null) }
InterestsListDetailScreen(
selectedTopicId = selectedTopicId,
onTopicClick = { topicId -> selectedTopicId = topicId },
@ -92,8 +93,8 @@ internal fun InterestsListDetailScreen(
NavHost(
navController = nestedNavController,
startDestination = TopicPlaceholderDestination::class,
route = DetailPaneNavHostDestination::class
){
route = DetailPaneNavHostDestination::class,
) {
topicScreen(
showBackButton = !listDetailNavigator.isListPaneVisible(),
onBackClick = listDetailNavigator::navigateBack,

@ -36,4 +36,3 @@ fun NavGraphBuilder.bookmarksScreen(
BookmarksRoute(onTopicClick, onShowSnackbar)
}
}

@ -27,6 +27,7 @@ import kotlinx.serialization.Serializable
const val LINKED_NEWS_RESOURCE_ID = "linkedNewsResourceId"
private const val DEEP_LINK_URI_PATTERN =
"https://www.nowinandroid.apps.samples.google.com/foryou/{$LINKED_NEWS_RESOURCE_ID}"
@Serializable data class ForYouDestination(val linkedNewsResourceId: String? = null)
fun NavController.navigateToForYou(navOptions: NavOptions) = navigate(route = ForYouDestination(), navOptions)
@ -35,7 +36,7 @@ fun NavGraphBuilder.forYouScreen(onTopicClick: (String) -> Unit) {
composable<ForYouDestination>(
deepLinks = listOf(
navDeepLink { uriPattern = DEEP_LINK_URI_PATTERN },
)
),
) {
ForYouRoute(onTopicClick)
}

@ -25,7 +25,6 @@ import com.google.samples.apps.nowinandroid.core.domain.GetFollowableTopicsUseCa
import com.google.samples.apps.nowinandroid.core.domain.TopicSortField
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.feature.interests.navigation.InterestsDestination
import com.google.samples.apps.nowinandroid.feature.interests.navigation.TOPIC_ID_ARG
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
@ -41,7 +40,7 @@ class InterestsViewModel @Inject constructor(
getFollowableTopics: GetFollowableTopicsUseCase,
) : ViewModel() {
private val interestsDestination : InterestsDestination = savedStateHandle.toRoute()
private val interestsDestination: InterestsDestination = savedStateHandle.toRoute()
val uiState: StateFlow<InterestsUiState> =
getFollowableTopics(sortBy = TopicSortField.NAME).map { topics ->

@ -20,11 +20,10 @@ import androidx.navigation.NavController
import androidx.navigation.NavOptions
import kotlinx.serialization.Serializable
const val TOPIC_ID_ARG = "topicId"
@Serializable data class InterestsDestination(val topicId: String?)
fun NavController.navigateToInterests(topicId: String? = null, navOptions: NavOptions? = null) {
navigate(route = InterestsDestination(topicId), navOptions)
}
}

@ -25,7 +25,6 @@ import com.google.samples.apps.nowinandroid.core.testing.repository.TestUserData
import com.google.samples.apps.nowinandroid.core.testing.util.MainDispatcherRule
import com.google.samples.apps.nowinandroid.feature.interests.InterestsUiState
import com.google.samples.apps.nowinandroid.feature.interests.InterestsViewModel
import com.google.samples.apps.nowinandroid.feature.interests.navigation.TOPIC_ID_ARG
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher
@ -55,7 +54,7 @@ class InterestsViewModelTest {
@Before
fun setup() {
viewModel = InterestsViewModel(
//TODO: Figure out how to supply the correct dependency: InterestsDestination(topicId = testInputTopics[0].topic.id)
// TODO: Figure out how to supply the correct dependency: InterestsDestination(topicId = testInputTopics[0].topic.id)
savedStateHandle = SavedStateHandle(mapOf("topicId" to testInputTopics[0].topic.id)),
userDataRepository = userDataRepository,
getFollowableTopics = getFollowableTopicsUseCase,

@ -48,7 +48,7 @@ class TopicViewModel @Inject constructor(
userNewsResourceRepository: UserNewsResourceRepository,
) : ViewModel() {
private val topicDestination : TopicDestination = savedStateHandle.toRoute()
private val topicDestination: TopicDestination = savedStateHandle.toRoute()
val topicId = topicDestination.id

@ -59,7 +59,7 @@ class TopicViewModelTest {
@Before
fun setup() {
viewModel = TopicViewModel(
//TODO: Figure out how to supply the correct dependency TopicDestination(id = testInputTopics[0].topic.id)
// TODO: Figure out how to supply the correct dependency TopicDestination(id = testInputTopics[0].topic.id)
savedStateHandle = SavedStateHandle(mapOf("id" to testInputTopics[0].topic.id)),
userDataRepository = userDataRepository,
topicsRepository = topicsRepository,

Loading…
Cancel
Save