Im trying to setup a system where I can specify a ...
# compose
z
Im trying to setup a system where I can specify a keyline, and have the title of my TopAppBar start at exactly that line. Its way harder than I thought though, theres some magical numbers (4.dp start padding) thrown into the mix, and Id love to avoid hardcoding them if possible. My thinking is that Id just need to calculate how far from the start of my composable the title is, but I dont know how.
Copy code
@Composable
fun TopAppBarWithKeyline(keyline: Dp = 72.dp){
	Row{
	    NavigationIcon(Modifier.padding(horizontal = ?.dp))

        // This is basically what I want to do, but I have no clue on how Id get the
        // magic numbers; I can get navigationSize from Modifier.onPlaced, etc.
	    val titleOffset = keyline - magicNumber*2 + navigationSize
	    Title(Modifier.offset(x=titleOffset))
	}
}
1
The closest Ive gotten to a working solution has been to throw Modifier.onPlaced on my title, then use coordinates.positionInParent().x as the offset. But that also has the side effect of tossing my title around since onPlaced gets called whenever I move the title. If I have some if(!called) before adjusting the offset, I wont get the final values that I need.