Closed nonproto closed 3 years ago
Hmmm, the API you outlined wouldn't really work, as insets are by definition asynchronous. I can imagine returning a Flow<Insets>
which you'd then collect. Would that work?
An example usage would be:
Insetter.builder()
.valueTop(windowInsetTypesOf(navigationBars = true)
.build()
.collect { insets ->
view1.updatePadding(0, insets.top, 0, 0)
view2.updatePadding(0, insets.top, 0, 0)
}
that would be super helpful
Although, at that point you wouldn't need Insetter
at all. You could just do:
ViewCompat.setOnApplyWindowInsetsListener(rootView) { v, insets ->
val i = insets.getInsets(windowInsetTypesOf(navigationBars = true))
view1.updatePadding(0, i.top, 0, 0)
view2.updatePadding(0, i.top, 0, 0)
}
thanks that actually worked out well
I am using https://github.com/cashapp/contour in a project and it would be nice to have something like
There are probably other uses cases outside of using contour where this could be helpful like