Last active
February 11, 2025 18:02
-
-
Save vitoksmile/f5c71992bfa393d00f9792c636b00bc7 to your computer and use it in GitHub Desktop.
ComposeHints
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Stable | |
| class HintAnchorState internal constructor() { | |
| internal var size: IntSize by mutableStateOf(IntSize.Zero) | |
| internal var offset: Offset by mutableStateOf(Offset.Zero) | |
| } | |
| @Composable | |
| fun rememberHintAnchorState(): HintAnchorState { | |
| return remember { HintAnchorState() } | |
| } | |
| fun Modifier.hintAnchor(state: HintAnchorState): Modifier { | |
| return onGloballyPositioned { | |
| state.size = it.size | |
| state.offset = it.positionInWindow() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment