-
-
Save KatieBarnett/cd4a50a19560e7a65309f2b35b0ebb9b to your computer and use it in GitHub Desktop.
Setting element colour for top app bar with derived state of
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.enterAlwaysScrollBehavior(rememberTopAppBarState()) | |
val isCollapsed = remember { derivedStateOf { scrollBehavior.state.collapsedFraction > 0.5 } } | |
val topAppBarElementColor = if (isCollapsed) { | |
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