Brais Gabin
11/22/2023, 2:23 PMfun Modifier.badge(text: String): Modifier
so you could add a "Badge" to any Composable without the need of a BadgeBox
(that's the material's solution). I tried with drawWithContent
but the badge is kind of complex to use such a low level api. And with Modifier.layout
I can just layout the "Composable" I can't add the Badge
composable to measure it and layout it. Is there any way to do this?Stylianos Gakis
11/22/2023, 2:29 PMmyanmarking
11/22/2023, 4:11 PMStylianos Gakis
11/22/2023, 4:24 PMBadgeBox
which material does for whatever reason that may be, and asked for a fun Modifier..() : Modifire
solution, which is why I suggested this 😄myanmarking
11/22/2023, 4:26 PMStylianos Gakis
11/22/2023, 4:33 PMmyanmarking
11/22/2023, 4:35 PMefemoney
11/29/2023, 1:50 PMBrais Gabin
11/29/2023, 2:16 PMdrawWitnContent
that text is not pick up by TalkBack so you need to implement it yourself and that's kind of difficult. Specially because I don't know how to write an accesibility test to ensure that it doesn't break.efemoney
11/29/2023, 2:18 PMefemoney
11/29/2023, 2:19 PMefemoney
11/29/2023, 2:21 PMchild: Size
within parent: Size
,
just place child at offset: Offset = parent.center - child.center
To pin it to the topLeft or topRight, the code is similar, the offset you should draw/place from should be something like parent.topRight - child.topRight.
Infact you can use the alignment (horizontal, vertical etc) values you are familiar with to handle these.
You will just need to know what are the bounds you are working with.
For measuring the text, there is a handy TextMeasurer
.efemoney
11/29/2023, 2:28 PM