Skip to content

Commit

Permalink
Fix format issues
Browse files Browse the repository at this point in the history
Change-Id: I5b87f89d824961cb9aec039281e784d6dec0716b
  • Loading branch information
thagikura committed Apr 11, 2023
1 parent 347e714 commit 16e8aad
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@ package com.google.samples.apps.nowinandroid.navigation

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.NavHostController
import androidx.navigation.compose.NavHost
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.forYouScreen
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.topic.navigation.navigateToTopic
import com.google.samples.apps.nowinandroid.feature.topic.navigation.topicScreen
Expand Down Expand Up @@ -56,7 +54,7 @@ fun NiaNavHost(
searchScreen(
onBackClick = navController::popBackStack,
onInterestsClick = { appState.navigateToTopLevelDestination(INTERESTS) },
onTopicClick = {}
onTopicClick = {},
)
interestsGraph(
onTopicClick = { topicId ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,4 @@ object PreviewParameterData {
userData = userData,
),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fun TopicsTabContent(
onTopicClick: (String) -> Unit,
onFollowButtonClick: (String, Boolean) -> Unit,
modifier: Modifier = Modifier,
withBottomSpacer: Boolean = true
withBottomSpacer: Boolean = true,
) {
LazyColumn(
modifier = modifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class SearchScreenTest {
fun emptySearchResult_emptyScreenIsDisplayed() {
composeTestRule.setContent {
SearchScreen(
uiState = SearchResultUiState.Success()
uiState = SearchResultUiState.Success(),
)
}

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/*
* Copyright 2023 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.samples.apps.nowinandroid.feature.search
Expand All @@ -28,4 +28,4 @@ sealed interface SearchResultUiState {
) : SearchResultUiState {
fun isEmpty(): Boolean = topics.isEmpty() && newsResources.isEmpty()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,17 @@ internal fun SearchRoute(
onInterestsClick = onInterestsClick,
onSearchQueryChanged = searchViewModel::onSearchQueryChanged,
onTopicClick = onTopicClick,
onNewsResourcesCheckedChanged = forYouViewModel::updateNewsResourceSaved
onNewsResourcesCheckedChanged = forYouViewModel::updateNewsResourceSaved,
)
}

@Composable
internal fun SearchScreen(
modifier: Modifier = Modifier,
onBackClick: () -> Unit = {},
onFollowButtonClick: (String, Boolean) -> Unit = {_, _ -> },
onFollowButtonClick: (String, Boolean) -> Unit = { _, _ -> },
onInterestsClick: () -> Unit = {},
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = {_, _ -> },
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = { _, _ -> },
onSearchQueryChanged: (String) -> Unit = {},
onTopicClick: (String) -> Unit = {},
uiState: SearchResultUiState = SearchResultUiState.Loading,
Expand Down Expand Up @@ -192,7 +192,6 @@ fun EmptySearchResultBody(
onInterestsClick()
}
}

}
}

Expand All @@ -201,8 +200,8 @@ private fun SearchResultBody(
topics: List<FollowableTopic>,
newsResources: List<UserNewsResource>,
onFollowButtonClick: (String, Boolean) -> Unit,
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = {_, _ -> },
onTopicClick: (String) -> Unit = {}
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = { _, _ -> },
onTopicClick: (String) -> Unit = {},
) {
if (topics.isNotEmpty()) {
Text(
Expand All @@ -217,7 +216,7 @@ private fun SearchResultBody(
topics = topics,
onTopicClick = onTopicClick,
onFollowButtonClick = onFollowButtonClick,
withBottomSpacer = false
withBottomSpacer = false,
)
}

Expand Down Expand Up @@ -246,7 +245,7 @@ private fun SearchResultBody(
newsFeed(
feedState = NewsFeedUiState.Success(feed = newsResources),
onNewsResourcesCheckedChanged = onNewsResourcesCheckedChanged,
onTopicClick = onTopicClick
onTopicClick = onTopicClick,
)
}
}
Expand Down Expand Up @@ -347,7 +346,7 @@ private fun EmptySearchResultColumnPreview() {
@DevicePreviews
@Composable
private fun SearchScreenPreview(
@PreviewParameter(SearchResultUiStatePreviewParameterProvider::class)
@PreviewParameter(SearchUiStatePreviewParameterProvider::class)
searchResultUiState: SearchResultUiState,
) {
NiaTheme {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
* provides list of [SearchResultUiState] for Composable previews.
*/
class SearchResultUiStatePreviewParameterProvider : PreviewParameterProvider<SearchResultUiState> {
override val values: Sequence<SearchResultUiState> = sequenceOf(SearchResultUiState.Success(
topics = topics.mapIndexed { i, topic ->
FollowableTopic(topic = topic, isFollowed = i % 2 == 0)
},
newsResources = newsResources,
))
}
class SearchUiStatePreviewParameterProvider : PreviewParameterProvider<SearchResultUiState> {
override val values: Sequence<SearchResultUiState> = sequenceOf(
SearchResultUiState.Success(
topics = topics.mapIndexed { i, topic ->
FollowableTopic(topic = topic, isFollowed = i % 2 == 0)
},
newsResources = newsResources,
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ fun NavController.navigateToSearch(navOptions: NavOptions? = null) {
fun NavGraphBuilder.searchScreen(
onBackClick: () -> Unit,
onInterestsClick: () -> Unit,
onTopicClick: (String) -> Unit = {}
onTopicClick: (String) -> Unit = {},
) {
// TODO: Handle back stack for each top-level destination. At the moment each top-level
// destination may have own search screen's back stack.
composable(route = searchRoute) {
SearchRoute(
onBackClick = onBackClick,
onInterestsClick = onInterestsClick,
onTopicClick = onTopicClick
onTopicClick = onTopicClick,
)
}
}

0 comments on commit 16e8aad

Please sign in to comment.