fix: navigating back home after clicking home section link (#6976)

This commit is contained in:
Thomas W. 2025-01-19 11:53:39 +01:00 committed by GitHub
parent 9893df8763
commit 8911810c76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 16 deletions

View File

@ -33,6 +33,7 @@ import com.github.libretube.ui.models.HomeViewModel
import com.github.libretube.ui.models.SubscriptionsViewModel
import com.google.android.material.snackbar.Snackbar
class HomeFragment : Fragment(R.layout.fragment_home) {
private var _binding: FragmentHomeBinding? = null
private val binding get() = _binding!!
@ -54,23 +55,23 @@ class HomeFragment : Fragment(R.layout.fragment_home) {
}
binding.featuredTV.setOnClickListener {
findNavController().navigate(R.id.subscriptionsFragment)
findNavController().navigate(R.id.action_homeFragment_to_subscriptionsFragment)
}
binding.watchingTV.setOnClickListener {
findNavController().navigate(R.id.watchHistoryFragment)
findNavController().navigate(R.id.action_homeFragment_to_watchHistoryFragment)
}
binding.trendingTV.setOnClickListener {
findNavController().navigate(R.id.trendsFragment)
findNavController().navigate(R.id.action_homeFragment_to_trendsFragment)
}
binding.playlistsTV.setOnClickListener {
findNavController().navigate(R.id.libraryFragment)
findNavController().navigate(R.id.action_homeFragment_to_libraryFragment)
}
binding.bookmarksTV.setOnClickListener {
findNavController().navigate(R.id.libraryFragment)
findNavController().navigate(R.id.action_homeFragment_to_libraryFragment)
}
binding.refresh.setOnRefreshListener {

View File

@ -8,7 +8,36 @@
android:id="@+id/homeFragment"
android:name="com.github.libretube.ui.fragments.HomeFragment"
android:label="fragment_home"
tools:layout="@layout/fragment_home" />
tools:layout="@layout/fragment_home">
<action
android:id="@+id/action_homeFragment_to_libraryFragment"
app:destination="@id/libraryFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
<action
android:id="@+id/action_homeFragment_to_watchHistoryFragment"
app:destination="@id/watchHistoryFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
<action
android:id="@+id/action_homeFragment_to_trendsFragment"
app:destination="@id/trendsFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
<action
android:id="@+id/action_homeFragment_to_subscriptionsFragment"
app:destination="@id/subscriptionsFragment"
app:popUpTo="@id/homeFragment"
app:popUpToInclusive="false"
app:popUpToSaveState="true"
app:restoreState="true" />
</fragment>
<fragment
android:id="@+id/trendsFragment"
android:name="com.github.libretube.ui.fragments.TrendsFragment"
@ -46,14 +75,14 @@
tools:layout="@layout/fragment_channel">
<argument
android:name="channelId"
android:defaultValue="@null"
app:argType="string"
app:nullable="true"
android:defaultValue="@null" />
app:nullable="true" />
<argument
android:name="channelName"
android:defaultValue="@null"
app:argType="string"
app:nullable="true"
android:defaultValue="@null" />
app:nullable="true" />
</fragment>
<fragment
android:id="@+id/playlistFragment"
@ -66,9 +95,9 @@
app:nullable="false" />
<argument
android:name="playlistType"
android:defaultValue="PUBLIC"
app:argType="com.github.libretube.enums.PlaylistType"
app:nullable="false"
android:defaultValue="PUBLIC" />
app:nullable="false" />
</fragment>
<fragment
android:id="@+id/watchHistoryFragment"
@ -81,10 +110,13 @@
android:label="@string/downloads"
tools:layout="@layout/fragment_downloads" />
<action android:id="@+id/openChannel"
<action
android:id="@+id/openChannel"
app:destination="@id/channelFragment" />
<action android:id="@+id/openPlaylist"
<action
android:id="@+id/openPlaylist"
app:destination="@id/playlistFragment" />
<action android:id="@+id/showSearchResults"
<action
android:id="@+id/showSearchResults"
app:destination="@id/searchResultFragment" />
</navigation>