Merge pull request #1248 from yongsuk44/main

Apply Composable Parameter Ordering Guidelines
av/repro-8.3.0-dependency-resolution
Don Turner 9 months ago committed by GitHub
commit 171fa88ac0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -53,12 +53,12 @@ import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme
fun RowScope.NiaNavigationBarItem( fun RowScope.NiaNavigationBarItem(
selected: Boolean, selected: Boolean,
onClick: () -> Unit, onClick: () -> Unit,
icon: @Composable () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
selectedIcon: @Composable () -> Unit = icon,
enabled: Boolean = true, enabled: Boolean = true,
label: @Composable (() -> Unit)? = null,
alwaysShowLabel: Boolean = true, alwaysShowLabel: Boolean = true,
icon: @Composable () -> Unit,
selectedIcon: @Composable () -> Unit = icon,
label: @Composable (() -> Unit)? = null,
) { ) {
NavigationBarItem( NavigationBarItem(
selected = selected, selected = selected,
@ -117,12 +117,12 @@ fun NiaNavigationBar(
fun NiaNavigationRailItem( fun NiaNavigationRailItem(
selected: Boolean, selected: Boolean,
onClick: () -> Unit, onClick: () -> Unit,
icon: @Composable () -> Unit,
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
selectedIcon: @Composable () -> Unit = icon,
enabled: Boolean = true, enabled: Boolean = true,
label: @Composable (() -> Unit)? = null,
alwaysShowLabel: Boolean = true, alwaysShowLabel: Boolean = true,
icon: @Composable () -> Unit,
selectedIcon: @Composable () -> Unit = icon,
label: @Composable (() -> Unit)? = null,
) { ) {
NavigationRailItem( NavigationRailItem(
selected = selected, selected = selected,

@ -75,10 +75,10 @@ private const val SCROLLBAR_INACTIVE_TO_DORMANT_TIME_IN_MS = 2_000L
*/ */
@Composable @Composable
fun ScrollableState.DraggableScrollbar( fun ScrollableState.DraggableScrollbar(
modifier: Modifier = Modifier,
state: ScrollbarState, state: ScrollbarState,
orientation: Orientation, orientation: Orientation,
onThumbMoved: (Float) -> Unit, onThumbMoved: (Float) -> Unit,
modifier: Modifier = Modifier,
) { ) {
val interactionSource = remember { MutableInteractionSource() } val interactionSource = remember { MutableInteractionSource() }
Scrollbar( Scrollbar(
@ -105,9 +105,9 @@ fun ScrollableState.DraggableScrollbar(
*/ */
@Composable @Composable
fun ScrollableState.DecorativeScrollbar( fun ScrollableState.DecorativeScrollbar(
modifier: Modifier = Modifier,
state: ScrollbarState, state: ScrollbarState,
orientation: Orientation, orientation: Orientation,
modifier: Modifier = Modifier,
) { ) {
val interactionSource = remember { MutableInteractionSource() } val interactionSource = remember { MutableInteractionSource() }
Scrollbar( Scrollbar(

@ -195,13 +195,13 @@ internal fun Orientation.valueOf(intOffset: IntOffset) = when (this) {
*/ */
@Composable @Composable
fun Scrollbar( fun Scrollbar(
modifier: Modifier = Modifier,
orientation: Orientation, orientation: Orientation,
state: ScrollbarState, state: ScrollbarState,
minThumbSize: Dp = 40.dp, modifier: Modifier = Modifier,
interactionSource: MutableInteractionSource? = null, interactionSource: MutableInteractionSource? = null,
thumb: @Composable () -> Unit, minThumbSize: Dp = 40.dp,
onThumbMoved: ((Float) -> Unit)? = null, onThumbMoved: ((Float) -> Unit)? = null,
thumb: @Composable () -> Unit,
) { ) {
// Using Offset.Unspecified and Float.NaN instead of null // Using Offset.Unspecified and Float.NaN instead of null
// to prevent unnecessary boxing of primitives // to prevent unnecessary boxing of primitives

@ -100,10 +100,10 @@ import com.google.samples.apps.nowinandroid.feature.search.R as searchR
@Composable @Composable
internal fun SearchRoute( internal fun SearchRoute(
modifier: Modifier = Modifier,
onBackClick: () -> Unit, onBackClick: () -> Unit,
onInterestsClick: () -> Unit, onInterestsClick: () -> Unit,
onTopicClick: (String) -> Unit, onTopicClick: (String) -> Unit,
modifier: Modifier = Modifier,
bookmarksViewModel: BookmarksViewModel = hiltViewModel(), bookmarksViewModel: BookmarksViewModel = hiltViewModel(),
interestsViewModel: InterestsViewModel = hiltViewModel(), interestsViewModel: InterestsViewModel = hiltViewModel(),
searchViewModel: SearchViewModel = hiltViewModel(), searchViewModel: SearchViewModel = hiltViewModel(),
@ -114,36 +114,36 @@ internal fun SearchRoute(
val searchQuery by searchViewModel.searchQuery.collectAsStateWithLifecycle() val searchQuery by searchViewModel.searchQuery.collectAsStateWithLifecycle()
SearchScreen( SearchScreen(
modifier = modifier, modifier = modifier,
onBackClick = onBackClick, searchQuery = searchQuery,
onClearRecentSearches = searchViewModel::clearRecentSearches, recentSearchesUiState = recentSearchQueriesUiState,
onFollowButtonClick = interestsViewModel::followTopic, searchResultUiState = searchResultUiState,
onInterestsClick = onInterestsClick,
onSearchQueryChanged = searchViewModel::onSearchQueryChanged, onSearchQueryChanged = searchViewModel::onSearchQueryChanged,
onSearchTriggered = searchViewModel::onSearchTriggered, onSearchTriggered = searchViewModel::onSearchTriggered,
onTopicClick = onTopicClick, onClearRecentSearches = searchViewModel::clearRecentSearches,
onNewsResourcesCheckedChanged = forYouViewModel::updateNewsResourceSaved, onNewsResourcesCheckedChanged = forYouViewModel::updateNewsResourceSaved,
onNewsResourceViewed = { bookmarksViewModel.setNewsResourceViewed(it, true) }, onNewsResourceViewed = { bookmarksViewModel.setNewsResourceViewed(it, true) },
recentSearchesUiState = recentSearchQueriesUiState, onFollowButtonClick = interestsViewModel::followTopic,
searchQuery = searchQuery, onBackClick = onBackClick,
searchResultUiState = searchResultUiState, onInterestsClick = onInterestsClick,
onTopicClick = onTopicClick,
) )
} }
@Composable @Composable
internal fun SearchScreen( internal fun SearchScreen(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onBackClick: () -> Unit = {}, searchQuery: String = "",
recentSearchesUiState: RecentSearchQueriesUiState = RecentSearchQueriesUiState.Loading,
searchResultUiState: SearchResultUiState = SearchResultUiState.Loading,
onSearchQueryChanged: (String) -> Unit = {},
onSearchTriggered: (String) -> Unit = {},
onClearRecentSearches: () -> Unit = {}, onClearRecentSearches: () -> Unit = {},
onFollowButtonClick: (String, Boolean) -> Unit = { _, _ -> },
onInterestsClick: () -> Unit = {},
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = { _, _ -> }, onNewsResourcesCheckedChanged: (String, Boolean) -> Unit = { _, _ -> },
onNewsResourceViewed: (String) -> Unit = {}, onNewsResourceViewed: (String) -> Unit = {},
onSearchQueryChanged: (String) -> Unit = {}, onFollowButtonClick: (String, Boolean) -> Unit = { _, _ -> },
onSearchTriggered: (String) -> Unit = {}, onBackClick: () -> Unit = {},
onInterestsClick: () -> Unit = {},
onTopicClick: (String) -> Unit = {}, onTopicClick: (String) -> Unit = {},
searchQuery: String = "",
recentSearchesUiState: RecentSearchQueriesUiState = RecentSearchQueriesUiState.Loading,
searchResultUiState: SearchResultUiState = SearchResultUiState.Loading,
) { ) {
TrackScreenViewEvent(screenName = "Search") TrackScreenViewEvent(screenName = "Search")
Column(modifier = modifier) { Column(modifier = modifier) {
@ -177,8 +177,8 @@ internal fun SearchScreen(
is SearchResultUiState.Success -> { is SearchResultUiState.Success -> {
if (searchResultUiState.isEmpty()) { if (searchResultUiState.isEmpty()) {
EmptySearchResultBody( EmptySearchResultBody(
onInterestsClick = onInterestsClick,
searchQuery = searchQuery, searchQuery = searchQuery,
onInterestsClick = onInterestsClick,
) )
if (recentSearchesUiState is RecentSearchQueriesUiState.Success) { if (recentSearchesUiState is RecentSearchQueriesUiState.Success) {
RecentSearchesBody( RecentSearchesBody(
@ -192,14 +192,14 @@ internal fun SearchScreen(
} }
} else { } else {
SearchResultBody( SearchResultBody(
searchQuery = searchQuery,
topics = searchResultUiState.topics, topics = searchResultUiState.topics,
onFollowButtonClick = onFollowButtonClick, newsResources = searchResultUiState.newsResources,
onNewsResourcesCheckedChanged = onNewsResourcesCheckedChanged,
onNewsResourceViewed = onNewsResourceViewed,
onSearchTriggered = onSearchTriggered, onSearchTriggered = onSearchTriggered,
onTopicClick = onTopicClick, onTopicClick = onTopicClick,
newsResources = searchResultUiState.newsResources, onNewsResourcesCheckedChanged = onNewsResourcesCheckedChanged,
searchQuery = searchQuery, onNewsResourceViewed = onNewsResourceViewed,
onFollowButtonClick = onFollowButtonClick,
) )
} }
} }
@ -210,8 +210,8 @@ internal fun SearchScreen(
@Composable @Composable
fun EmptySearchResultBody( fun EmptySearchResultBody(
onInterestsClick: () -> Unit,
searchQuery: String, searchQuery: String,
onInterestsClick: () -> Unit,
) { ) {
Column( Column(
horizontalAlignment = Alignment.CenterHorizontally, horizontalAlignment = Alignment.CenterHorizontally,
@ -286,14 +286,14 @@ private fun SearchNotReadyBody() {
@Composable @Composable
private fun SearchResultBody( private fun SearchResultBody(
searchQuery: String,
topics: List<FollowableTopic>, topics: List<FollowableTopic>,
newsResources: List<UserNewsResource>, newsResources: List<UserNewsResource>,
onFollowButtonClick: (String, Boolean) -> Unit,
onNewsResourcesCheckedChanged: (String, Boolean) -> Unit,
onNewsResourceViewed: (String) -> Unit,
onSearchTriggered: (String) -> Unit, onSearchTriggered: (String) -> Unit,
onTopicClick: (String) -> Unit, onTopicClick: (String) -> Unit,
searchQuery: String = "", onNewsResourcesCheckedChanged: (String, Boolean) -> Unit,
onNewsResourceViewed: (String) -> Unit,
onFollowButtonClick: (String, Boolean) -> Unit,
) { ) {
val state = rememberLazyStaggeredGridState() val state = rememberLazyStaggeredGridState()
Box( Box(
@ -392,9 +392,9 @@ private fun SearchResultBody(
@Composable @Composable
private fun RecentSearchesBody( private fun RecentSearchesBody(
recentSearchQueries: List<String>,
onClearRecentSearches: () -> Unit, onClearRecentSearches: () -> Unit,
onRecentSearchClicked: (String) -> Unit, onRecentSearchClicked: (String) -> Unit,
recentSearchQueries: List<String>,
) { ) {
Column { Column {
Row( Row(
@ -444,11 +444,11 @@ private fun RecentSearchesBody(
@Composable @Composable
private fun SearchToolbar( private fun SearchToolbar(
modifier: Modifier = Modifier, searchQuery: String,
onBackClick: () -> Unit,
onSearchQueryChanged: (String) -> Unit, onSearchQueryChanged: (String) -> Unit,
searchQuery: String = "",
onSearchTriggered: (String) -> Unit, onSearchTriggered: (String) -> Unit,
onBackClick: () -> Unit,
modifier: Modifier = Modifier,
) { ) {
Row( Row(
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
@ -473,8 +473,8 @@ private fun SearchToolbar(
@OptIn(ExperimentalComposeUiApi::class) @OptIn(ExperimentalComposeUiApi::class)
@Composable @Composable
private fun SearchTextField( private fun SearchTextField(
onSearchQueryChanged: (String) -> Unit,
searchQuery: String, searchQuery: String,
onSearchQueryChanged: (String) -> Unit,
onSearchTriggered: (String) -> Unit, onSearchTriggered: (String) -> Unit,
) { ) {
val focusRequester = remember { FocusRequester() } val focusRequester = remember { FocusRequester() }
@ -556,6 +556,7 @@ private fun SearchTextField(
private fun SearchToolbarPreview() { private fun SearchToolbarPreview() {
NiaTheme { NiaTheme {
SearchToolbar( SearchToolbar(
searchQuery = "",
onBackClick = {}, onBackClick = {},
onSearchQueryChanged = {}, onSearchQueryChanged = {},
onSearchTriggered = {}, onSearchTriggered = {},

Loading…
Cancel
Save