Skip to content

refactor: consolidate common media context menu items into MediaMenuFlyout - #1076

Draft
huynhsontung wants to merge 4 commits into
mainfrom
consolidate_common_menu_flyouts
Draft

refactor: consolidate common media context menu items into MediaMenuFlyout#1076
huynhsontung wants to merge 4 commits into
mainfrom
consolidate_common_menu_flyouts

Conversation

@huynhsontung

Copy link
Copy Markdown
Owner

Context & Motivation

Across various media listing pages (SongsPage, AllVideosPage, FolderViewPage, FolderListViewPage, HomePage, AlbumDetailsPage, ArtistDetailsPage, PlaylistDetailsPage, SearchResultPage, SongSearchResultPage, VideoSearchResultPage), the context menu (ItemFlyout) repeated dozens of lines of identical XAML definitions for common media actions (Play, Play Next, Add to Queue, Add to Playlist, Open With, Open in File Explorer, Properties, Set Playback Options).

In addition to XAML boilerplate duplication, each page had to declare visual state setters to mirror glyphs for Right-to-Left (RTL) languages.

Key Changes & Impact

  • New MediaMenuFlyout Custom Control: Subclasses MenuFlyout to encapsulate standard media items natively in C#, handling commands, item parameters (unwrapping StorageItemViewModel to MediaViewModel as needed), dynamic play/pause icons, and RTL glyph mirroring automatically.
  • Extensibility Support: Pages can still declare page-specific menu items inside <controls:MediaMenuFlyout> in XAML (e.g. ShowAlbum, ShowArtist, RemoveCommand, SelectCommand), which are dynamically appended in the correct order.
  • Refactored 11 Pages: Replaced duplicated <MenuFlyout x:Key="ItemFlyout"> declarations across 11 media views with <controls:MediaMenuFlyout>, stripping hundreds of lines of duplicated XAML and removing redundant RTL VisualState setters.

Testing & Verification

  • Ran automated test suite via dotnet run --project Screenbox.Core.Tests/Screenbox.Core.Tests.csproj (all 26 tests passed).
  • Verified XAML bindings and control hierarchies across all updated pages.

…lyout

- Introduce MediaMenuFlyout control to centralize standard media context menu items (Play, Play Next, Add to Queue, Add to Playlist, Open With, Open in File Explorer, Properties, Set Playback Options).
- Handle dynamic play/pause icons and labels, RTL icon mirroring, and media item command parameter resolution directly in C#.
- Support page-specific extension items defined within XAML content.
- Refactor SongsPage, AllVideosPage, FolderViewPage, and FolderListViewPage to use MediaMenuFlyout.
Consolidate duplicated MenuFlyout XAML definitions into the reusable
MediaMenuFlyout component across AlbumDetailsPage, ArtistDetailsPage,
HomePage, PlaylistDetailsPage, SearchResultPage, SongSearchResultPage,
and VideoSearchResultPage. Also removes redundant RTL icon visual states.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant