Skip to content

Commit a6b6b9b

Browse files
author
Chris Banes
committedJul 8, 2020
[Jetcaster] Migrate to using preferredWrapContent
Along with using bias, we can workaround b/160757904 Change-Id: Iaa9925cee357aea12a1aba82145378cae92185d2
1 parent 8ba20ea commit a6b6b9b

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed
 

‎Jetcaster/app/src/main/java/com/example/jetcaster/ui/home/CategoryList.kt

+24-8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import com.example.jetcaster.data.Category
5858
import com.example.jetcaster.data.Episode
5959
import com.example.jetcaster.data.Podcast
6060
import com.example.jetcaster.ui.theme.JetcasterTheme
61+
import com.example.jetcaster.ui.theme.Keyline1
6162
import com.example.jetcaster.util.viewModelProviderFactoryOf
6263
import dev.chrisbanes.accompanist.coil.CoilImageWithCrossfade
6364
import java.time.format.DateTimeFormatter
@@ -114,6 +115,7 @@ fun EpisodeListItem(
114115
Modifier.constrainAs(divider) {
115116
top.linkTo(parent.top)
116117
centerHorizontallyTo(parent)
118+
117119
width = Dimension.fillToConstraints
118120
}
119121
)
@@ -157,10 +159,16 @@ fun EpisodeListItem(
157159
lineHeight = 20.sp,
158160
style = MaterialTheme.typography.subtitle1,
159161
modifier = Modifier.constrainAs(episodeTitle) {
160-
start.linkTo(parent.start, 16.dp)
162+
linkTo(
163+
start = parent.start,
164+
end = image.start,
165+
startMargin = Keyline1,
166+
endMargin = 16.dp,
167+
bias = 0f
168+
)
161169
top.linkTo(parent.top, 16.dp)
162-
end.linkTo(image.start, 16.dp)
163-
width = Dimension.fillToConstraints
170+
171+
width = Dimension.preferredWrapContent
164172
}
165173
)
166174
}
@@ -173,10 +181,16 @@ fun EpisodeListItem(
173181
maxLines = 2,
174182
style = MaterialTheme.typography.caption,
175183
modifier = Modifier.constrainAs(podcastTitle) {
176-
start.linkTo(episodeTitle.start)
184+
linkTo(
185+
start = parent.start,
186+
end = image.start,
187+
startMargin = Keyline1,
188+
endMargin = 16.dp,
189+
bias = 0f
190+
)
177191
top.linkTo(episodeTitle.bottom, 4.dp)
178-
end.linkTo(episodeTitle.end)
179-
width = Dimension.fillToConstraints
192+
193+
width = Dimension.preferredWrapContent
180194
}
181195
)
182196

@@ -187,9 +201,10 @@ fun EpisodeListItem(
187201
overflow = TextOverflow.Ellipsis,
188202
style = MaterialTheme.typography.caption,
189203
modifier = Modifier.constrainAs(summary) {
190-
start.linkTo(podcastTitle.start)
204+
start.linkTo(parent.start, Keyline1)
191205
end.linkTo(image.end)
192206
top.linkTo(titleImageBarrier, 16.dp)
207+
193208
width = Dimension.fillToConstraints
194209
}
195210
)
@@ -204,7 +219,7 @@ fun EpisodeListItem(
204219
modifier = Modifier.preferredSize(48.dp)
205220
.clickable { /* TODO */ }
206221
.constrainAs(playIcon) {
207-
start.linkTo(podcastTitle.start)
222+
start.linkTo(parent.start, Keyline1)
208223
top.linkTo(summary.bottom, margin = 16.dp)
209224
bottom.linkTo(parent.bottom, 16.dp)
210225
}
@@ -233,6 +248,7 @@ fun EpisodeListItem(
233248
start.linkTo(playIcon.end, margin = 16.dp)
234249
end.linkTo(addPlaylist.start, margin = 16.dp)
235250
centerVerticallyTo(playIcon)
251+
236252
width = Dimension.fillToConstraints
237253
}
238254
)

0 commit comments

Comments
 (0)