From 2a69d1b0510107efd38de10853efabb90757635d Mon Sep 17 00:00:00 2001 From: arkon Date: Tue, 13 Apr 2021 18:23:06 -0400 Subject: [PATCH] Add navigation bar scrim (closes #4836) --- .../kanade/tachiyomi/ui/main/MainActivity.kt | 21 ++++++++++++++----- app/src/main/res/layout/main_activity.xml | 13 ++++++++++++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index bf336e777..3a66f4902 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -24,6 +24,7 @@ import com.bluelinelabs.conductor.Router import com.bluelinelabs.conductor.RouterTransaction import com.google.android.material.appbar.AppBarLayout import com.google.android.material.behavior.HideBottomViewOnScrollBehavior +import dev.chrisbanes.insetter.Insetter import dev.chrisbanes.insetter.applyInsetter import eu.kanade.tachiyomi.BuildConfig import eu.kanade.tachiyomi.Migrations @@ -102,16 +103,26 @@ class MainActivity : BaseViewBindingActivity() { margin(top = true) } } - binding.bottomNav.applyInsetter { - type(navigationBars = true) { - padding() - } - } binding.rootFab.applyInsetter { type(navigationBars = true) { margin() } } + binding.bottomNav.applyInsetter { + type(navigationBars = true) { + padding() + } + } + Insetter.builder() + .consume(Insetter.CONSUME_ALL) + .setOnApplyInsetsListener { view, insets, _ -> + val systemInsets = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + view.isVisible = systemInsets.bottom > 0 + view.updateLayoutParams { + height = systemInsets.bottom + } + } + .applyToView(binding.navigationScrim) // Make sure navigation bar is on bottom when making it transparent ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, insets -> diff --git a/app/src/main/res/layout/main_activity.xml b/app/src/main/res/layout/main_activity.xml index cbd72ac50..d43b4c88c 100644 --- a/app/src/main/res/layout/main_activity.xml +++ b/app/src/main/res/layout/main_activity.xml @@ -91,4 +91,17 @@ app:layout_insetEdge="bottom" app:menu="@menu/bottom_nav" /> + +