Hanzhen
08/16/2020, 10:11 PMromainguy
08/16/2020, 10:13 PMursus
08/16/2020, 11:05 PMZach Klippenstein (he/him) [MOD]
08/16/2020, 11:33 PMursus
08/17/2020, 12:30 AMHanzhen
08/17/2020, 7:06 AMTimo Drick
08/17/2020, 7:30 AMprivate var insets by mutableStateOf(WindowInsetsCompat.Builder().build())
private val systemWindowInsetListener = { view: View, insets: WindowInsetsCompat ->
this.insets = insets
insets
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
ViewCompat.setOnApplyWindowInsetsListener(window.decorView.rootView, systemWindowInsetListener)
setContent {
AppThemeTransparent {
val insetPadding = with(DensityAmbient.current) {
val ltr = ConfigurationAmbient.current.localeLayoutDirection == LayoutDirection.Ltr
with(insets) {
InnerPadding(
start = if (ltr) systemWindowInsetLeft.toDp() else systemWindowInsetRight.toDp(),
top = systemWindowInsetTop.toDp(),
end = if (ltr) systemWindowInsetRight.toDp() else systemWindowInsetLeft.toDp(),
bottom = systemWindowInsetBottom.toDp()
)
}
}
Zach Klippenstein (he/him) [MOD]
08/17/2020, 8:20 AMViewGroup.setContent
Hanzhen
08/17/2020, 11:12 AMZach Klippenstein (he/him) [MOD]
08/17/2020, 3:23 PMonActive
block, and use onDisposed
to clean up.
Also FYI you can share larger code snippets in slack, with syntax highlighting, by posting a Snippet.Zach Klippenstein (he/him) [MOD]
08/17/2020, 3:32 PMViewAmbient
.Hanzhen
08/17/2020, 7:05 PMonActive
, but I can by wrapping it in remember
. Is it a bug? Also ViewAmbient
can only be called inside Composable context.cb
08/17/2020, 8:44 PM