change: Move SwipeRefreshLayout margin in AccountActivity (#642)

AccountActivity is full screen, so the swipe spinner was appearing very
close to the top system bar. Adjust the spinner's top margin to avoid
the system bar, and have it scale in/out so it doesn't appear to slide
out from an invisible barrier.
This commit is contained in:
Nik Clayton 2024-04-23 15:58:32 +02:00 committed by GitHub
parent 9e954a2c8b
commit 5959d23d89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 0 deletions

View File

@ -35,6 +35,7 @@ import android.view.MenuInflater
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.ViewGroup.MarginLayoutParams
import androidx.activity.viewModels
import androidx.annotation.ColorInt
import androidx.annotation.DrawableRes
@ -48,6 +49,7 @@ import androidx.core.view.ViewCompat
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsCompat.Type.systemBars
import androidx.core.view.updateLayoutParams
import androidx.core.view.updatePadding
import androidx.core.widget.doAfterTextChanged
import androidx.recyclerview.widget.LinearLayoutManager
@ -313,6 +315,11 @@ class AccountActivity :
val left = insets.getInsets(systemBars()).left
binding.accountCoordinatorLayout.updatePadding(right = right, bottom = bottom, left = left)
// Scale the swipe spinner instead of appearing to come from nowhere, and adjust the
// top margin to avoid the system bar
binding.swipeRefreshLayout.setProgressViewEndTarget(true, binding.swipeRefreshLayout.progressViewEndOffset)
binding.swipeRefreshLayout.updateLayoutParams<MarginLayoutParams> { topMargin = top }
WindowInsetsCompat.CONSUMED
}
}