Replace per-page corner regions with one "Below Video" picker

The corner layout's below-video host is the portrait info panel, not a
page host: it can render only Info, plus Comments as the panel's pill on
iOS. The page editor still offered "Below Video" for every page, so
assigning Related there was accepted, stored, listed as such, and then
silently rendered in the side column.

- The Layout section gains a "Below Video" picker in corner mode:
  Nothing / Info / Info and Comments (macOS offers the first two). It
  writes the info/comments regions; the per-page Location section and
  its strings are gone.
- PanelSettings.normalizedPages clamps regions to what the host can
  render (only info/comments below, comments only together with info),
  so older presets self-correct. effectiveRegion(for:) resolves the
  platform-specific placement and is used by both the pages list labels
  and CornerPlayerLayout, replacing its own region checks.
- The layout schematic drops the below-video block for "Nothing"; the
  corner-mode footer explains the constraint.
- Tests cover the picker round-trip and the clamping.
This commit is contained in:
Arkadiusz Fal
2026-09-27 20:05:20 +02:00
parent 7f74b50e94
commit 0bfbd47882
7 changed files with 248 additions and 90 deletions

View File

@@ -279,17 +279,48 @@ struct PanelSettingsTests {
#expect(settings.pages.map(\.pageType) == PanelSettings.default.pages.map(\.pageType))
}
@Test("Region assignment and layout mode round-trip through Codable")
func regionAndLayoutModeRoundTrip() throws {
@Test("Below-video content and layout mode round-trip through Codable")
func belowVideoContentAndLayoutModeRoundTrip() throws {
var settings = PanelSettings.default
settings.layoutMode = .corner
settings.setRegion(.belowVideo, for: .related)
#expect(settings.configuration(for: .related)?.region == .belowVideo)
#expect(settings.enabledPages(in: .primary).map(\.pageType) == [.chapters, .queue])
#expect(settings.belowVideoContent == .infoAndComments)
settings.belowVideoContent = .info
#expect(settings.configuration(for: .info)?.region == .belowVideo)
#expect(settings.configuration(for: .comments)?.region == .primary)
#expect(settings.enabledPages(in: .primary).map(\.pageType) == [.comments, .related, .chapters, .queue])
let data = try JSONEncoder().encode(settings)
let decoded = try JSONDecoder().decode(PanelSettings.self, from: data)
#expect(decoded.effectiveLayoutMode == .corner)
#expect(decoded.configuration(for: .related)?.region == .belowVideo)
#expect(decoded.belowVideoContent == .info)
settings.belowVideoContent = .nothing
#expect(settings.enabledPages(in: .belowVideo).isEmpty)
#expect(settings.enabledPages(in: .primary).map(\.pageType) == [.info, .comments, .related, .chapters, .queue])
}
@Test("Pages the below-video host cannot render are clamped to the side column")
func unhostableBelowVideoRegionsClamp() {
// Older presets could assign any page below the video.
var settings = PanelSettings(pages: [
PanelPageConfiguration(pageType: .info, region: .primary),
PanelPageConfiguration(pageType: .comments, region: .belowVideo),
PanelPageConfiguration(pageType: .related, region: .belowVideo),
PanelPageConfiguration(pageType: .chapters, region: .belowVideo),
PanelPageConfiguration(pageType: .queue, region: .belowVideo),
])
#expect(settings.belowVideoContent == .nothing)
#expect(settings.enabledPages(in: .belowVideo).isEmpty)
#expect(settings.effectiveRegion(for: .related) == .primary)
// Comments may sit below only together with info.
settings.belowVideoContent = .infoAndComments
#expect(settings.enabledPages(in: .belowVideo).map(\.pageType) == [.info, .comments])
#expect(settings.enabledPages(in: .primary).map(\.pageType) == [.related, .chapters, .queue])
settings.pages[0].region = .primary
#expect(settings.belowVideoContent == .nothing)
#expect(settings.effectiveRegion(for: .comments) == .primary)
}
}