Created
January 21, 2022 09:16
-
-
Save hvisser/de8686e7a82df94d2607100206d2df04 to your computer and use it in GitHub Desktop.
LocalView.current can be useful if you need to tap into a view function like keepScreenOn or haptics from Compose
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
@Composable | |
fun KeepScreenOn() { | |
val currentView = LocalView.current | |
DisposableEffect(Unit) { | |
currentView.keepScreenOn = true | |
onDispose { | |
currentView.keepScreenOn = false | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment