Alex Vanyo
06/19/2025, 7:39 PMAlex Vanyo
06/19/2025, 7:40 PMval configChangeLayoutCoordinatesHolder = remember { LayoutCoordinatesHolder() }
val recreationLayoutCoordinatesHolder = remember { LayoutCoordinatesHolder() }
val onConfigurationChangedLayoutCoordinatesHolder = remember { LayoutCoordinatesHolder() }
Box(
modifier = Modifier.fillMaxSize()
) {
Row(
Modifier.fillMaxSize(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
) {
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier
.layoutCoordinates(configChangeLayoutCoordinatesHolder)
.padding(16.dp),
) {
Text(
"Configuration",
style = MaterialTheme.typography.h4,
)
Text(
"Changes",
style = MaterialTheme.typography.h4,
)
}
Spacer(Modifier.size(100.dp))
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.Start,
) {
Text(
"Activity Recreation",
style = MaterialTheme.typography.h4,
modifier = Modifier
.layoutCoordinates(recreationLayoutCoordinatesHolder)
.padding(16.dp)
)
Spacer(Modifier.height(64.dp))
Text(
"onConfigurationChanged",
style = MaterialTheme.typography.h4,
fontFamily = jetBrainsMono,
modifier = Modifier
.layoutCoordinates(onConfigurationChangedLayoutCoordinatesHolder)
.padding(horizontal = 16.dp)
)
}
}
LineCanvas(
lines = listOf(
Arrow(
start = configChangeLayoutCoordinatesHolder,
startAlignment = Alignment.CenterEnd,
end = recreationLayoutCoordinatesHolder,
endAlignment = Alignment.CenterStart,
color = MaterialTheme.colors.onSurface,
),
Arrow(
start = configChangeLayoutCoordinatesHolder,
startAlignment = Alignment.CenterEnd,
end = onConfigurationChangedLayoutCoordinatesHolder,
endAlignment = Alignment.CenterStart,
color = MaterialTheme.colors.onSurface,
),
),
modifier = Modifier.fillMaxSize(),
)
}
Alex Vanyo
06/19/2025, 7:44 PMLayoutCoordinates
reference, that you can attach arbitrarily with a Modifier
.
Then, you can have an overlaying LineCanvas
that can draw stuff using those references.
The thing I needed was just a simple straight-line arrow from start to end, so that's what I went with, but the idea could be expanded to any other sort of overlaying-y anchoring-y thingbnorm
06/19/2025, 7:48 PMbnorm
06/19/2025, 7:51 PMConnectedLayout(
connections = listOf(
Arrow(start = startKey, end = endKey, ...),
...
)
) {
Box(Modifier.connected(startKey)...) { ... }
Box(Modifier.connected(endKey)...) { ... }
}
Alex Vanyo
06/20/2025, 5:21 PM