TV: Cache main tab models and extract scroll-offset modifier#4572
Open
SergioEstevao wants to merge 13 commits into
Open
TV: Cache main tab models and extract scroll-offset modifier#4572SergioEstevao wants to merge 13 commits into
SergioEstevao wants to merge 13 commits into
Conversation
Collaborator
Generated by 🚫 Danger |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves performance and structure in the Pocket Casts TV App main tab UI by caching tab-scoped view models in MainTabViewModel (so tabs don’t rebuild their models on each presentation) and extracting the repeated scroll-offset tracking logic into a reusable modifier.
Changes:
- Hoist and cache Home/Podcasts/Playlists/Up Next/Search/Discover All view models onto
MainTabViewModeland inject them into tab views. - Extract repeated
.onScrollGeometryChangelogic into atrackScrollOffset()modifier and apply it across tab content. - Remove
SearchViewContainer, tweak layout inRootView, and adjust tab transition structure.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Pocket Casts TV App/UI/UpNext/UpNextView.swift | Accepts an injected UpNextViewModel and updates environment dependency to MainTabViewModel. |
| Pocket Casts TV App/UI/Starred/StarredEpisodesView.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/Search/SearchViewContainer.swift | Removes the container wrapper now that SearchViewModel is injected/cached elsewhere. |
| Pocket Casts TV App/UI/Search/SearchResultsView.swift | Switches environment dependency to MainTabViewModel and reuses cached DiscoverAllViewModel. |
| Pocket Casts TV App/UI/RootView.swift | Adjusts loading layout sizing (frame(maxWidth: .infinity)). |
| Pocket Casts TV App/UI/Podcasts/PodcastsView.swift | Updates environment dependency to MainTabViewModel and preview injection. |
| Pocket Casts TV App/UI/Podcasts/PodcastDetailView.swift | Renames router environment dependency to MainTabViewModel and updates preview. |
| Pocket Casts TV App/UI/Podcasts/EpisodeRow.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/Playlists/PlaylistsView.swift | Accepts an injected PlaylistsViewModel and updates environment dependency to MainTabViewModel. |
| Pocket Casts TV App/UI/Playlists/PlaylistDetailView.swift | Renames router environment dependency to MainTabViewModel and updates preview. |
| Pocket Casts TV App/UI/Playlists/PlaylistCell.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/Player/NowPlayingTab.swift | Updates environment dependency to MainTabViewModel. |
| Pocket Casts TV App/UI/Player/NowPlayingRow.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/MainTabViewModel.swift | Renames router to MainTabViewModel and adds cached tab view models. |
| Pocket Casts TV App/UI/MainTabView.swift | Uses cached models, adds trackScrollOffset() modifier, and removes wrapper impacting animations. |
| Pocket Casts TV App/UI/Home/HomeView.swift | Accepts an injected HomeViewModel and updates environment dependency to MainTabViewModel. |
| Pocket Casts TV App/UI/History/ListeningHistoryView.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/Discover/DiscoverVideoEpisodeCell.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/Discover/DiscoverPodcastsListView.swift | Renames router environment dependency to MainTabViewModel and updates preview. |
| Pocket Casts TV App/UI/Discover/DiscoverFeaturedPodcastCell.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/Discover/DiscoverCategoryCell.swift | Updates preview environment injection to MainTabViewModel. |
| Pocket Casts TV App/UI/Discover/DiscoverAllView.swift | Accepts an injected DiscoverAllViewModel and removes direct scroll-offset reporting. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes: PCIOS-753
Performance and structural cleanup for the Pocket Casts TV App main tab UI.
The tab content models (Home, My Podcasts, Playlists, Up Next, Search, Discover All) were previously recreated on each tab presentation. This PR hoists them onto
MainTabViewModelso they are constructed once and cached for the lifetime of the tab router, avoiding redundant reloads when switching tabs.It also tidies up the tab content view:
trackScrollOffsetmodifier — the four (now five) identical.onScrollGeometryChangeblocks inMainTabContentVieware extracted into a single reusabletrackScrollOffset()view modifier that reports the scroll offset to the view model..ifand aZStackwrapper that were interfering with tab transition animations.To test
Checklist
CHANGELOG.mdif necessary.