Can
03/07/2021, 3:04 PMDenis
03/07/2021, 3:32 PMCan
03/07/2021, 3:39 PMDenis
03/07/2021, 3:54 PMTextDelegate
in this thread. I don't know if it won't change significantly in future releases. But basing on this message from @Adam Powell, there's no hidden magic (private APIs), and I think even if it'll change, it will stay accessible in some way. In the worst case you just copy the code to your project and keep using it.
(Sorry for mentions, folks, but maybe you have something to add or correct me.)Adam Powell
03/07/2021, 3:59 PM@InternalFoundationTextApi
Can
03/07/2021, 4:20 PMval displayedValue = displayedValue
val textDelegate = if (displayedValue != null) {
TextDelegate(
text = AnnotatedString("${displayedValue / 1_000L}"),
style = MaterialTheme.typography.h1.copy(fontWeight = FontWeight.Bold),
density = Density(dm.density),
resourceLoader = LocalFontLoader.current
).layout(Constraints(), LayoutDirection.Ltr)
} else {
null
}
Canvas(
Modifier.fillMaxSize()
) {
if (textDelegate != null) {
drawIntoCanvas {
TextDelegate.paint(canvas = it, textDelegate)
}
}
drawRect(
color = Color.Red,
topLeft = Offset(0f, 0f),
size = Size(size.width, size.height),
blendMode = BlendMode.DstAtop
)
}
Canvas(
Modifier
.fillMaxSize()
.alpha(0.99f)
) {
if (textDelegate != null) {
drawIntoCanvas {
TextDelegate.paint(canvas = it, textDelegate)
}
}
drawRect(
color = Color.White,
topLeft = Offset(0f, size.height - boxHeight),
size = Size(size.width, boxHeight),
blendMode = BlendMode.SrcAtop
)
}
FYI @Denisromainguy
03/07/2021, 7:46 PMNader Jawad
03/07/2021, 7:54 PMCan
03/07/2021, 8:05 PM