Apply Composable Parameter Ordering Guidelines

Change-Id: Id456e91b5ce8bd5807c40df67c3deac008c61670
pull/1248/head
kim-yongsuk 10 months ago
parent 11359185ce
commit 3fa75a037a

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

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

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

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

Loading…
Cancel
Save