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 { binding.bottomNav.setOnItemSelectedListener {
// clear backstack if it's the start fragment // clear backstack if it's the start fragment
if (startFragmentId == it.itemId) navController.backQueue.clear() if (startFragmentId == it.itemId) navController.backQueue.clear()
// set menu item on click listeners
removeSearchFocus() if (it.itemId == R.id.subscriptionsFragment) {
when (it.itemId) { binding.bottomNav.removeBadge(R.id.subscriptionsFragment)
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)
}
} }
removeSearchFocus()
// navigate to the selected fragment
navController.navigate(it.itemId)
false false
} }

View File

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

View File

@ -5,13 +5,27 @@
android:id="@+id/homeFragment" android:id="@+id/homeFragment"
android:icon="@drawable/ic_home" android:icon="@drawable/ic_home"
android:title="@string/startpage" /> android:title="@string/startpage" />
<item <item
android:id="@+id/subscriptionsFragment" android:id="@+id/subscriptionsFragment"
android:icon="@drawable/ic_subscriptions" android:icon="@drawable/ic_subscriptions"
android:title="@string/subscriptions" /> android:title="@string/subscriptions" />
<item <item
android:id="@+id/libraryFragment" android:id="@+id/libraryFragment"
android:icon="@drawable/ic_library" android:icon="@drawable/ic_library"
android:title="@string/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> </menu>