Fix format issues

Change-Id: I5b87f89d824961cb9aec039281e784d6dec0716b
search_screen
Takeshi Hagikura 2 years ago
parent 13e6cc4f2b
commit 83b640a7f0

@ -18,13 +18,11 @@ package com.google.samples.apps.nowinandroid.navigation
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost import androidx.navigation.compose.NavHost
import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.bookmarksScreen import com.google.samples.apps.nowinandroid.feature.bookmarks.navigation.bookmarksScreen
import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouNavigationRoute import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouNavigationRoute
import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouScreen import com.google.samples.apps.nowinandroid.feature.foryou.navigation.forYouScreen
import com.google.samples.apps.nowinandroid.feature.interests.navigation.interestsGraph import com.google.samples.apps.nowinandroid.feature.interests.navigation.interestsGraph
import com.google.samples.apps.nowinandroid.feature.interests.navigation.navigateToInterestsGraph
import com.google.samples.apps.nowinandroid.feature.search.navigation.searchScreen import com.google.samples.apps.nowinandroid.feature.search.navigation.searchScreen
import com.google.samples.apps.nowinandroid.feature.topic.navigation.navigateToTopic import com.google.samples.apps.nowinandroid.feature.topic.navigation.navigateToTopic
import com.google.samples.apps.nowinandroid.feature.topic.navigation.topicScreen import com.google.samples.apps.nowinandroid.feature.topic.navigation.topicScreen
@ -56,7 +54,7 @@ fun NiaNavHost(
searchScreen( searchScreen(
onBackClick = navController::popBackStack, onBackClick = navController::popBackStack,
onInterestsClick = { appState.navigateToTopLevelDestination(INTERESTS) }, onInterestsClick = { appState.navigateToTopLevelDestination(INTERESTS) },
onTopicClick = {} onTopicClick = {},
) )
interestsGraph( interestsGraph(
onTopicClick = { topicId -> onTopicClick = { topicId ->

@ -35,7 +35,7 @@ fun TopicsTabContent(
onTopicClick: (String) -> Unit, onTopicClick: (String) -> Unit,
onFollowButtonClick: (String, Boolean) -> Unit, onFollowButtonClick: (String, Boolean) -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
withBottomSpacer: Boolean = true withBottomSpacer: Boolean = true,
) { ) {
LazyColumn( LazyColumn(
modifier = modifier modifier = modifier

@ -93,7 +93,7 @@ class SearchScreenTest {
fun emptySearchResult_emptyScreenIsDisplayed() { fun emptySearchResult_emptyScreenIsDisplayed() {
composeTestRule.setContent { composeTestRule.setContent {
SearchScreen( SearchScreen(
uiState = SearchResultUiState.Success() uiState = SearchResultUiState.Success(),
) )
} }
@ -135,11 +135,14 @@ class SearchScreenTest {
fun searchResultWithNewsResources_firstNewsResourcesIsVisible() { fun searchResultWithNewsResources_firstNewsResourcesIsVisible() {
composeTestRule.setContent { composeTestRule.setContent {
SearchScreen( SearchScreen(
uiState = SearchResultUiState.Success(newsResources = newsResourcesTestData.map { uiState = SearchResultUiState.Success(
newsResources = newsResourcesTestData.map {
UserNewsResource( UserNewsResource(
newsResource = it, newsResource = it,
userData = userData) userData = userData,
}), )
},
),
) )
} }

@ -95,7 +95,7 @@ internal fun SearchRoute(
onInterestsClick = onInterestsClick, onInterestsClick = onInterestsClick,
onSearchQueryChanged = searchViewModel::onSearchQueryChanged, onSearchQueryChanged = searchViewModel::onSearchQueryChanged,
onTopicClick = onTopicClick, onTopicClick = onTopicClick,
onNewsResourcesCheckedChanged = forYouViewModel::updateNewsResourceSaved onNewsResourcesCheckedChanged = forYouViewModel::updateNewsResourceSaved,
) )
} }
@ -192,7 +192,6 @@ fun EmptySearchResultBody(
onInterestsClick() onInterestsClick()
} }
} }
} }
} }
@ -202,7 +201,7 @@ private fun SearchResultBody(
newsResources: List<UserNewsResource>, newsResources: List<UserNewsResource>,
onFollowButtonClick: (String, Boolean) -> Unit, onFollowButtonClick: (String, Boolean) -> Unit,
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = { _, _ -> }, onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = { _, _ -> },
onTopicClick: (String) -> Unit = {} onTopicClick: (String) -> Unit = {},
) { ) {
if (topics.isNotEmpty()) { if (topics.isNotEmpty()) {
Text( Text(
@ -217,7 +216,7 @@ private fun SearchResultBody(
topics = topics, topics = topics,
onTopicClick = onTopicClick, onTopicClick = onTopicClick,
onFollowButtonClick = onFollowButtonClick, onFollowButtonClick = onFollowButtonClick,
withBottomSpacer = false withBottomSpacer = false,
) )
} }
@ -246,7 +245,7 @@ private fun SearchResultBody(
newsFeed( newsFeed(
feedState = NewsFeedUiState.Success(feed = newsResources), feedState = NewsFeedUiState.Success(feed = newsResources),
onNewsResourcesCheckedChanged = onNewsResourcesCheckedChanged, onNewsResourcesCheckedChanged = onNewsResourcesCheckedChanged,
onTopicClick = onTopicClick onTopicClick = onTopicClick,
) )
} }
} }
@ -347,7 +346,7 @@ private fun EmptySearchResultColumnPreview() {
@DevicePreviews @DevicePreviews
@Composable @Composable
private fun SearchScreenPreview( private fun SearchScreenPreview(
@PreviewParameter(SearchResultUiStatePreviewParameterProvider::class) @PreviewParameter(SearchUiStatePreviewParameterProvider::class)
searchResultUiState: SearchResultUiState, searchResultUiState: SearchResultUiState,
) { ) {
NiaTheme { NiaTheme {

@ -26,11 +26,13 @@ import com.google.samples.apps.nowinandroid.core.ui.PreviewParameterData.topics
* This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider) * This [PreviewParameterProvider](https://developer.android.com/reference/kotlin/androidx/compose/ui/tooling/preview/PreviewParameterProvider)
* provides list of [SearchResultUiState] for Composable previews. * provides list of [SearchResultUiState] for Composable previews.
*/ */
class SearchResultUiStatePreviewParameterProvider : PreviewParameterProvider<SearchResultUiState> { class SearchUiStatePreviewParameterProvider : PreviewParameterProvider<SearchResultUiState> {
override val values: Sequence<SearchResultUiState> = sequenceOf(SearchResultUiState.Success( override val values: Sequence<SearchResultUiState> = sequenceOf(
SearchResultUiState.Success(
topics = topics.mapIndexed { i, topic -> topics = topics.mapIndexed { i, topic ->
FollowableTopic(topic = topic, isFollowed = i % 2 == 0) FollowableTopic(topic = topic, isFollowed = i % 2 == 0)
}, },
newsResources = newsResources, newsResources = newsResources,
)) ),
)
} }

@ -31,7 +31,7 @@ fun NavController.navigateToSearch(navOptions: NavOptions? = null) {
fun NavGraphBuilder.searchScreen( fun NavGraphBuilder.searchScreen(
onBackClick: () -> Unit, onBackClick: () -> Unit,
onInterestsClick: () -> Unit, onInterestsClick: () -> Unit,
onTopicClick: (String) -> Unit = {} onTopicClick: (String) -> Unit = {},
) { ) {
// TODO: Handle back stack for each top-level destination. At the moment each top-level // TODO: Handle back stack for each top-level destination. At the moment each top-level
// destination may have own search screen's back stack. // destination may have own search screen's back stack.
@ -39,7 +39,7 @@ fun NavGraphBuilder.searchScreen(
SearchRoute( SearchRoute(
onBackClick = onBackClick, onBackClick = onBackClick,
onInterestsClick = onInterestsClick, onInterestsClick = onInterestsClick,
onTopicClick = onTopicClick onTopicClick = onTopicClick,
) )
} }
} }

Loading…
Cancel
Save