mirror of
https://github.com/libre-tube/LibreTube.git
synced 2025-04-27 23:40:33 +05:30
fix: preserve platform bottom navigation implementation (#6956)
This commit is contained in:
parent
5bafa1209a
commit
f519168422
@ -26,6 +26,7 @@ import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.NavController
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import androidx.navigation.ui.onNavDestinationSelected
|
||||
import androidx.navigation.ui.setupWithNavController
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.BuildConfig
|
||||
@ -163,7 +164,6 @@ class MainActivity : BaseActivity() {
|
||||
|
||||
binding.bottomNav.setOnItemSelectedListener {
|
||||
navigateToBottomSelectedItem(it)
|
||||
false
|
||||
}
|
||||
|
||||
if (binding.bottomNav.menu.children.none { it.itemId == startFragmentId }) deselectBottomBarItems()
|
||||
@ -551,21 +551,17 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateToBottomSelectedItem(item: MenuItem) {
|
||||
private fun navigateToBottomSelectedItem(item: MenuItem): Boolean {
|
||||
if (item.itemId == R.id.subscriptionsFragment) {
|
||||
binding.bottomNav.removeBadge(R.id.subscriptionsFragment)
|
||||
}
|
||||
|
||||
// navigate to the selected fragment, if the fragment already
|
||||
// exists in backstack then pop up to that entry
|
||||
if (!navController.popBackStack(item.itemId, false)) {
|
||||
navController.navigate(item.itemId)
|
||||
}
|
||||
|
||||
// Remove focus from search view when navigating to bottom view.
|
||||
// Call only after navigate to destination, so it can be used in
|
||||
// onMenuItemActionCollapse for backstack management
|
||||
removeSearchFocus()
|
||||
|
||||
return item.onNavDestinationSelected(navController)
|
||||
}
|
||||
|
||||
override fun onUserLeaveHint() {
|
||||
|
@ -41,6 +41,7 @@
|
||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
app:defaultNavHost="true"
|
||||
app:layout_constraintBottom_toTopOf="@+id/bottomNav"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
Loading…
x
Reference in New Issue
Block a user