From 72d735e9627c34398dd22823ff776f9359ff052f Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Wed, 10 Nov 2021 23:05:59 +0100 Subject: [PATCH] Minor improvements --- Shared/Player/VideoDetails.swift | 3 +- Shared/Playlists/AddToPlaylistView.swift | 32 +++---- Shared/Playlists/PlaylistFormView.swift | 88 ++++++++++--------- Shared/Settings/AccountForm.swift | 2 - Shared/Trending/TrendingView.swift | 52 +++++------ Shared/Videos/VideoCell.swift | 1 - Shared/Views/ChannelPlaylistView.swift | 5 +- Shared/Views/OpenSettingsButton.swift | 5 +- Yattee.xcodeproj/project.pbxproj | 6 +- .../xcschemes/Periphery (tvOS).xcscheme | 67 ++++++++++++++ macOS/Settings/InstancesSettings.swift | 1 - 11 files changed, 167 insertions(+), 95 deletions(-) create mode 100644 Yattee.xcodeproj/xcshareddata/xcschemes/Periphery (tvOS).xcscheme diff --git a/Shared/Player/VideoDetails.swift b/Shared/Player/VideoDetails.swift index 468ec27b..b42da1fe 100644 --- a/Shared/Player/VideoDetails.swift +++ b/Shared/Player/VideoDetails.swift @@ -23,7 +23,6 @@ struct VideoDetails: View { @EnvironmentObject private var accounts @EnvironmentObject private var player - @EnvironmentObject private var playlists @EnvironmentObject private var subscriptions @Default(.showKeywords) private var showKeywords @@ -263,7 +262,7 @@ struct VideoDetails: View { if let video = player.currentVideo { HStack { ShareButton( - contentItem: ContentItem(video: video), + contentItem: contentItem, presentingShareSheet: $presentingShareSheet, shareURL: $shareURL ) diff --git a/Shared/Playlists/AddToPlaylistView.swift b/Shared/Playlists/AddToPlaylistView.swift index 4304eb6f..16099acf 100644 --- a/Shared/Playlists/AddToPlaylistView.swift +++ b/Shared/Playlists/AddToPlaylistView.swift @@ -126,24 +126,26 @@ struct AddToPlaylistView: View { .padding(.horizontal) } - private var selectPlaylistButton: some View { - Button(selectedPlaylist?.title ?? "Select playlist") { - guard selectedPlaylist != nil else { - return - } - - selectedPlaylistID = model.all.next(after: selectedPlaylist!)!.id - } - .contextMenu { - ForEach(model.all) { playlist in - Button(playlist.title) { - selectedPlaylistID = playlist.id + #if os(tvOS) + private var selectPlaylistButton: some View { + Button(selectedPlaylist?.title ?? "Select playlist") { + guard selectedPlaylist != nil else { + return // swiftlint:disable:this implicit_return } - } - Button("Cancel", role: .cancel) {} + selectedPlaylistID = model.all.next(after: selectedPlaylist!)!.id + } + .contextMenu { + ForEach(model.all) { playlist in + Button(playlist.title) { + selectedPlaylistID = playlist.id + } + } + + Button("Cancel", role: .cancel) {} + } } - } + #endif private func addToPlaylist() { guard let id = selectedPlaylist?.id else { diff --git a/Shared/Playlists/PlaylistFormView.swift b/Shared/Playlists/PlaylistFormView.swift index f14b629c..6544ad25 100644 --- a/Shared/Playlists/PlaylistFormView.swift +++ b/Shared/Playlists/PlaylistFormView.swift @@ -95,59 +95,61 @@ struct PlaylistFormView: View { #endif } - var header: some View { - HStack(alignment: .center) { - Text(editing ? "Edit Playlist" : "Create Playlist") - .font(.title2.bold()) + #if os(tvOS) + var header: some View { + HStack(alignment: .center) { + Text(editing ? "Edit Playlist" : "Create Playlist") + .font(.title2.bold()) - Spacer() - - #if !os(tvOS) - Button("Cancel") { - dismiss() - } - .keyboardShortcut(.cancelAction) - #endif - } - .padding(.horizontal) - } - - var form: some View { - VStack(alignment: .trailing) { - VStack { - Text("Name") - .frame(maxWidth: .infinity, alignment: .leading) - - TextField("Playlist Name", text: $name, onCommit: validate) - } - - HStack { - Text("Visibility") - .frame(maxWidth: .infinity, alignment: .leading) - - visibilityFormItem - } - .padding(.top, 10) - - HStack { Spacer() - Button("Save", action: submitForm).disabled(!valid) + #if !os(tvOS) + Button("Cancel") { + dismiss() + } + .keyboardShortcut(.cancelAction) + #endif } - .padding(.top, 40) + .padding(.horizontal) + } + + var form: some View { + VStack(alignment: .trailing) { + VStack { + Text("Name") + .frame(maxWidth: .infinity, alignment: .leading) + + TextField("Playlist Name", text: $name, onCommit: validate) + } + + HStack { + Text("Visibility") + .frame(maxWidth: .infinity, alignment: .leading) + + visibilityFormItem + } + .padding(.top, 10) - if editing { - Divider() HStack { - Text("Delete playlist") - .font(.title2.bold()) Spacer() - deletePlaylistButton + + Button("Save", action: submitForm).disabled(!valid) + } + .padding(.top, 40) + + if editing { + Divider() + HStack { + Text("Delete playlist") + .font(.title2.bold()) + Spacer() + deletePlaylistButton + } } } + .padding(.horizontal) } - .padding(.horizontal) - } + #endif func initializeForm() { focused = true diff --git a/Shared/Settings/AccountForm.swift b/Shared/Settings/AccountForm.swift index 86a6de95..11865bf3 100644 --- a/Shared/Settings/AccountForm.swift +++ b/Shared/Settings/AccountForm.swift @@ -17,8 +17,6 @@ struct AccountForm: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var instances - var body: some View { VStack { Group { diff --git a/Shared/Trending/TrendingView.swift b/Shared/Trending/TrendingView.swift index 0979703a..e562c303 100644 --- a/Shared/Trending/TrendingView.swift +++ b/Shared/Trending/TrendingView.swift @@ -124,37 +124,39 @@ struct TrendingView: View { } } - private var toolbar: some View { - HStack { - if accounts.app.supportsTrendingCategories { + #if os(tvOS) + private var toolbar: some View { + HStack { + if accounts.app.supportsTrendingCategories { + HStack { + Text("Category") + .foregroundColor(.secondary) + + categoryButton + } + } + + #if os(iOS) + Spacer() + #endif + HStack { - Text("Category") + Text("Country") .foregroundColor(.secondary) - categoryButton + countryButton } + + #if os(tvOS) + if let favoriteItem = favoriteItem { + FavoriteButton(item: favoriteItem) + .id(favoriteItem.id) + .labelStyle(.iconOnly) + } + #endif } - - #if os(iOS) - Spacer() - #endif - - HStack { - Text("Country") - .foregroundColor(.secondary) - - countryButton - } - - #if os(tvOS) - if let favoriteItem = favoriteItem { - FavoriteButton(item: favoriteItem) - .id(favoriteItem.id) - .labelStyle(.iconOnly) - } - #endif } - } + #endif private var categoryButton: some View { #if os(tvOS) diff --git a/Shared/Videos/VideoCell.swift b/Shared/Videos/VideoCell.swift index 8a7a0a5a..63727a4d 100644 --- a/Shared/Videos/VideoCell.swift +++ b/Shared/Videos/VideoCell.swift @@ -4,7 +4,6 @@ import SwiftUI struct VideoCell: View { var video: Video - @State private var mediumQualityThumbnail = false @Environment(\.inNavigationView) private var inNavigationView diff --git a/Shared/Views/ChannelPlaylistView.swift b/Shared/Views/ChannelPlaylistView.swift index 6adffb15..b42d2857 100644 --- a/Shared/Views/ChannelPlaylistView.swift +++ b/Shared/Views/ChannelPlaylistView.swift @@ -8,8 +8,9 @@ struct ChannelPlaylistView: View { @StateObject private var store = Store() - @Environment(\.dismiss) private var dismiss - @Environment(\.inNavigationView) private var inNavigationView + #if os(iOS) + @Environment(\.inNavigationView) private var inNavigationView + #endif @EnvironmentObject private var accounts diff --git a/Shared/Views/OpenSettingsButton.swift b/Shared/Views/OpenSettingsButton.swift index 7b8d69e3..f78dfd8c 100644 --- a/Shared/Views/OpenSettingsButton.swift +++ b/Shared/Views/OpenSettingsButton.swift @@ -2,7 +2,10 @@ import SwiftUI struct OpenSettingsButton: View { @Environment(\.dismiss) private var dismiss - @EnvironmentObject private var navigation + + #if !os(macOS) + @EnvironmentObject private var navigation + #endif var body: some View { Button { diff --git a/Yattee.xcodeproj/project.pbxproj b/Yattee.xcodeproj/project.pbxproj index f56ae8d0..b2cc2287 100644 --- a/Yattee.xcodeproj/project.pbxproj +++ b/Yattee.xcodeproj/project.pbxproj @@ -1612,7 +1612,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "periphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (iOS)\" \\\n --targets \"Yattee (iOS)\" \\\n --retain-objc-accessible \\\n --retain-public \\\n -- -destination \"platform=iOS\\ Simulator,name=iPhone\\ 8,OS=15.0\"\n"; + shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (iOS)\" \\\n --targets \"Yattee (iOS)\" \\\n --retain-objc-accessible \\\n --retain-public \\\n -- -destination \"platform=iOS\\ Simulator,name=iPhone\\ 8,OS=15.0\"\n"; }; 37CC3F48270CE89B00608308 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -1680,7 +1680,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "periphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (macOS)\" \\\n --targets \"Yattee (macOS)\" \\\n --retain-objc-accessible \\\n --retain-public\n"; + shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (macOS)\" \\\n --targets \"Yattee (macOS)\" \\\n --retain-objc-accessible \\\n --retain-public\n"; }; 37FD43EF2704A7780073EE42 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -1697,7 +1697,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "periphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (Apple TV)\" \\\n --targets \"Yattee (Apple TV)\" \\\n --retain-objc-accessible \\\n --retain-public\n"; + shellScript = "if test -d \"/opt/homebrew/bin/\"; then\n PATH=\"/opt/homebrew/bin/:${PATH}\"\nfi\n\nperiphery scan \\\n --project \"Yattee.xcodeproj\" \\\n --schemes \"Yattee (tvOS)\" \\\n --targets \"Yattee (tvOS)\" \\\n --retain-objc-accessible \\\n --retain-public\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/Yattee.xcodeproj/xcshareddata/xcschemes/Periphery (tvOS).xcscheme b/Yattee.xcodeproj/xcshareddata/xcschemes/Periphery (tvOS).xcscheme new file mode 100644 index 00000000..f1032a8e --- /dev/null +++ b/Yattee.xcodeproj/xcshareddata/xcschemes/Periphery (tvOS).xcscheme @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/macOS/Settings/InstancesSettings.swift b/macOS/Settings/InstancesSettings.swift index bcc6fd88..f3d014e4 100644 --- a/macOS/Settings/InstancesSettings.swift +++ b/macOS/Settings/InstancesSettings.swift @@ -15,7 +15,6 @@ struct InstancesSettings: View { @State private var frontendURL = "" @EnvironmentObject private var accounts - @EnvironmentObject private var model @Default(.instances) private var instances