Disable lift on scroll for search

This commit is contained in:
Kirill Kamakin
2022-11-21 19:48:19 +01:00
parent 1947de99db
commit 48ad18fa72
2 changed files with 18 additions and 21 deletions

View File

@@ -125,15 +125,14 @@ class MainActivity : AppCompatActivity(R.layout.main_activity) {
binding.toolbar.isSearchVisible = uiState.searchVisible binding.toolbar.isSearchVisible = uiState.searchVisible
if (uiState.searchVisible) { if (uiState.searchVisible) {
binding.toolbarHolder.setBackgroundResource(R.drawable.bg_toolbar) binding.toolbar.setBackgroundResource(R.drawable.bg_toolbar)
} else { } else {
binding.toolbarHolder.background = null binding.toolbar.background = null
} }
} }
private fun navigateTo(directions: NavDirections) { private fun navigateTo(directions: NavDirections) {
logger.v { "navigateTo() called with: directions = $directions" } logger.v { "navigateTo() called with: directions = $directions" }
binding.toolbarHolder.setExpanded(true)
binding.drawer.close() binding.drawer.close()
navController.navigate(directions) navController.navigate(directions)
} }

View File

@@ -6,37 +6,35 @@
style="?drawerLayoutStyle" style="?drawerLayoutStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context=".ui.activity.MainActivity" tools:context=".ui.activity.MainActivity">
tools:openDrawer="start">
<androidx.coordinatorlayout.widget.CoordinatorLayout <androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout <gq.kirmanak.mealient.ui.activity.ToolbarView
android:id="@+id/toolbar_holder" android:id="@+id/toolbar"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/margin_medium" android:layout_marginHorizontal="@dimen/margin_medium"
android:background="@drawable/bg_toolbar" android:background="@drawable/bg_toolbar"
app:liftOnScroll="true"> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
<gq.kirmanak.mealient.ui.activity.ToolbarView app:layout_constraintTop_toTopOf="parent" />
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|snap|enterAlways" />
</com.google.android.material.appbar.AppBarLayout>
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
android:id="@+id/nav_host" android:id="@+id/nav_host"
android:name="androidx.navigation.fragment.NavHostFragment" android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="0dp"
android:layout_marginTop="@dimen/margin_small" android:layout_marginTop="@dimen/margin_small"
app:defaultNavHost="true" app:defaultNavHost="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior" /> app:layout_constraintBottom_toBottomOf="parent"
</androidx.coordinatorlayout.widget.CoordinatorLayout> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/toolbar"
tools:layout="@layout/fragment_recipes_list" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView <com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view" android:id="@+id/navigation_view"