From f7b35925b42c88fa1fe87b59add02ae73b035ca8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Tue, 28 Feb 2023 22:13:39 +0100 Subject: [PATCH] Change syntax to overcome compiler issue --- Model/Channel.swift | 4 ++++ Shared/Channels/ChannelVideosView.swift | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Model/Channel.swift b/Model/Channel.swift index fcfb6d3f..044ed12d 100644 --- a/Model/Channel.swift +++ b/Model/Channel.swift @@ -62,6 +62,10 @@ struct Channel: Identifiable, Hashable { return "person.3" } } + + var alwaysAvailable: Bool { + self == .videos || self == .playlists + } } struct Tab: Identifiable, Hashable { diff --git a/Shared/Channels/ChannelVideosView.swift b/Shared/Channels/ChannelVideosView.swift index ed207f5b..ff8792ac 100644 --- a/Shared/Channels/ChannelVideosView.swift +++ b/Shared/Channels/ChannelVideosView.swift @@ -322,7 +322,7 @@ struct ChannelVideosView: View { Picker("Content type", selection: $contentType) { if let channel = presentedChannel { ForEach(Channel.ContentType.allCases, id: \.self) { type in - if type == .videos || type == .playlists || channel.hasData(for: type) { + if typeAvailable(type) { Label(type.description, systemImage: type.systemImage).tag(type) } } @@ -330,6 +330,10 @@ struct ChannelVideosView: View { } } + private func typeAvailable(_ type: Channel.ContentType) -> Bool { + type.alwaysAvailable || (presentedChannel?.hasData(for: type) ?? false) + } + private var resource: Resource? { guard let channel = presentedChannel else { return nil }