fix collapsing toolbar title when doing back gesture

This commit is contained in:
Franek 2024-06-16 15:12:06 +02:00
parent 743050712b
commit bc8c952853
No known key found for this signature in database
GPG Key ID: 0329F871B2079351

View File

@ -967,16 +967,18 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
bottomSheet.removeAllContextual() bottomSheet.removeAllContextual()
bottomSheet.toggleGroupEnabled = false bottomSheet.toggleGroupEnabled = false
drawer.close() drawer.close()
if (drawer.getSelection() != navTarget.id) if (drawer.getSelection() != navTarget.id)
drawer.setSelection(navTarget.id, fireOnClick = false) drawer.setSelection(navTarget.id, fireOnClick = false)
navView.toolbar.setTitle(navTarget.titleRes ?: navTarget.nameRes)
navView.bottomBar.fabEnable = false navView.bottomBar.fabEnable = false
navView.bottomBar.fabExtended = false navView.bottomBar.fabExtended = false
navView.bottomBar.setFabOnClickListener(null) navView.bottomBar.setFabOnClickListener(null)
navView.toolbarLayout.setTitle((navTarget.titleRes ?: navTarget.nameRes).resolveString(applicationContext))
d("NavDebug", "Navigating from ${this.navTarget.name} to ${navTarget.name}") d("NavDebug", "Navigating from ${this.navTarget.name} to ${navTarget.name}")
val fragment = navTarget.fragmentClass?.newInstance() ?: return val fragment = navTarget.fragmentClass?.getDeclaredConstructor()?.newInstance() ?: return
fragment.arguments = arguments fragment.arguments = arguments
val transaction = fragmentManager.beginTransaction() val transaction = fragmentManager.beginTransaction()
@ -1084,7 +1086,7 @@ class MainActivity : AppCompatActivity(), CoroutineScope {
fun navigateUp(skipBeforeNavigate: Boolean = false) { fun navigateUp(skipBeforeNavigate: Boolean = false) {
if (!popBackStack(skipBeforeNavigate)) { if (!popBackStack(skipBeforeNavigate)) {
super.onBackPressed() super.onBackPressedDispatcher.onBackPressed()
} }
} }