// // Swiftfin is subject to the terms of the Mozilla Public // License, v2.0. If a copy of the MPL was not distributed with this // file, you can obtain one at https://mozilla.org/MPL/2.0/. // // Copyright (c) 2026 Jellyfin & Jellyfin Contributors // // Adapted for Tunavelo from Swiftfin 8a515c580e8b96eaeffcecdfeb14a1c97ef9264e Shared/Objects/ContentGroup/SeriesEpisodeContentGroup/SeriesEpisodeContentGroup+SeasonSelector.swift // import DesignSystem import SwiftUI /// The season picker of a series page: one title when there is a single season, otherwise a menu with a picker of the seasons. /// Upstream's router call ("open the season as a library") and its focus-driven track for Apple TV are left out: a menu works with /// the remote, the pointer and touch alike. struct SeasonSelector: View { @Binding var selection: Int? let seasons: [SeriesDetailModel.SeasonChip] private var selectedSeason: SeriesDetailModel.SeasonChip? { seasons.first { $0.number == selection } } private static func words(_ chip: SeriesDetailModel.SeasonChip) -> String { chip.badge.map { chip.title + ", " + $0 } ?? chip.title } var body: some View { if seasons.count == 1, let season = seasons.first { Text(season.title) .tunaveloFont(.episodeTitle) .foregroundStyle(Theme.textPrimary.color) .accessibilityAddTraits(.isHeader) .accessibilityIdentifier(VODID.detailSeason) } else if !seasons.isEmpty { Menu { Picker(VODText.string("vod.seasons"), selection: $selection) { ForEach(seasons) { season in Text(Self.words(season)).tag(Optional(season.number)) } } } label: { HStack(spacing: Theme.Spacing.s) { Text(selectedSeason?.title ?? VODText.string("vod.seasons")) Image(systemName: "chevron.down").accessibilityHidden(true) } .padding(.horizontal, Theme.Spacing.s) } .buttonStyle(.tunavelo(.secondary)) .accessibilityLabel(selectedSeason.map(Self.words) ?? VODText.string("vod.seasons")) .accessibilityHint(VODText.string("vod.seasons")) .accessibilityIdentifier(VODID.detailSeason) } } }