Introducing a new way to review your PRs.

Read the announcement

metrolistgroup / metrolist

Material Design YouTube Music client for Android, iOS and desktop

View on GitHub

19 documents · Updated Nov 4, 2026

docs / compose-navigation-and-screens

Compose navigation and music screens

Metrolist presents music through a set of Jetpack Compose screens. A shared navigation graph moves the user from the main Home, Search, Listen Together, and Library areas into detail pages for songs, albums, artists, playlists, podcasts, and browse results. Screens bind to view-model state, reuse common music and menu components, and keep the active player visible while the user explores the catalog.

Screen model

Main screen areas

The main screen areas provide the app's stable entry points. Screens defines their names, routes, labels, and selected or unselected icons, while the navigation bar and rail use the same list to show the current area. Search detail routes still count as part of Search, so the user keeps a clear point of return while moving through results.

References: app/…/Screens.kt• L13-50 app/…/AppNavigation.kt• L36-48

The navigation graph maps a route to a screen and passes identity or query data through route arguments. Main areas lead to focused journeys such as search results, catalog browse pages, artist and album details, online or local playlists, podcasts, settings, recognition, and the equalizer. Detail screens provide normal back navigation, while a long back action can return directly to a main area.

The following diagram shows how a user moves from a main area into discovery or library content and then into a playable detail view.

flowchart LR
    Main[Main areas] --> Home[Home]
    Main --> Search[Search]
    Main --> Library[Library]
    Home --> Discover[Recommendations and browse]
    Search --> Results[Search results]
    Discover --> Detail[Album, artist, playlist, or podcast]
    Results --> Detail
    Library --> Local[Local songs, albums, artists, playlists, or podcasts]
    Local --> Detail
    Detail --> Play[Play or queue music]

References: app/…/NavigationBuilder.kt• L68-184 app/…/NavigationBuilder.kt• L186-345 app/…/NavControllerUtils.kt• L8-17

Shared interaction surfaces

Music items support two levels of action. A normal tap opens a detail page or starts playback. A long press opens a bottom-sheet menu with actions that fit the item type, such as a song, album, artist, playlist, podcast, or episode. The shared menu state lets any screen request the sheet without owning a separate menu host.

This pattern keeps actions close to the item that caused them. It also gives local and remote items a common interaction model, even when their available actions differ.

References: app/…/BottomSheetMenu.kt• L44-62 app/…/BottomSheetMenu.kt• L121-156 app/…/YouTubeBrowseScreen.kt• L104-194

Reusable music components

Shared Compose components provide the visual and interaction language for music content. Grid and list items show local or remote metadata, mark the active item, and connect taps to playback or navigation. Other shared pieces provide chips, navigation titles, loading placeholders, hide-on-scroll actions, and artist links.

Screens compose these pieces into different layouts rather than creating a new item pattern for each page. This makes Home, Search, Browse, Library, and detail pages feel like parts of one music surface.

References: app/…/Items.kt• L142-220 app/…/HomeScreen.kt• L812-1024 app/…/BrowseScreen.kt• L66-145

State and presentation

View-model screen binding

Each data-heavy screen gets a view model for loading and shaping its state. The screen collects that state with lifecycle awareness, then combines it with player state, user preferences, and navigation arguments to decide what to show and what a tap should do. This keeps network, database, filtering, and pagination work outside the composable layout.

The binding model supports both local and remote content. For example, Home joins recommendations with local history and saved items, while album and library screens expose their own data flows for the current route and user filters.

References: app/…/HomeScreen.kt• L645-704 app/…/AlbumScreen.kt• L100-136 app/…/HomeViewModel.kt• L91-125

Theme and display modes

The Compose theme gives every screen one Material color and type system. It can follow the system light or dark mode, use Android system colors on supported devices, or derive a palette from a chosen theme color. Dark mode can also use pure black surfaces for screens and navigation surfaces.

Screens read colors and typography from MaterialTheme instead of defining their own global palette. This lets the same library and discovery journeys adapt to the selected appearance without changing their content model.

References: app/…/Theme.kt• L28-68 app/…/Theme.kt• L89-98 app/…/AppNavigation.kt• L50-66

Library journey

Library entry and filters

The Library screen is the local music hub. It starts with a mixed library view and lets the user switch to playlists, songs, albums, artists, or podcasts through a shared filter row. Each category can choose the view style that suits its content, while child screens keep the same navigation controller for opening details.

