Michal Klimczak
05/20/2021, 5:34 PMnitrog42
05/20/2021, 5:36 PMnitrog42
05/20/2021, 5:36 PMMichal Klimczak
05/20/2021, 5:36 PMChris Sinco [G]
05/20/2021, 8:42 PMChris Sinco [G]
05/20/2021, 8:43 PMLazyColumn
can be within anything else like Surface
or another Row/Box/Column
which you can add modifiers to in order to draw a background with a shapeChris Sinco [G]
05/20/2021, 8:48 PMfun Modifier.upperRoundRectStroke(
brush: Brush,
stroke: Stroke,
cornerRadius: CornerRadius
): Modifier {
return this.then(Modifier.drawWithContent {
drawContent()
clipRect {
drawRoundRect(
brush = brush,
topLeft = Offset(stroke.width / 2, stroke.width / 2), // inset round rect to account for the stroke width
size = Size(
size.width - stroke.width, // adjust size to account for stroke width on either side
size.height - stroke.width / 2 + cornerRadius.y // make the rect taller to extend beyond the bounds of the clip
),
style = stroke,
cornerRadius = cornerRadius
)
}
}
)
}
Michal Klimczak
05/21/2021, 4:48 AMMichal Klimczak
05/21/2021, 4:49 AMMichal Klimczak
05/21/2021, 4:52 AMChris Sinco [G]
05/21/2021, 9:34 PMwrapContentHeight()
on the LazyColumn
within a Surface
or Card
that has vertical scrolling. @Andrey Kulikov may know moreAndrey Kulikov
05/22/2021, 12:55 PMMichal Klimczak
05/22/2021, 4:59 PMMichal Klimczak
05/24/2021, 8:50 PMChris Sinco [G]
05/24/2021, 9:07 PMNader Jawad
05/24/2021, 9:23 PMModifier.drawWithCache
if you have objects that need to be allocated with sizing information. For example the stroke parameter would benefit from being cached across calls. As it is implemented now, a new stroke object will be allocated on every draw operation. The implementation would be identical to that of the existing Modifier.drawWithContent
implementation except the objects could be allocated within the main lambda block and the rest of the implementation would be placed in an onDraw
blockMichal Klimczak
05/25/2021, 8:29 AMNader Jawad
05/25/2021, 6:36 PMModifier.drawWithCache
lambda. It will automatically get invalidated whenever the size of the composable changes or any state parameters that are read in that block also change