pull/1833/merge
Adnan Habib 5 days ago committed by GitHub
commit 4a325b571a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -40,6 +40,7 @@ import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollba
import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState import com.google.samples.apps.nowinandroid.core.designsystem.component.scrollbar.scrollbarState
import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic import com.google.samples.apps.nowinandroid.core.model.data.FollowableTopic
import com.google.samples.apps.nowinandroid.core.ui.InterestsItem import com.google.samples.apps.nowinandroid.core.ui.InterestsItem
import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank
@Composable @Composable
fun TopicsTabContent( fun TopicsTabContent(
@ -56,10 +57,14 @@ fun TopicsTabContent(
.fillMaxWidth(), .fillMaxWidth(),
) { ) {
val scrollableState = rememberLazyListState() val scrollableState = rememberLazyListState()
val testTag = "interests:topics"
TrackScrollJank(scrollableState = scrollableState, stateName = testTag)
LazyColumn( LazyColumn(
modifier = Modifier modifier = Modifier
.padding(horizontal = 24.dp) .padding(horizontal = 24.dp)
.testTag("interests:topics"), .testTag(testTag),
contentPadding = PaddingValues(vertical = 16.dp), contentPadding = PaddingValues(vertical = 16.dp),
state = scrollableState, state = scrollableState,
) { ) {

@ -36,6 +36,7 @@ import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.layout.windowInsetsTopHeight import androidx.compose.foundation.layout.windowInsetsTopHeight
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan
@ -92,6 +93,7 @@ import com.google.samples.apps.nowinandroid.core.ui.InterestsItem
import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success import com.google.samples.apps.nowinandroid.core.ui.NewsFeedUiState.Success
import com.google.samples.apps.nowinandroid.core.ui.R.string import com.google.samples.apps.nowinandroid.core.ui.R.string
import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent import com.google.samples.apps.nowinandroid.core.ui.TrackScreenViewEvent
import com.google.samples.apps.nowinandroid.core.ui.TrackScrollJank
import com.google.samples.apps.nowinandroid.core.ui.newsFeed import com.google.samples.apps.nowinandroid.core.ui.newsFeed
import com.google.samples.apps.nowinandroid.feature.search.R as searchR import com.google.samples.apps.nowinandroid.feature.search.R as searchR
@ -154,8 +156,7 @@ internal fun SearchScreen(
-> Unit -> Unit
SearchResultUiState.SearchNotReady -> SearchNotReadyBody() SearchResultUiState.SearchNotReady -> SearchNotReadyBody()
SearchResultUiState.EmptyQuery, SearchResultUiState.EmptyQuery -> {
-> {
if (recentSearchesUiState is RecentSearchQueriesUiState.Success) { if (recentSearchesUiState is RecentSearchQueriesUiState.Success) {
RecentSearchesBody( RecentSearchesBody(
onClearRecentSearches = onClearRecentSearches, onClearRecentSearches = onClearRecentSearches,
@ -293,6 +294,10 @@ private fun SearchResultBody(
onFollowButtonClick: (String, Boolean) -> Unit, onFollowButtonClick: (String, Boolean) -> Unit,
) { ) {
val state = rememberLazyStaggeredGridState() val state = rememberLazyStaggeredGridState()
val testTag = "search:searchResult"
TrackScrollJank(scrollableState = state, stateName = testTag)
Box( Box(
modifier = Modifier modifier = Modifier
.fillMaxSize(), .fillMaxSize(),
@ -304,7 +309,7 @@ private fun SearchResultBody(
verticalItemSpacing = 24.dp, verticalItemSpacing = 24.dp,
modifier = Modifier modifier = Modifier
.fillMaxSize() .fillMaxSize()
.testTag("search:newsResources"), .testTag(testTag),
state = state, state = state,
) { ) {
if (topics.isNotEmpty()) { if (topics.isNotEmpty()) {
@ -394,6 +399,10 @@ private fun RecentSearchesBody(
onRecentSearchClicked: (String) -> Unit, onRecentSearchClicked: (String) -> Unit,
) { ) {
Column { Column {
val scrollableState = rememberLazyListState()
TrackScrollJank(scrollableState = scrollableState, stateName = "search:recentSearches")
Row( Row(
horizontalArrangement = Arrangement.SpaceBetween, horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically, verticalAlignment = Alignment.CenterVertically,
@ -424,7 +433,10 @@ private fun RecentSearchesBody(
} }
} }
} }
LazyColumn(modifier = Modifier.padding(horizontal = 16.dp)) { LazyColumn(
modifier = Modifier.padding(horizontal = 16.dp),
state = scrollableState,
) {
items(recentSearchQueries) { recentSearch -> items(recentSearchQueries) { recentSearch ->
Text( Text(
text = recentSearch, text = recentSearch,

Loading…
Cancel
Save