mirror of
https://github.com/yattee/yattee.git
synced 2026-10-28 23:47:17 +00:00
Add per-page element customization and panel settings polish
Phase 5 of the player panels redesign: - Per-page element toggles now rendered and editable for every page: comments (author avatars), related (thumbnails), chapters (thumbnails), queue (previously played section), tracks (video/audio/subtitles/speed sections) - Page bar labels toggle (icons-only bar shows the selected page's name) - Layout mode schematic diagram in the details panel settings - NEW badge machinery for future page types (versionAdded on PanelPageType) - Typed per-page settings accessors on PanelPageConfiguration and VM update helpers for each page kind - Unit tests for per-page settings round-trip and accessor fallbacks The standalone quality selector sheet is unaffected: section gating defaults to everything visible and only the embedded tracks page passes preset settings through.
This commit is contained in:
@@ -50,6 +50,45 @@ struct PanelSettingsTests {
|
||||
#expect(info?.effectiveShowChannelRow == true)
|
||||
}
|
||||
|
||||
@Test("Per-page element settings round-trip for every page type")
|
||||
func perPageSettingsRoundTrip() throws {
|
||||
var settings = PanelSettings.default
|
||||
settings.updateSettings(.comments(CommentsPageSettings(showAvatars: false)), for: .comments)
|
||||
settings.updateSettings(.related(RelatedPageSettings(showThumbnails: false)), for: .related)
|
||||
settings.updateSettings(.chapters(ChaptersPageSettings(showThumbnails: false)), for: .chapters)
|
||||
settings.updateSettings(.queue(QueuePageSettings(showHistory: false)), for: .queue)
|
||||
settings.updateSettings(
|
||||
.tracks(TracksPageSettings(showQuality: false, showSubtitles: false)),
|
||||
for: .tracks
|
||||
)
|
||||
|
||||
let decoded = try roundTrip(settings)
|
||||
#expect(decoded == settings)
|
||||
#expect(decoded.configuration(for: .comments)?.commentsSettings.effectiveShowAvatars == false)
|
||||
#expect(decoded.configuration(for: .related)?.relatedSettings.effectiveShowThumbnails == false)
|
||||
#expect(decoded.configuration(for: .chapters)?.chaptersSettings.effectiveShowThumbnails == false)
|
||||
#expect(decoded.configuration(for: .queue)?.queueSettings.effectiveShowHistory == false)
|
||||
|
||||
let tracks = try #require(decoded.configuration(for: .tracks)?.tracksSettings)
|
||||
#expect(tracks.effectiveShowQuality == false)
|
||||
#expect(tracks.effectiveShowSubtitles == false)
|
||||
// Unset fields keep their effective defaults
|
||||
#expect(tracks.effectiveShowAudio == true)
|
||||
#expect(tracks.effectiveShowRate == true)
|
||||
}
|
||||
|
||||
@Test("Typed accessors fall back to defaults for mismatched payloads")
|
||||
func typedAccessorFallbacks() {
|
||||
// An info payload read through the comments accessor yields defaults.
|
||||
let page = PanelPageConfiguration(
|
||||
pageType: .comments,
|
||||
settings: .info(InfoPageSettings(showStatsRow: false))
|
||||
)
|
||||
#expect(page.commentsSettings.effectiveShowAvatars == true)
|
||||
#expect(page.queueSettings.effectiveShowHistory == true)
|
||||
#expect(page.tracksSettings.effectiveShowQuality == true)
|
||||
}
|
||||
|
||||
// MARK: - Backward Compatibility
|
||||
|
||||
@Test("Layout without panelSettings decodes and falls back to default")
|
||||
|
||||
Reference in New Issue
Block a user