Skip to content

Commit

Permalink
Merge pull request #13621 from woocommerce/fix-prologue-carousel
Browse files Browse the repository at this point in the history
[Login] Fix Window insets handling for the prologue carousel
  • Loading branch information
irfano authored Feb 26, 2025
2 parents 0a0c70c + fffa106 commit 960c3ef
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,26 +55,24 @@ class LoginPrologueCarouselFragment : Fragment(R.layout.fragment_login_prologue_

val isTablet = DisplayUtils.isTablet(context) || DisplayUtils.isXLargeTablet(context)
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
val insets = windowInsets.getInsets(
WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout()
)
val buttonHorizontalMargin = resources.getDimension(R.dimen.prologue_button_horizontal_margin)

binding.buttonSkip.updateLayoutParams<MarginLayoutParams> {
val currentBottomMargin = resources.getDimension(R.dimen.prologue_button_skip_bottom_margin)
bottomMargin = currentBottomMargin.roundToInt() + insets.bottom
if (!isTablet) {
val buttonHorizontalMargin = resources.getDimension(R.dimen.prologue_button_horizontal_margin)
rightMargin = buttonHorizontalMargin.roundToInt() + insets.right
}
}
WindowInsetsCompat.CONSUMED
}
if (!isTablet) {
ViewCompat.setOnApplyWindowInsetsListener(binding.buttonNext) { v, windowInsets ->
val insets = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars())
val buttonHorizontalMargin = resources.getDimension(R.dimen.prologue_button_horizontal_margin)
v.updateLayoutParams<MarginLayoutParams> {
if (!isTablet) {
binding.buttonNext.updateLayoutParams<MarginLayoutParams> {
leftMargin = buttonHorizontalMargin.roundToInt() + insets.left
}
WindowInsetsCompat.CONSUMED
}
WindowInsetsCompat.CONSUMED
}

val adapter = LoginPrologueAdapter(this)
Expand Down

0 comments on commit 960c3ef

Please sign in to comment.