|
|
@ -49,13 +49,14 @@ import androidx.compose.foundation.layout.windowInsetsBottomHeight
|
|
|
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
|
|
import androidx.compose.foundation.layout.windowInsetsPadding
|
|
|
|
import androidx.compose.foundation.lazy.LazyListScope
|
|
|
|
import androidx.compose.foundation.lazy.LazyListScope
|
|
|
|
import androidx.compose.foundation.lazy.grid.GridCells
|
|
|
|
import androidx.compose.foundation.lazy.grid.GridCells
|
|
|
|
import androidx.compose.foundation.lazy.grid.GridCells.Adaptive
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.GridItemSpan
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.LazyGridScope
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid
|
|
|
|
import androidx.compose.foundation.lazy.grid.LazyHorizontalGrid
|
|
|
|
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.grid.items
|
|
|
|
import androidx.compose.foundation.lazy.grid.items
|
|
|
|
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
|
|
|
import androidx.compose.foundation.lazy.grid.rememberLazyGridState
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.staggeredgrid.LazyStaggeredGridScope
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.staggeredgrid.LazyVerticalStaggeredGrid
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridCells
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.staggeredgrid.StaggeredGridItemSpan
|
|
|
|
|
|
|
|
import androidx.compose.foundation.lazy.staggeredgrid.rememberLazyStaggeredGridState
|
|
|
|
import androidx.compose.foundation.shape.CornerSize
|
|
|
|
import androidx.compose.foundation.shape.CornerSize
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.Icon
|
|
|
@ -153,7 +154,7 @@ internal fun ForYouScreen(
|
|
|
|
|
|
|
|
|
|
|
|
val itemsAvailable = feedItemsSize(feedState, onboardingUiState)
|
|
|
|
val itemsAvailable = feedItemsSize(feedState, onboardingUiState)
|
|
|
|
|
|
|
|
|
|
|
|
val state = rememberLazyGridState()
|
|
|
|
val state = rememberLazyStaggeredGridState()
|
|
|
|
val scrollbarState = state.scrollbarState(
|
|
|
|
val scrollbarState = state.scrollbarState(
|
|
|
|
itemsAvailable = itemsAvailable,
|
|
|
|
itemsAvailable = itemsAvailable,
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -163,11 +164,11 @@ internal fun ForYouScreen(
|
|
|
|
modifier = modifier
|
|
|
|
modifier = modifier
|
|
|
|
.fillMaxSize(),
|
|
|
|
.fillMaxSize(),
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
LazyVerticalGrid(
|
|
|
|
LazyVerticalStaggeredGrid(
|
|
|
|
columns = Adaptive(300.dp),
|
|
|
|
columns = StaggeredGridCells.Adaptive(300.dp),
|
|
|
|
contentPadding = PaddingValues(16.dp),
|
|
|
|
contentPadding = PaddingValues(16.dp),
|
|
|
|
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
|
|
|
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
|
|
|
verticalArrangement = Arrangement.spacedBy(24.dp),
|
|
|
|
verticalItemSpacing = 24.dp,
|
|
|
|
modifier = Modifier
|
|
|
|
modifier = Modifier
|
|
|
|
.testTag("forYou:feed"),
|
|
|
|
.testTag("forYou:feed"),
|
|
|
|
state = state,
|
|
|
|
state = state,
|
|
|
@ -197,7 +198,7 @@ internal fun ForYouScreen(
|
|
|
|
onTopicClick = onTopicClick,
|
|
|
|
onTopicClick = onTopicClick,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
item(span = { GridItemSpan(maxLineSpan) }, contentType = "bottomSpacing") {
|
|
|
|
item(span = StaggeredGridItemSpan.FullLine, contentType = "bottomSpacing") {
|
|
|
|
Column {
|
|
|
|
Column {
|
|
|
|
Spacer(modifier = Modifier.height(8.dp))
|
|
|
|
Spacer(modifier = Modifier.height(8.dp))
|
|
|
|
// Add space for the content to clear the "offline" snackbar.
|
|
|
|
// Add space for the content to clear the "offline" snackbar.
|
|
|
@ -255,7 +256,7 @@ internal fun ForYouScreen(
|
|
|
|
* Depending on the [onboardingUiState], this might emit no items.
|
|
|
|
* Depending on the [onboardingUiState], this might emit no items.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private fun LazyGridScope.onboarding(
|
|
|
|
private fun LazyStaggeredGridScope.onboarding(
|
|
|
|
onboardingUiState: OnboardingUiState,
|
|
|
|
onboardingUiState: OnboardingUiState,
|
|
|
|
onTopicCheckedChanged: (String, Boolean) -> Unit,
|
|
|
|
onTopicCheckedChanged: (String, Boolean) -> Unit,
|
|
|
|
saveFollowedTopics: () -> Unit,
|
|
|
|
saveFollowedTopics: () -> Unit,
|
|
|
@ -268,7 +269,7 @@ private fun LazyGridScope.onboarding(
|
|
|
|
-> Unit
|
|
|
|
-> Unit
|
|
|
|
|
|
|
|
|
|
|
|
is OnboardingUiState.Shown -> {
|
|
|
|
is OnboardingUiState.Shown -> {
|
|
|
|
item(span = { GridItemSpan(maxLineSpan) }, contentType = "onboarding") {
|
|
|
|
item(span = StaggeredGridItemSpan.FullLine, contentType = "onboarding") {
|
|
|
|
Column(modifier = interestsItemModifier) {
|
|
|
|
Column(modifier = interestsItemModifier) {
|
|
|
|
Text(
|
|
|
|
Text(
|
|
|
|
text = stringResource(R.string.onboarding_guidance_title),
|
|
|
|
text = stringResource(R.string.onboarding_guidance_title),
|
|
|
|