Compare commits

..

2 Commits

Author SHA1 Message Date
Arkadiusz Fal
37a315e75a iOS 14/macOS Big Sur Support 2021-11-30 18:43:21 +01:00
Arkadiusz Fal
f47d8ed752 Remove alpha channel from iOS icons 2021-11-28 11:21:11 +01:00
20 changed files with 282 additions and 448 deletions

View File

@@ -23,7 +23,7 @@ final class NavigationModel: ObservableObject {
} }
} }
@Published var tabSelection: TabSelection! @Published var tabSelection: TabSelection! = .favorites
@Published var presentingAddToPlaylist = false @Published var presentingAddToPlaylist = false
@Published var videoToAddToPlaylist: Video! @Published var videoToAddToPlaylist: Video!

View File

@@ -3,7 +3,7 @@ import Foundation
final class RecentsModel: ObservableObject { final class RecentsModel: ObservableObject {
@Default(.recentlyOpened) var items @Default(.recentlyOpened) var items
@Default(.saveRecents) var saveRecents
func clear() { func clear() {
items = [] items = []
} }
@@ -13,14 +13,6 @@ final class RecentsModel: ObservableObject {
} }
func add(_ item: RecentItem) { func add(_ item: RecentItem) {
if !saveRecents {
clear()
if item.type != .channel {
return
}
}
if let index = items.firstIndex(where: { $0.id == item.id }) { if let index = items.firstIndex(where: { $0.id == item.id }) {
items.remove(at: index) items.remove(at: index)
} }

View File

@@ -40,12 +40,13 @@ extension Defaults.Keys {
static let lastPlayed = Key<PlayerQueueItem?>("lastPlayed") static let lastPlayed = Key<PlayerQueueItem?>("lastPlayed")
static let saveHistory = Key<Bool>("saveHistory", default: true) static let saveHistory = Key<Bool>("saveHistory", default: true)
static let saveRecents = Key<Bool>("saveRecents", default: true)
static let trendingCategory = Key<TrendingCategory>("trendingCategory", default: .default) static let trendingCategory = Key<TrendingCategory>("trendingCategory", default: .default)
static let trendingCountry = Key<Country>("trendingCountry", default: .us) static let trendingCountry = Key<Country>("trendingCountry", default: .us)
static let visibleSections = Key<Set<VisibleSection>>("visibleSections", default: [.favorites, .subscriptions, .trending, .playlists]) #if os(iOS)
static let tabNavigationSection = Key<TabNavigationSectionSetting>("tabNavigationSection", default: .trending)
#endif
} }
enum ResolutionSetting: String, CaseIterable, Defaults.Serializable { enum ResolutionSetting: String, CaseIterable, Defaults.Serializable {
@@ -82,48 +83,8 @@ enum PlayerSidebarSetting: String, CaseIterable, Defaults.Serializable {
} }
} }
enum VisibleSection: String, CaseIterable, Comparable, Defaults.Serializable { #if os(iOS)
case favorites, subscriptions, popular, trending, playlists enum TabNavigationSectionSetting: String, Defaults.Serializable {
case trending, popular
static func from(_ string: String) -> VisibleSection {
allCases.first { $0.rawValue == string }!
} }
#endif
var title: String {
rawValue.localizedCapitalized
}
var tabSelection: TabSelection {
switch self {
case .favorites:
return TabSelection.favorites
case .subscriptions:
return TabSelection.subscriptions
case .popular:
return TabSelection.popular
case .trending:
return TabSelection.trending
case .playlists:
return TabSelection.playlists
}
}
private var sortOrder: Int {
switch self {
case .favorites:
return 0
case .subscriptions:
return 1
case .popular:
return 2
case .trending:
return 3
case .playlists:
return 4
}
}
static func < (lhs: Self, rhs: Self) -> Bool {
lhs.sortOrder < rhs.sortOrder
}
}

View File

@@ -42,6 +42,9 @@ struct FavoritesView: View {
.redrawOn(change: favoritesChanged) .redrawOn(change: favoritesChanged)
#if os(tvOS) #if os(tvOS)
.sheet(isPresented: $presentingEditFavorites) {
EditFavorites()
}
.edgesIgnoringSafeArea(.horizontal) .edgesIgnoringSafeArea(.horizontal)
#else #else
.onDrop(of: [UTType.text], delegate: DropFavoriteOutside(current: $dragging)) .onDrop(of: [UTType.text], delegate: DropFavoriteOutside(current: $dragging))

View File

@@ -1,4 +1,3 @@
import Defaults
import SwiftUI import SwiftUI
#if os(iOS) #if os(iOS)
import Introspect import Introspect
@@ -6,9 +5,6 @@ import SwiftUI
struct AppSidebarNavigation: View { struct AppSidebarNavigation: View {
@EnvironmentObject<AccountsModel> private var accounts @EnvironmentObject<AccountsModel> private var accounts
@Default(.visibleSections) private var visibleSections
#if os(iOS) #if os(iOS)
@EnvironmentObject<NavigationModel> private var navigation @EnvironmentObject<NavigationModel> private var navigation
@State private var didApplyPrimaryViewWorkAround = false @State private var didApplyPrimaryViewWorkAround = false

View File

@@ -8,94 +8,102 @@ struct AppTabNavigation: View {
@EnvironmentObject<RecentsModel> private var recents @EnvironmentObject<RecentsModel> private var recents
@EnvironmentObject<SearchModel> private var search @EnvironmentObject<SearchModel> private var search
@Default(.visibleSections) private var visibleSections @Default(.tabNavigationSection) private var tabNavigationSection
var body: some View { var body: some View {
TabView(selection: navigation.tabSelectionBinding) { TabView(selection: navigation.tabSelectionBinding) {
if visibleSections.contains(.favorites) { NavigationView {
favoritesNavigationView LazyView(FavoritesView())
.toolbar { toolbarContent }
}
.tabItem {
Label("Favorites", systemImage: "heart")
.accessibility(label: Text("Favorites"))
}
.tag(TabSelection.favorites)
if subscriptionsVisible {
NavigationView {
LazyView(SubscriptionsView())
.toolbar { toolbarContent }
}
.tabItem {
Label("Subscriptions", systemImage: "star.circle.fill")
.accessibility(label: Text("Subscriptions"))
}
.tag(TabSelection.subscriptions)
} }
if subscriptionsVisible { if subscriptionsVisible {
subscriptionsNavigationView if accounts.app.supportsPopular {
} if tabNavigationSection == .popular {
popularNavigationView
if visibleSections.contains(.popular), accounts.app.supportsPopular { } else {
popularNavigationView trendingNavigationView
} }
} else {
if visibleSections.contains(.trending) { trendingNavigationView
}
} else {
if accounts.app.supportsPopular {
popularNavigationView
}
trendingNavigationView trendingNavigationView
} }
if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists { if accounts.app.supportsUserPlaylists {
playlistsNavigationView NavigationView {
LazyView(PlaylistsView())
.toolbar { toolbarContent }
}
.tabItem {
Label("Playlists", systemImage: "list.and.film")
.accessibility(label: Text("Playlists"))
}
.tag(TabSelection.playlists)
} }
searchNavigationView NavigationView {
LazyView(SearchView())
}
.tabItem {
Label("Search", systemImage: "magnifyingglass")
.accessibility(label: Text("Search"))
}
.tag(TabSelection.search)
} }
.id(accounts.current?.id ?? "")
.environment(\.navigationStyle, .tab) .environment(\.navigationStyle, .tab)
.background( .sheet(isPresented: $navigation.presentingChannel, onDismiss: {
EmptyView().sheet(isPresented: $navigation.presentingChannel, onDismiss: { if let channel = recents.presentedChannel {
if let channel = recents.presentedChannel { recents.close(RecentItem(from: channel))
recents.close(RecentItem(from: channel)) }
} }) {
}) { if let channel = recents.presentedChannel {
if let channel = recents.presentedChannel { NavigationView {
NavigationView { ChannelVideosView(channel: channel)
ChannelVideosView(channel: channel) .environment(\.inChannelView, true)
.environment(\.inChannelView, true) .environment(\.inNavigationView, true)
.environment(\.inNavigationView, true) .background(playerNavigationLink)
.background(playerNavigationLink)
}
} }
} }
) }
.background( .sheet(isPresented: $navigation.presentingPlaylist, onDismiss: {
EmptyView().sheet(isPresented: $navigation.presentingPlaylist, onDismiss: { if let playlist = recents.presentedPlaylist {
if let playlist = recents.presentedPlaylist { recents.close(RecentItem(from: playlist))
recents.close(RecentItem(from: playlist)) }
} }) {
}) { if let playlist = recents.presentedPlaylist {
if let playlist = recents.presentedPlaylist { NavigationView {
NavigationView { ChannelPlaylistView(playlist: playlist)
ChannelPlaylistView(playlist: playlist) .environment(\.inNavigationView, true)
.environment(\.inNavigationView, true) .background(playerNavigationLink)
.background(playerNavigationLink)
}
} }
} }
)
}
private var favoritesNavigationView: some View {
NavigationView {
LazyView(FavoritesView())
.toolbar { toolbarContent }
} }
.tabItem {
Label("Favorites", systemImage: "heart")
.accessibility(label: Text("Favorites"))
}
.tag(TabSelection.favorites)
}
private var subscriptionsNavigationView: some View {
NavigationView {
LazyView(SubscriptionsView())
.toolbar { toolbarContent }
}
.tabItem {
Label("Subscriptions", systemImage: "star.circle.fill")
.accessibility(label: Text("Subscriptions"))
}
.tag(TabSelection.subscriptions)
} }
private var subscriptionsVisible: Bool { private var subscriptionsVisible: Bool {
visibleSections.contains(.subscriptions) && accounts.app.supportsSubscriptions && !(accounts.current?.anonymous ?? true)
accounts.app.supportsSubscriptions && !(accounts.current?.anonymous ?? true)
} }
private var popularNavigationView: some View { private var popularNavigationView: some View {
@@ -122,30 +130,6 @@ struct AppTabNavigation: View {
.tag(TabSelection.trending) .tag(TabSelection.trending)
} }
private var playlistsNavigationView: some View {
NavigationView {
LazyView(PlaylistsView())
.toolbar { toolbarContent }
}
.tabItem {
Label("Playlists", systemImage: "list.and.film")
.accessibility(label: Text("Playlists"))
}
.tag(TabSelection.playlists)
}
private var searchNavigationView: some View {
NavigationView {
LazyView(SearchView())
.toolbar { toolbarContent }
}
.tabItem {
Label("Search", systemImage: "magnifyingglass")
.accessibility(label: Text("Search"))
}
.tag(TabSelection.search)
}
private var playerNavigationLink: some View { private var playerNavigationLink: some View {
NavigationLink(isActive: $player.playerNavigationLinkActive, destination: { NavigationLink(isActive: $player.playerNavigationLinkActive, destination: {
VideoPlayerView() VideoPlayerView()

View File

@@ -24,7 +24,7 @@ struct ContentView: View {
#endif #endif
var body: some View { var body: some View {
Group { Section {
#if os(iOS) #if os(iOS)
if horizontalSizeClass == .compact { if horizontalSizeClass == .compact {
AppTabNavigation() AppTabNavigation()
@@ -49,70 +49,59 @@ struct ContentView: View {
.environmentObject(subscriptions) .environmentObject(subscriptions)
.environmentObject(thumbnailsModel) .environmentObject(thumbnailsModel)
// iOS 14 has problem with multiple sheets in one view .sheet(isPresented: $navigation.presentingWelcomeScreen) {
// but it's ok when it's in background WelcomeScreen()
.background( .environmentObject(accounts)
EmptyView().sheet(isPresented: $navigation.presentingWelcomeScreen) { .environmentObject(navigation)
WelcomeScreen() }
.environmentObject(accounts)
.environmentObject(navigation)
}
)
#if os(iOS) #if os(iOS)
.background( .fullScreenCover(isPresented: $player.presentingPlayer) {
EmptyView().fullScreenCover(isPresented: $player.presentingPlayer) { VideoPlayerView()
videoPlayer .environmentObject(accounts)
} .environmentObject(instances)
) .environmentObject(navigation)
.environmentObject(player)
.environmentObject(playlists)
.environmentObject(subscriptions)
.environmentObject(thumbnailsModel)
}
#elseif os(macOS) #elseif os(macOS)
.background( .sheet(isPresented: $player.presentingPlayer) {
EmptyView().sheet(isPresented: $player.presentingPlayer) { VideoPlayerView()
videoPlayer .frame(minWidth: 900, minHeight: 800)
.frame(minWidth: 900, minHeight: 800) .environmentObject(accounts)
} .environmentObject(instances)
) .environmentObject(navigation)
.environmentObject(player)
.environmentObject(playlists)
.environmentObject(subscriptions)
.environmentObject(thumbnailsModel)
}
#endif #endif
#if !os(tvOS) #if !os(tvOS)
.handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"])) .handlesExternalEvents(preferring: Set(["*"]), allowing: Set(["*"]))
.onOpenURL(perform: handleOpenedURL) .onOpenURL(perform: handleOpenedURL)
.background( .sheet(isPresented: $navigation.presentingAddToPlaylist) {
EmptyView().sheet(isPresented: $navigation.presentingAddToPlaylist) { AddToPlaylistView(video: navigation.videoToAddToPlaylist)
AddToPlaylistView(video: navigation.videoToAddToPlaylist) .environmentObject(playlists)
.environmentObject(playlists) }
} .sheet(isPresented: $navigation.presentingPlaylistForm) {
) PlaylistFormView(playlist: $navigation.editedPlaylist)
.background( .environmentObject(accounts)
EmptyView().sheet(isPresented: $navigation.presentingPlaylistForm) { .environmentObject(playlists)
PlaylistFormView(playlist: $navigation.editedPlaylist) }
.environmentObject(accounts) .sheet(isPresented: $navigation.presentingSettings, onDismiss: openWelcomeScreenIfAccountEmpty) {
.environmentObject(playlists) SettingsView()
} .environmentObject(accounts)
) .environmentObject(instances)
.background( }
EmptyView().sheet(isPresented: $navigation.presentingSettings, onDismiss: openWelcomeScreenIfAccountEmpty) {
SettingsView()
.environmentObject(accounts)
.environmentObject(instances)
}
)
#endif #endif
} }
private var videoPlayer: some View {
VideoPlayerView()
.environmentObject(accounts)
.environmentObject(instances)
.environmentObject(navigation)
.environmentObject(player)
.environmentObject(playlists)
.environmentObject(subscriptions)
.environmentObject(thumbnailsModel)
}
func configure() { func configure() {
SiestaLog.Category.enabled = .common SiestaLog.Category.enabled = .common
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared) SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDWebImageManager.defaultImageCache = PINCache(name: "stream.yattee.app") SDWebImageManager.defaultImageCache = PINCache(name: "net.yattee.app")
#if !os(macOS) #if !os(macOS)
try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback) try? AVAudioSession.sharedInstance().setCategory(.playback, mode: .moviePlayback)
#endif #endif
@@ -140,20 +129,6 @@ struct ContentView: View {
if !accounts.current.isNil { if !accounts.current.isNil {
player.loadHistoryDetails() player.loadHistoryDetails()
} }
if !Defaults[.saveRecents] {
recents.clear()
}
var section = Defaults[.visibleSections].min()?.tabSelection
#if os(macOS)
if section == .playlists {
section = .search
}
#endif
navigation.tabSelection = section ?? .search
} }
func openWelcomeScreenIfAccountEmpty() { func openWelcomeScreenIfAccountEmpty() {

View File

@@ -1,4 +1,3 @@
import Defaults
import SwiftUI import SwiftUI
struct Sidebar: View { struct Sidebar: View {
@@ -7,8 +6,6 @@ struct Sidebar: View {
@EnvironmentObject<PlaylistsModel> private var playlists @EnvironmentObject<PlaylistsModel> private var playlists
@EnvironmentObject<SubscriptionsModel> private var subscriptions @EnvironmentObject<SubscriptionsModel> private var subscriptions
@Default(.visibleSections) private var visibleSections
var body: some View { var body: some View {
ScrollViewReader { scrollView in ScrollViewReader { scrollView in
List { List {
@@ -19,11 +16,11 @@ struct Sidebar: View {
.id("recentlyOpened") .id("recentlyOpened")
if accounts.api.signedIn { if accounts.api.signedIn {
if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions { if accounts.app.supportsSubscriptions {
AppSidebarSubscriptions() AppSidebarSubscriptions()
} }
if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists { if accounts.app.supportsUserPlaylists {
AppSidebarPlaylists() AppSidebarPlaylists()
} }
} }
@@ -50,33 +47,27 @@ struct Sidebar: View {
var mainNavigationLinks: some View { var mainNavigationLinks: some View {
Section(header: Text("Videos")) { Section(header: Text("Videos")) {
if visibleSections.contains(.favorites) { NavigationLink(destination: LazyView(FavoritesView()), tag: TabSelection.favorites, selection: $navigation.tabSelection) {
NavigationLink(destination: LazyView(FavoritesView()), tag: TabSelection.favorites, selection: $navigation.tabSelection) { Label("Favorites", systemImage: "heart")
Label("Favorites", systemImage: "heart") .accessibility(label: Text("Favorites"))
.accessibility(label: Text("Favorites"))
}
} }
if visibleSections.contains(.subscriptions), if accounts.app.supportsSubscriptions && accounts.signedIn {
accounts.app.supportsSubscriptions && accounts.signedIn
{
NavigationLink(destination: LazyView(SubscriptionsView()), tag: TabSelection.subscriptions, selection: $navigation.tabSelection) { NavigationLink(destination: LazyView(SubscriptionsView()), tag: TabSelection.subscriptions, selection: $navigation.tabSelection) {
Label("Subscriptions", systemImage: "star.circle") Label("Subscriptions", systemImage: "star.circle")
.accessibility(label: Text("Subscriptions")) .accessibility(label: Text("Subscriptions"))
} }
} }
if visibleSections.contains(.popular), accounts.app.supportsPopular { if accounts.app.supportsPopular {
NavigationLink(destination: LazyView(PopularView()), tag: TabSelection.popular, selection: $navigation.tabSelection) { NavigationLink(destination: LazyView(PopularView()), tag: TabSelection.popular, selection: $navigation.tabSelection) {
Label("Popular", systemImage: "arrow.up.right.circle") Label("Popular", systemImage: "arrow.up.right.circle")
.accessibility(label: Text("Popular")) .accessibility(label: Text("Popular"))
} }
} }
if visibleSections.contains(.trending) { NavigationLink(destination: LazyView(TrendingView()), tag: TabSelection.trending, selection: $navigation.tabSelection) {
NavigationLink(destination: LazyView(TrendingView()), tag: TabSelection.trending, selection: $navigation.tabSelection) { Label("Trending", systemImage: "chart.bar")
Label("Trending", systemImage: "chart.bar") .accessibility(label: Text("Trending"))
.accessibility(label: Text("Trending"))
}
} }
NavigationLink(destination: LazyView(SearchView()), tag: TabSelection.search, selection: $navigation.tabSelection) { NavigationLink(destination: LazyView(SearchView()), tag: TabSelection.search, selection: $navigation.tabSelection) {
@@ -87,7 +78,7 @@ struct Sidebar: View {
} }
} }
private func scrollScrollViewToItem(scrollView: ScrollViewProxy, for selection: TabSelection) { func scrollScrollViewToItem(scrollView: ScrollViewProxy, for selection: TabSelection) {
if case .recentlyOpened = selection { if case .recentlyOpened = selection {
scrollView.scrollTo("recentlyOpened") scrollView.scrollTo("recentlyOpened")
} else if case let .playlist(id) = selection { } else if case let .playlist(id) = selection {

View File

@@ -16,10 +16,13 @@ struct PlaybackBar: View {
if player.currentItem != nil { if player.currentItem != nil {
HStack { HStack {
Text(playbackStatus) Text(playbackStatus)
Text("") Text("")
rateMenu rateMenu
} }
.font(.caption2) .font(.caption2)
.foregroundColor(.gray)
Spacer() Spacer()
@@ -56,12 +59,12 @@ struct PlaybackBar: View {
#endif #endif
} }
.transaction { t in t.animation = .none } .transaction { t in t.animation = .none }
.foregroundColor(.gray)
.font(.caption2) .font(.caption2)
} else { } else {
Spacer() Spacer()
} }
} }
.foregroundColor(colorScheme == .dark ? .gray : .black)
.alert(isPresented: $player.presentingErrorDetails) { .alert(isPresented: $player.presentingErrorDetails) {
Alert( Alert(
title: Text("Error"), title: Text("Error"),

View File

@@ -44,11 +44,18 @@ struct PlayerQueueView: View {
} }
ForEach(player.queue) { item in ForEach(player.queue) { item in
PlayerQueueRow(item: item, fullScreen: $fullScreen) let row = PlayerQueueRow(item: item, fullScreen: $fullScreen)
.contextMenu { .contextMenu {
removeButton(item, history: false) removeButton(item, history: false)
removeAllButton(history: false) removeAllButton(history: false)
} }
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
row.swipeActions(edge: .trailing, allowsFullSwipe: true) {
removeButton(item, history: false)
}
} else {
row
}
} }
} }
} }
@@ -58,11 +65,20 @@ struct PlayerQueueView: View {
if !player.history.isEmpty { if !player.history.isEmpty {
Section(header: Text("Played Previously")) { Section(header: Text("Played Previously")) {
ForEach(player.history) { item in ForEach(player.history) { item in
PlayerQueueRow(item: item, history: true, fullScreen: $fullScreen) let row = PlayerQueueRow(item: item, history: true, fullScreen: $fullScreen)
.contextMenu { .contextMenu {
removeButton(item, history: true) removeButton(item, history: true)
removeAllButton(history: true) removeAllButton(history: true)
} }
#if os(iOS)
if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
row.swipeActions(edge: .trailing, allowsFullSwipe: true) {
removeButton(item, history: true)
}
} else {
row
}
#endif
} }
} }
} }
@@ -90,10 +106,18 @@ struct PlayerQueueView: View {
} }
private func removeButton(_ item: PlayerQueueItem, history: Bool) -> some View { private func removeButton(_ item: PlayerQueueItem, history: Bool) -> some View {
Button { if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
removeButtonAction(item, history: history) return Button(role: .destructive) {
} label: { removeButtonAction(item, history: history)
Label("Remove", systemImage: "trash") } label: {
Label("Remove", systemImage: "trash")
}
} else {
return Button {
removeButtonAction(item, history: history)
} label: {
Label("Remove", systemImage: "trash")
}
} }
} }
@@ -102,10 +126,18 @@ struct PlayerQueueView: View {
} }
private func removeAllButton(history: Bool) -> some View { private func removeAllButton(history: Bool) -> some View {
Button { if #available(iOS 15.0, macOS 12.0, tvOS 15.0, *) {
removeAllButtonAction(history: history) return Button(role: .destructive) {
} label: { removeAllButtonAction(history: history)
Label("Remove All", systemImage: "trash.fill") } label: {
Label("Remove All", systemImage: "trash.fill")
}
} else {
return Button {
removeAllButtonAction(history: history)
} label: {
Label("Remove All", systemImage: "trash.fill")
}
} }
} }

View File

@@ -9,18 +9,6 @@ struct RelatedView: View {
Section(header: Text("Related")) { Section(header: Text("Related")) {
ForEach(player.currentVideo!.related) { video in ForEach(player.currentVideo!.related) { video in
PlayerQueueRow(item: PlayerQueueItem(video), fullScreen: .constant(false)) PlayerQueueRow(item: PlayerQueueItem(video), fullScreen: .constant(false))
.contextMenu {
Button {
player.playNext(video)
} label: {
Label("Play Next", systemImage: "text.insert")
}
Button {
player.enqueueVideo(video)
} label: {
Label("Play Last", systemImage: "text.append")
}
}
} }
} }
} }

View File

@@ -318,21 +318,17 @@ struct VideoDetails: View {
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
} }
.background( .sheet(isPresented: $presentingAddToPlaylist) {
EmptyView().sheet(isPresented: $presentingAddToPlaylist) { if let video = video {
if let video = video { AddToPlaylistView(video: video)
AddToPlaylistView(video: video)
}
} }
) }
#if os(iOS) #if os(iOS)
.background( .sheet(isPresented: $presentingShareSheet) {
EmptyView().sheet(isPresented: $presentingShareSheet) { if let shareURL = shareURL {
if let shareURL = shareURL { ShareSheet(activityItems: [shareURL])
ShareSheet(activityItems: [shareURL])
}
} }
) }
#endif #endif
} }

View File

@@ -58,20 +58,14 @@ struct PlaylistsView: View {
.environmentObject(accounts) .environmentObject(accounts)
} }
#else #else
.background( .sheet(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) {
EmptyView() PlaylistFormView(playlist: $createdPlaylist)
.sheet(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) { .environmentObject(accounts)
PlaylistFormView(playlist: $createdPlaylist) }
.environmentObject(accounts) .sheet(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) {
} PlaylistFormView(playlist: $editedPlaylist)
) .environmentObject(accounts)
.background( }
EmptyView()
.sheet(isPresented: $showingEditPlaylist, onDismiss: selectEditedPlaylist) {
PlaylistFormView(playlist: $editedPlaylist)
.environmentObject(accounts)
}
)
#endif #endif
.toolbar { .toolbar {
ToolbarItemGroup { ToolbarItemGroup {

View File

@@ -24,8 +24,6 @@ struct SearchView: View {
@EnvironmentObject<RecentsModel> private var recents @EnvironmentObject<RecentsModel> private var recents
@EnvironmentObject<SearchModel> private var state @EnvironmentObject<SearchModel> private var state
@Default(.saveRecents) private var saveRecents
private var videos = [Video]() private var videos = [Video]()
var items: [ContentItem] { var items: [ContentItem] {
@@ -53,16 +51,14 @@ struct SearchView: View {
ZStack { ZStack {
results results
#if !os(tvOS) if state.query.query != state.queryText, !state.queryText.isEmpty, !state.querySuggestions.collection.isEmpty {
if state.query.query != state.queryText, !state.queryText.isEmpty, !state.querySuggestions.collection.isEmpty { HStack {
HStack { Spacer()
Spacer() SearchSuggestions()
SearchSuggestions() .borderLeading(width: 1, color: Color("ControlsBorderColor"))
.borderLeading(width: 1, color: Color("ControlsBorderColor")) .frame(maxWidth: 280)
.frame(maxWidth: 280)
}
} }
#endif }
} }
#endif #endif
} }
@@ -175,19 +171,12 @@ struct SearchView: View {
updateFavoriteItem() updateFavoriteItem()
} }
} }
#if os(tvOS) #if !os(tvOS)
.searchable(text: $state.queryText) { .ignoresSafeArea(.keyboard, edges: .bottom)
ForEach(state.querySuggestions.collection, id: \.self) { suggestion in .navigationTitle("Search")
Text(suggestion)
.searchCompletion(suggestion)
}
}
#else
.ignoresSafeArea(.keyboard, edges: .bottom)
.navigationTitle("Search")
#endif #endif
#if os(iOS) #if os(iOS)
.navigationBarHidden(!Defaults[.visibleSections].isEmpty || navigationStyle == .sidebar) .navigationBarHidden(true)
#endif #endif
} }
@@ -240,7 +229,7 @@ struct SearchView: View {
} }
private var showRecentQueries: Bool { private var showRecentQueries: Bool {
navigationStyle == .tab && saveRecents && state.queryText.isEmpty navigationStyle == .tab && state.queryText.isEmpty
} }
private var filtersActive: Bool { private var filtersActive: Bool {

View File

@@ -4,100 +4,42 @@ import SwiftUI
struct BrowsingSettings: View { struct BrowsingSettings: View {
@Default(.channelOnThumbnail) private var channelOnThumbnail @Default(.channelOnThumbnail) private var channelOnThumbnail
@Default(.timeOnThumbnail) private var timeOnThumbnail @Default(.timeOnThumbnail) private var timeOnThumbnail
@Default(.saveRecents) private var saveRecents #if os(iOS)
@Default(.saveHistory) private var saveHistory @Default(.tabNavigationSection) private var tabNavigationSection
@Default(.visibleSections) private var visibleSections #endif
var body: some View { var body: some View {
Group { Section(header: SettingsHeader(text: "Browsing"), footer: footer) {
Section(header: SettingsHeader(text: "Browsing")) { Toggle("Display channel names on thumbnails", isOn: $channelOnThumbnail)
Toggle("Show channel name on thumbnail", isOn: $channelOnThumbnail) Toggle("Display video length on thumbnails", isOn: $timeOnThumbnail)
Toggle("Show video length on thumbnail", isOn: $timeOnThumbnail)
Toggle("Save recent queries and channels", isOn: $saveRecents)
Toggle("Save history of played videos", isOn: $saveHistory)
}
Section(header: SettingsHeader(text: "Sections")) {
#if os(macOS)
let list = List(VisibleSection.allCases, id: \.self) { section in
VisibleSectionSelectionRow(
title: section.title,
selected: visibleSections.contains(section)
) { value in
toggleSection(section, value: value)
}
}
Group { #if os(iOS)
if #available(macOS 12.0, *) { preferredTabPicker
list
.listStyle(.inset(alternatesRowBackgrounds: true))
} else {
list
.listStyle(.inset)
}
}
#else
ForEach(VisibleSection.allCases, id: \.self) { section in
VisibleSectionSelectionRow(
title: section.title,
selected: visibleSections.contains(section)
) { value in
toggleSection(section, value: value)
}
}
#endif
}
}
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
}
func toggleSection(_ section: VisibleSection, value: Bool) {
if value {
visibleSections.insert(section)
} else {
visibleSections.remove(section)
}
}
struct VisibleSectionSelectionRow: View {
let title: String
let selected: Bool
var action: (Bool) -> Void
@State private var toggleChecked = false
var body: some View {
Button(action: { action(!selected) }) {
HStack {
#if os(macOS)
Toggle(isOn: $toggleChecked) {
Text(self.title)
Spacer()
}
.onAppear {
toggleChecked = selected
}
.onChange(of: toggleChecked) { new in
action(new)
}
#else
Text(self.title)
Spacer()
if selected {
Image(systemName: "checkmark")
#if os(iOS)
.foregroundColor(.accentColor)
#endif
}
#endif
}
.contentShape(Rectangle())
}
#if !os(tvOS)
.buttonStyle(.plain)
#endif #endif
} }
.frame(minWidth: 0, maxWidth: .infinity, alignment: .leading)
#if os(macOS)
Spacer()
#endif
} }
var footer: some View {
#if os(iOS)
Text("This tab will be displayed when there is no space to display all tabs")
#else
EmptyView()
#endif
}
#if os(iOS)
var preferredTabPicker: some View {
Picker("Preferred tab", selection: $tabNavigationSection) {
Text("Trending").tag(TabNavigationSectionSetting.trending)
Text("Popular").tag(TabNavigationSectionSetting.popular)
}
}
#endif
} }
struct BrowsingSettings_Previews: PreviewProvider { struct BrowsingSettings_Previews: PreviewProvider {

View File

@@ -27,6 +27,7 @@ struct PlaybackSettings: View {
} }
keywordsToggle keywordsToggle
saveHistoryToggle
} }
#else #else
Section(header: SettingsHeader(text: "Source")) { Section(header: SettingsHeader(text: "Source")) {
@@ -44,6 +45,7 @@ struct PlaybackSettings: View {
#endif #endif
keywordsToggle keywordsToggle
saveHistoryToggle
#endif #endif
} }
@@ -107,6 +109,10 @@ struct PlaybackSettings: View {
private var keywordsToggle: some View { private var keywordsToggle: some View {
Toggle("Show video keywords", isOn: $showKeywords) Toggle("Show video keywords", isOn: $showKeywords)
} }
private var saveHistoryToggle: some View {
Toggle("Save history of played videos", isOn: $saveHistory)
}
} }
struct PlaybackSettings_Previews: PreviewProvider { struct PlaybackSettings_Previews: PreviewProvider {

View File

@@ -1,4 +1,3 @@
import Defaults
import Foundation import Foundation
import SwiftUI import SwiftUI
@@ -8,27 +7,19 @@ struct FavoriteButton: View {
@State private var isFavorite = false @State private var isFavorite = false
@Default(.visibleSections) private var visibleSections
var body: some View { var body: some View {
Group { Button {
if visibleSections.contains(.favorites) { favorites.toggle(item)
Button { isFavorite.toggle()
favorites.toggle(item) } label: {
isFavorite.toggle() if isFavorite {
} label: { Label("Remove from Favorites", systemImage: "heart.fill")
if isFavorite {
Label("Remove from Favorites", systemImage: "heart.fill")
} else {
Label("Add to Favorites", systemImage: "heart")
}
}
.onAppear {
isFavorite = favorites.contains(item)
}
} else { } else {
EmptyView() Label("Add to Favorites", systemImage: "heart")
} }
} }
.onAppear {
isFavorite = favorites.contains(item)
}
} }
} }

View File

@@ -36,7 +36,7 @@ struct PlayerControlsView<Content: View>: View {
.foregroundColor(model.currentItem.isNil ? .secondary : .accentColor) .foregroundColor(model.currentItem.isNil ? .secondary : .accentColor)
.lineLimit(1) .lineLimit(1)
Text(model.currentItem?.video?.author ?? "Yattee v\(appVersion) (build \(appBuild))") Text(model.currentItem?.video?.author ?? "Yattee v\(appVersion)")
.fontWeight(model.currentItem.isNil ? .light : .bold) .fontWeight(model.currentItem.isNil ? .light : .bold)
.font(.system(size: 10)) .font(.system(size: 10))
.foregroundColor(.secondary) .foregroundColor(.secondary)
@@ -115,10 +115,6 @@ struct PlayerControlsView<Content: View>: View {
Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "unknown" Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "unknown"
} }
private var appBuild: String {
Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? "unknown"
}
private var progressViewValue: Double { private var progressViewValue: Double {
[model.time?.seconds, model.videoDuration].compactMap { $0 }.min() ?? 0 [model.time?.seconds, model.videoDuration].compactMap { $0 }.min() ?? 0
} }

View File

@@ -2217,7 +2217,7 @@
CODE_SIGN_ENTITLEMENTS = "Open in Yattee/Open in Yattee.entitlements"; CODE_SIGN_ENTITLEMENTS = "Open in Yattee/Open in Yattee.entitlements";
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -2229,7 +2229,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks", "@executable_path/../../../../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 11.0; MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.2; MARKETING_VERSION = 1.2;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-framework", "-framework",
@@ -2251,7 +2251,7 @@
CODE_SIGN_ENTITLEMENTS = "Open in Yattee/Open in Yattee.entitlements"; CODE_SIGN_ENTITLEMENTS = "Open in Yattee/Open in Yattee.entitlements";
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -2263,7 +2263,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
"@executable_path/../../../../Frameworks", "@executable_path/../../../../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 11.0; MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.2; MARKETING_VERSION = 1.2;
OTHER_LDFLAGS = ( OTHER_LDFLAGS = (
"-framework", "-framework",
@@ -2283,7 +2283,7 @@
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Open in Yattee/Info.plist"; INFOPLIST_FILE = "Open in Yattee/Info.plist";
@@ -2315,7 +2315,7 @@
buildSettings = { buildSettings = {
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = "Open in Yattee/Info.plist"; INFOPLIST_FILE = "Open in Yattee/Info.plist";
@@ -2478,7 +2478,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -2509,7 +2509,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -2544,7 +2544,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_APP_SANDBOX = YES; ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@@ -2577,7 +2577,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_APP_SANDBOX = YES; ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@@ -2708,7 +2708,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
@@ -2740,7 +2740,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image"; ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5; CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;

View File

@@ -8,34 +8,29 @@ struct TVNavigationView: View {
@EnvironmentObject<RecentsModel> private var recents @EnvironmentObject<RecentsModel> private var recents
@EnvironmentObject<SearchModel> private var search @EnvironmentObject<SearchModel> private var search
@Default(.visibleSections) private var visibleSections
var body: some View { var body: some View {
TabView(selection: navigation.tabSelectionBinding) { TabView(selection: navigation.tabSelectionBinding) {
if visibleSections.contains(.favorites) { FavoritesView()
FavoritesView() .tabItem { Text("Favorites") }
.tabItem { Text("Favorites") } .tag(TabSelection.favorites)
.tag(TabSelection.favorites)
}
if visibleSections.contains(.subscriptions), accounts.app.supportsSubscriptions { if accounts.app.supportsSubscriptions {
SubscriptionsView() SubscriptionsView()
.tabItem { Text("Subscriptions") } .tabItem { Text("Subscriptions") }
.tag(TabSelection.subscriptions) .tag(TabSelection.subscriptions)
} }
if visibleSections.contains(.popular), accounts.app.supportsPopular { if accounts.app.supportsPopular {
PopularView() PopularView()
.tabItem { Text("Popular") } .tabItem { Text("Popular") }
.tag(TabSelection.popular) .tag(TabSelection.popular)
} }
if visibleSections.contains(.trending) { TrendingView()
TrendingView() .tabItem { Text("Trending") }
.tabItem { Text("Trending") } .tag(TabSelection.trending)
.tag(TabSelection.trending)
}
if visibleSections.contains(.playlists), accounts.app.supportsUserPlaylists { if accounts.app.supportsUserPlaylists {
PlaylistsView() PlaylistsView()
.tabItem { Text("Playlists") } .tabItem { Text("Playlists") }
.tag(TabSelection.playlists) .tag(TabSelection.playlists)