The library view models turn database changes and saved preferences into screen state. Song data can be filtered and sorted, searched with a delayed query, and narrowed by local rules such as liked, downloaded, or uploaded content.

References: app/…/LibraryScreen.kt• L26-83 app/…/LibraryViewModels.kt• L74-120 app/…/LibrarySongsScreen.kt• L86-120

Library detail paths

Library items lead to the same detail concepts used by discovery. A local album opens an album journey, an artist opens artist content, and a playlist opens a local playlist. From those pages the user can play items, select several songs, manage downloads, and use the relevant item menu.

This shared destination model prevents the library from becoming a separate product surface. It also lets playback state and common actions remain familiar when the source changes from local data to YouTube Music data.

References: app/…/AlbumScreen.kt• L100-180 app/…/NavigationBuilder.kt• L186-327 app/…/LibraryPlaylistsScreen.kt• L100-150

Discovery journey

Home discovery

Home is a changing discovery feed that joins personal listening context with remote recommendations. It can show quick picks, daily discovery, continued listening, account playlists, community playlists, similar recommendations, remote home sections, and mood or genre entry points. The view model supplies these groups, and the screen arranges them into cards, rows, grids, or a selected chip view.

The feed also acts as a launch point for playback and catalog navigation. A song can start a queue, while an album, artist, playlist, podcast, or episode can open the matching route. Long press adds the same contextual menu used elsewhere.

References: app/…/HomeScreen.kt• L177-204 app/…/HomeScreen.kt• L912-1024 app/…/HomeViewModel.kt• L70-117

Search and browse

Search begins with one input surface that can target the local library or the online YouTube Music catalog. A direct video or catalog URL takes the user to the matching playable or detail destination. A text query opens remote results with summary sections, filters, pagination, search history, and item actions.

Browse screens present remote collections as grids. They resolve the selected browse or query identity through the navigation route, load the matching items through a view model, and route each item to playback or a detail page. Loading placeholders and lifecycle-aware state make the same journey work while data is still arriving.

References: app/…/SearchScreen.kt• L127-173 app/…/OnlineSearchResult.kt• L170-231 app/…/YouTubeBrowseScreen.kt• L58-90 app/…/BrowseScreen.kt• L48-74

Change checklist

When these files or sections are changed, remember to consider these:

  • When a main route or detail route changes, update route selection, back-to-main behavior, and every item tap that creates that route.
  • When a new remote item type is added, align its tap, long-press menu, active-player state, and detail destination in Home, Search, and Browse.
  • When a library filter changes, keep its chip value, child screen, view preference, and view-model query behavior in sync.
  • When theme or pure-black behavior changes, check both screen surfaces and the navigation bar or rail.
  • When a view model changes the shape of its state, update the screen's lifecycle collection and its loading, empty, and pagination states together.

Important failure modes

TriggerConsequenceGuard
A route argument does not match the route used by a screenThe detail page opens without the item identity or shows the wrong contentKeep route templates, argument names, and view-model saved-state reads aligned in NavigationBuilder and the destination screen
A new item type has no tap or menu mappingThe item appears in a feed but does not open, play, or offer actionsAdd the type to the shared item handling used by Home, Search, and Browse
A library chip and its view model use different filter valuesThe selected tab shows stale data or returns to the wrong library viewTreat the library filter enum, chip list, child screen, and query flow as one contract
A screen ignores player-aware insetsThe mini-player or navigation bar covers the last contentPreserve player-aware padding and bottom spacing in scrollable content

Key files

FileWhy to read it
app/…/NavigationBuilder.ktMain route-to-screen map and navigation argument contract
app/…/Screens.ktMain screen identities, labels, icons, and routes
app/…/AppNavigation.ktBottom navigation and rail selection behavior
app/…/HomeScreen.ktHome discovery composition and item interaction patterns
app/…/LibraryScreen.ktLibrary filters and transitions to local content views
app/…/SearchScreen.ktLocal versus online search entry journey
app/…/OnlineSearchResult.ktRemote results, filters, paging, and result actions
app/…/YouTubeBrowseScreen.ktRemote browse grid and item routing
app/…/Items.ktReusable music item presentation and interaction base
app/…/BottomSheetMenu.ktShared menu state and bottom-sheet action surface
app/…/Theme.ktApp-wide Compose color and display modes
app/…/HomeViewModel.ktHome discovery state assembled for the screen
app/…/LibraryViewModels.ktLocal library query, filter, sort, and search state