Skip to content

Commit

Permalink
[feat]: added NavigationRailView
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse205 authored Oct 2, 2023
1 parent 2752a8a commit a0c07f2
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),

navController = findNavController(R.id.nav_host_fragment_content_main)

binding.bottomNavigation.setupWithNavController(navController)
binding.bottomNavigation.setOnItemReselectedListener {
binding.bottomNavigation?.setupWithNavController(navController)
binding.bottomNavigation?.setOnItemReselectedListener {
// Just do nothing
}
binding.navigationRail?.setupWithNavController(navController)

navController.addOnDestinationChangedListener(this)

Expand Down Expand Up @@ -74,7 +75,8 @@ class MainActivity: BaseViewModelActivity<MainViewModel, ActivityMainBinding>(),
else -> true
}

binding.bottomNavigation.visibility = if (barShown) View.VISIBLE else View.GONE
binding.bottomNavigation?.visibility = if (barShown) View.VISIBLE else View.GONE
binding.navigationRail?.visibility = if (barShown) View.VISIBLE else View.GONE
}

override fun onNewIntent(intent: Intent?) {
Expand Down
31 changes: 31 additions & 0 deletions app/src/main/res/layout-land/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">

<fragment
android:id="@+id/nav_host_fragment_content_main"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="0dp"
android:layout_height="0dp"
app:defaultNavHost="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/navigation_rail"
app:layout_constraintBottom_toBottomOf="parent"
app:navGraph="@navigation/nav_graph" />

<com.google.android.material.navigationrail.NavigationRailView
android:id="@+id/navigation_rail"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:itemTextAppearanceActive="@style/LogFoxBottomNavigationViewTextStyle"
app:itemTextAppearanceInactive="@style/LogFoxBottomNavigationViewTextStyle"
app:menu="@menu/main_menu"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@id/nav_host_fragment_content_main"
app:layout_constraintBottom_toBottomOf="parent"/>

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit a0c07f2

Please sign in to comment.