Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix navigating back home #6976

Merged
merged 4 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading