-
-
Save KatieBarnett/2807b455311b34cd577de8d090b4b1b2 to your computer and use it in GitHub Desktop.
Pinned scroll state with isScrolled check
This file contains 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
... | |
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState()) | |
val isScrolled = remember { derivedStateOf { scrollBehavior.state.contentOffset < -100f } } | |
val topAppBarElementColor = if (isScrolled.value) { | |
MaterialTheme.colorScheme.onSurface | |
} else { | |
MaterialTheme.colorScheme.onPrimary | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment