Skip to content

Commit

Permalink
fix: navigating back home after clicking home section link (#6976)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pittvandewitt authored Jan 19, 2025
1 parent 9893df8 commit 8911810
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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!!
Expand All @@ -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 {
Expand Down
54 changes: 43 additions & 11 deletions app/src/main/res/navigation/nav.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -43,17 +72,17 @@
android:id="@+id/channelFragment"
android:name="com.github.libretube.ui.fragments.ChannelFragment"
android:label="channel"
tools:layout="@layout/fragment_channel" >
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"
Expand All @@ -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"
Expand All @@ -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>

0 comments on commit 8911810

Please sign in to comment.