add more items to navbar

This commit is contained in:
Bnyro 2022-09-26 18:50:57 +02:00
parent 48b3a916b7
commit e2eb131069
3 changed files with 24 additions and 14 deletions

View File

@ -106,20 +106,15 @@ class MainActivity : BaseActivity() {
binding.bottomNav.setOnItemSelectedListener {
// clear backstack if it's the start fragment
if (startFragmentId == it.itemId) navController.backQueue.clear()
// set menu item on click listeners
removeSearchFocus()
when (it.itemId) {
R.id.homeFragment -> {
navController.navigate(R.id.homeFragment)
}
R.id.subscriptionsFragment -> {
binding.bottomNav.removeBadge(R.id.subscriptionsFragment)
navController.navigate(R.id.subscriptionsFragment)
}
R.id.libraryFragment -> {
navController.navigate(R.id.libraryFragment)
}
if (it.itemId == R.id.subscriptionsFragment) {
binding.bottomNav.removeBadge(R.id.subscriptionsFragment)
}
removeSearchFocus()
// navigate to the selected fragment
navController.navigate(it.itemId)
false
}

View File

@ -37,7 +37,8 @@ object NavBarHelper {
defaultNavBarItems.add(
NavBarItem(
it.itemId,
it.title.toString()
it.title.toString(),
it.isEnabled
)
)
}

View File

@ -5,13 +5,27 @@
android:id="@+id/homeFragment"
android:icon="@drawable/ic_home"
android:title="@string/startpage" />
<item
android:id="@+id/subscriptionsFragment"
android:icon="@drawable/ic_subscriptions"
android:title="@string/subscriptions" />
<item
android:id="@+id/libraryFragment"
android:icon="@drawable/ic_library"
android:title="@string/library" />
<item
android:id="@+id/downloadsFragment"
android:icon="@drawable/ic_download_filled"
android:title="@string/downloads"
android:enabled="false" />
<item
android:id="@+id/watchHistoryFragment"
android:icon="@drawable/ic_history_filled"
android:title="@string/history"
android:enabled="false" />
</menu>