Skip to content

Commit a43f6ca

Browse files
committed
Tweaks to chip alignment and padding.
1 parent 8fa519a commit a43f6ca

1 file changed

Lines changed: 43 additions & 28 deletions

File tree

app/src/main/java/org/wikipedia/feed/personalization/interest/InterestSelectionScreen.kt

Lines changed: 43 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import androidx.compose.ui.Alignment
3838
import androidx.compose.ui.Modifier
3939
import androidx.compose.ui.draw.clip
4040
import androidx.compose.ui.graphics.Color
41+
import androidx.compose.ui.layout.layout
4142
import androidx.compose.ui.res.painterResource
4243
import androidx.compose.ui.res.stringResource
4344
import androidx.compose.ui.text.font.FontWeight
@@ -73,9 +74,7 @@ fun InterestOnboardingScreen(
7374
) {
7475
val transition = rememberInfiniteTransition(label = "shimmerTransition")
7576
Box(modifier = modifier) {
76-
Column(
77-
verticalArrangement = Arrangement.spacedBy(16.dp),
78-
) {
77+
Column {
7978
Text(
8079
modifier = Modifier.padding(horizontal = 16.dp),
8180
text = stringResource(id = R.string.recommended_reading_list_interest_pick_title),
@@ -84,6 +83,7 @@ fun InterestOnboardingScreen(
8483
),
8584
color = WikipediaTheme.colors.primaryColor
8685
)
86+
Spacer(modifier = Modifier.height(16.dp))
8787

8888
LazyVerticalStaggeredGrid(
8989
columns = StaggeredGridCells.Adaptive(140.dp),
@@ -92,7 +92,7 @@ fun InterestOnboardingScreen(
9292
state = gridState,
9393
verticalItemSpacing = 16.dp,
9494
horizontalArrangement = Arrangement.spacedBy(16.dp),
95-
contentPadding = PaddingValues(16.dp),
95+
contentPadding = PaddingValues(start = 16.dp, end = 16.dp, bottom = 16.dp),
9696
content = {
9797
item(span = StaggeredGridItemSpan.FullLine) {
9898
SearchBarCard(
@@ -101,32 +101,47 @@ fun InterestOnboardingScreen(
101101
)
102102
}
103103
item(span = StaggeredGridItemSpan.FullLine) {
104-
when (topicsState) {
105-
is TopicsState.Error -> {
106-
showError(topicsState.message)
104+
Box(
105+
modifier = Modifier.layout { measurable, constraints ->
106+
val extra = 16.dp.roundToPx() * 2
107+
val placeable = measurable.measure(
108+
constraints.copy(
109+
minWidth = constraints.minWidth + extra,
110+
maxWidth = constraints.maxWidth + extra
111+
)
112+
)
113+
layout(placeable.width, placeable.height) {
114+
placeable.place(0, 0)
115+
}
107116
}
108-
TopicsState.Loading -> {
109-
LazyRow(
110-
horizontalArrangement = Arrangement.spacedBy(8.dp),
111-
contentPadding = PaddingValues(horizontal = 16.dp)
112-
) {
113-
items(5) {
114-
Box(
115-
modifier = Modifier
116-
.width(80.dp)
117-
.height(32.dp)
118-
.clip(RoundedCornerShape(size = 8.dp))
119-
.shimmerEffect(transition = transition)
120-
)
117+
) {
118+
when (topicsState) {
119+
is TopicsState.Error -> {
120+
showError(topicsState.message)
121+
}
122+
TopicsState.Loading -> {
123+
LazyRow(
124+
horizontalArrangement = Arrangement.spacedBy(8.dp),
125+
contentPadding = PaddingValues(horizontal = 16.dp)
126+
) {
127+
items(5) {
128+
Box(
129+
modifier = Modifier
130+
.width(80.dp)
131+
.height(32.dp)
132+
.clip(RoundedCornerShape(size = 8.dp))
133+
.shimmerEffect(transition = transition)
134+
)
135+
}
121136
}
122137
}
123-
}
124138

125-
is TopicsState.Success -> {
126-
TopicFilterChipRow(
127-
topics = topicsState.topics,
128-
onTopicSelected = { onTopicSelected(it) }
129-
)
139+
is TopicsState.Success -> {
140+
TopicFilterChipRow(
141+
topics = topicsState.topics,
142+
onTopicSelected = { onTopicSelected(it) }
143+
)
144+
}
130145
}
131146
}
132147
}
@@ -202,11 +217,11 @@ fun TopicFilterChipRow(
202217
) {
203218
LazyRow(
204219
modifier = modifier,
205-
horizontalArrangement = Arrangement.spacedBy(8.dp)
220+
horizontalArrangement = Arrangement.spacedBy(8.dp),
221+
contentPadding = PaddingValues(horizontal = 16.dp)
206222
) {
207223
items(items = topics, key = { it.topicId }) { item ->
208224
FilterChip(
209-
modifier = Modifier.fillMaxWidth(),
210225
label = { Text(item.displayTitle) },
211226
selected = item.isSelected,
212227
onClick = { onTopicSelected(item) },

0 commit comments

Comments
 (0)