0
0
mirror of https://github.com/mediathekview/zapp.git synced 2024-09-20 04:12:14 +02:00

Hide bottom navigation for non main destinations

This commit is contained in:
Christine Coenen 2022-04-21 09:59:56 +02:00
parent 6f0169d1b9
commit 9307a46559
4 changed files with 47 additions and 5 deletions

View File

@ -4,7 +4,9 @@ import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.*
import androidx.preference.PreferenceManager
@ -40,11 +42,35 @@ class MainActivity : AppCompatActivity() {
setSupportActionBar(binding.toolbar)
setupActionBarWithNavController(navController, appBarConfiguration)
navController.addOnDestinationChangedListener(::onDestinationChanged)
binding.bottomNavigation.setupWithNavController(navController)
PreferenceManager.setDefaultValues(application, R.xml.preferences, false)
}
@Suppress("UNUSED_PARAMETER")
private fun onDestinationChanged(
controller: NavController,
destination: NavDestination,
arguments: Bundle?
) {
val isMainDestination = arguments?.getBoolean("is_main_destination", false) == true
// hide bottom navigation for non main destinations
binding.bottomNavigation.isVisible = isMainDestination
// hide toolbar logo for non main destinations
if (isMainDestination) {
binding.toolbar.setLogo(R.drawable.ic_zapp_tv_small)
binding.toolbar.titleMarginStart =
resources.getDimensionPixelSize(R.dimen.toolbar_logo_margin)
} else {
binding.toolbar.logo = null
binding.toolbar.titleMarginStart = 0
}
}
override fun onDestroy() {
super.onDestroy()
_binding = null

View File

@ -27,8 +27,7 @@
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="8dp"
app:logo="@drawable/ic_zapp_tv_small"
app:titleMarginStart="32dp" />
app:logo="@drawable/ic_zapp_tv_small" />
</com.google.android.material.appbar.AppBarLayout>

View File

@ -9,17 +9,32 @@
android:id="@+id/channelListFragment"
android:name="de.christinecoenen.code.zapp.app.livestream.ui.list.ChannelListFragment"
android:label="@string/app_name"
tools:layout="@layout/fragment_channel_list" />
tools:layout="@layout/fragment_channel_list">
<argument
android:name="is_main_destination"
android:defaultValue="true"
app:argType="boolean" />
</fragment>
<fragment
android:id="@+id/mediathekListFragment"
android:name="de.christinecoenen.code.zapp.app.mediathek.ui.list.MediathekListFragment"
android:label="@string/app_name"
tools:layout="@layout/fragment_mediathek_list" />
tools:layout="@layout/fragment_mediathek_list">
<argument
android:name="is_main_destination"
android:defaultValue="true"
app:argType="boolean" />
</fragment>
<fragment
android:id="@+id/downloadsFragment"
android:name="de.christinecoenen.code.zapp.app.downloads.ui.list.DownloadsFragment"
android:label="@string/app_name"
tools:layout="@layout/downloads_fragment" />
tools:layout="@layout/downloads_fragment">
<argument
android:name="is_main_destination"
android:defaultValue="true"
app:argType="boolean" />
</fragment>
<fragment
android:id="@+id/settingsFragment"
android:name="de.christinecoenen.code.zapp.app.settings.ui.SettingsFragment"

View File

@ -3,6 +3,8 @@
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="toolbar_logo_margin">32dp</dimen>
<dimen name="view_program_info_subtitle_margin_bottom">4dp</dimen>
<dimen name="activity_channel_selection_item_width">120dip</dimen>