From 791a7ae66ec37b4d08b17742cc91b64c38852784 Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Thu, 5 Aug 2021 11:46:11 -0600 Subject: [PATCH 1/4] Fix support for Swift 5.4 --- Shared/Extensions/SearchBarView.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Shared/Extensions/SearchBarView.swift b/Shared/Extensions/SearchBarView.swift index ac4b8f32..4e565210 100644 --- a/Shared/Extensions/SearchBarView.swift +++ b/Shared/Extensions/SearchBarView.swift @@ -16,13 +16,21 @@ struct SearchBar: View { var body: some View { HStack(spacing: 8) { + // TODO: Clean up the statement as previously done + // in commit 93a25eb9c43eddd03e09df87722c086fb6cb6da4 + // after Swift 5.5 is released. + #if os(iOS) TextField(NSLocalizedString("Search...", comment: ""), text: $text) .padding(8) .padding(.horizontal, 16) - #if os(iOS) .background(Color(.systemGray6)) - #endif .cornerRadius(8) + #else + TextField(NSLocalizedString("Search...", comment: ""), text: $text) + .padding(8) + .padding(.horizontal, 16) + .cornerRadius(8) + #endif if !text.isEmpty { Button(action: { self.text = "" From c0dd7411dbc75a490947245eb911fc30324dccc7 Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Thu, 5 Aug 2021 12:25:03 -0600 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81b0e430..f868ece9 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Check out our [Weblate instance](https://translate.jellyfin.org/projects/swiftfi ## ⚙️ Development -Xcode 13.0 with command line tools. +Xcode 12.5 with command line tools. ### Build Process From ff80c6ff07a61b87ea1b59c63d9a2ba55f9a9973 Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Fri, 6 Aug 2021 11:47:42 -0600 Subject: [PATCH 3/4] Rearrance tvos media buttons --- .../Components/MediaPlayButtonRowView.swift | 47 +++++++++++++++++++ JellyfinPlayer tvOS/MovieItemView.swift | 29 +----------- JellyfinPlayer.xcodeproj/project.pbxproj | 4 ++ 3 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 JellyfinPlayer tvOS/Components/MediaPlayButtonRowView.swift diff --git a/JellyfinPlayer tvOS/Components/MediaPlayButtonRowView.swift b/JellyfinPlayer tvOS/Components/MediaPlayButtonRowView.swift new file mode 100644 index 00000000..c50ec266 --- /dev/null +++ b/JellyfinPlayer tvOS/Components/MediaPlayButtonRowView.swift @@ -0,0 +1,47 @@ +// + /* + * 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 2021 Aiden Vigue & Jellyfin Contributors + */ + +import SwiftUI + +struct MediaPlayButtonRowView: View { + + @ObservedObject var viewModel: DetailItemViewModel + @State var wrappedScrollView: UIScrollView? + + var body: some View { + HStack { + VStack { + NavigationLink(destination: VideoPlayerView(item: viewModel.item)) { + MediaViewActionButton(icon: "play.fill", scrollView: $wrappedScrollView) + } + Text(viewModel.item.getItemProgressString() != "" ? "\(viewModel.item.getItemProgressString()) left" : "Play") + .font(.caption) + } + VStack { + Button { + viewModel.updateWatchState() + } label: { + MediaViewActionButton(icon: "eye.fill", scrollView: $wrappedScrollView, iconColor: viewModel.isWatched ? .red : .white) + } + Text(viewModel.isWatched ? "Unwatch" : "Mark Watched") + .font(.caption) + } + VStack { + Button { + viewModel.updateFavoriteState() + } label: { + MediaViewActionButton(icon: "heart.fill", scrollView: $wrappedScrollView, iconColor: viewModel.isFavorited ? .red : .white) + } + Text(viewModel.isFavorited ? "Unfavorite" : "Favorite") + .font(.caption) + } + Spacer() + } + } +} diff --git a/JellyfinPlayer tvOS/MovieItemView.swift b/JellyfinPlayer tvOS/MovieItemView.swift index f163cac8..fe3be443 100644 --- a/JellyfinPlayer tvOS/MovieItemView.swift +++ b/JellyfinPlayer tvOS/MovieItemView.swift @@ -129,34 +129,7 @@ struct MovieItemView: View { .fontWeight(.medium) .foregroundColor(.primary) - HStack { - VStack { - Button { - viewModel.updateFavoriteState() - } label: { - MediaViewActionButton(icon: "heart.fill", scrollView: $wrappedScrollView, iconColor: viewModel.isFavorited ? .red : .white) - } - Text(viewModel.isFavorited ? "Unfavorite" : "Favorite") - .font(.caption) - } - VStack { - NavigationLink(destination: VideoPlayerView(item: viewModel.item)) { - MediaViewActionButton(icon: "play.fill", scrollView: $wrappedScrollView) - } - Text(viewModel.item.getItemProgressString() != "" ? "\(viewModel.item.getItemProgressString()) left" : "Play") - .font(.caption) - } - VStack { - Button { - viewModel.updateWatchState() - } label: { - MediaViewActionButton(icon: "eye.fill", scrollView: $wrappedScrollView, iconColor: viewModel.isWatched ? .red : .white) - } - Text(viewModel.isWatched ? "Unwatch" : "Mark Watched") - .font(.caption) - } - Spacer() - } + MediaPlayButtonRowView(viewModel: self.viewModel, wrappedScrollView: self.wrappedScrollView) .padding(.top, 15) .addFocusGuide(using: focusBag, name: "actionButtons", destinations: [.bottom: "moreLikeThis"], debug: false) } diff --git a/JellyfinPlayer.xcodeproj/project.pbxproj b/JellyfinPlayer.xcodeproj/project.pbxproj index b12ec6e0..c07269ae 100644 --- a/JellyfinPlayer.xcodeproj/project.pbxproj +++ b/JellyfinPlayer.xcodeproj/project.pbxproj @@ -196,6 +196,7 @@ 62EC353226766849000E9F2D /* SessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC352E267666A5000E9F2D /* SessionManager.swift */; }; 62EC353426766B03000E9F2D /* DeviceRotationViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC353326766B03000E9F2D /* DeviceRotationViewModifier.swift */; }; AE8C3159265D6F90008AA076 /* bitrates.json in Resources */ = {isa = PBXBuildFile; fileRef = AE8C3158265D6F90008AA076 /* bitrates.json */; }; + E100720726BDABC100CE3E31 /* MediaPlayButtonRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E100720626BDABC100CE3E31 /* MediaPlayButtonRowView.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -374,6 +375,7 @@ BEEC50E7EFD4848C0E320941 /* Pods-JellyfinPlayer iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JellyfinPlayer iOS.release.xcconfig"; path = "Target Support Files/Pods-JellyfinPlayer iOS/Pods-JellyfinPlayer iOS.release.xcconfig"; sourceTree = ""; }; D79953919FED0C4DF72BA578 /* Pods-JellyfinPlayer tvOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JellyfinPlayer tvOS.release.xcconfig"; path = "Target Support Files/Pods-JellyfinPlayer tvOS/Pods-JellyfinPlayer tvOS.release.xcconfig"; sourceTree = ""; }; DE5004F745B19E28744A7DE7 /* Pods-JellyfinPlayer tvOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-JellyfinPlayer tvOS.debug.xcconfig"; path = "Target Support Files/Pods-JellyfinPlayer tvOS/Pods-JellyfinPlayer tvOS.debug.xcconfig"; sourceTree = ""; }; + E100720626BDABC100CE3E31 /* MediaPlayButtonRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaPlayButtonRowView.swift; sourceTree = ""; }; EBFE1F64394BCC2EFFF1610D /* Pods_JellyfinPlayer_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JellyfinPlayer_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ @@ -581,6 +583,7 @@ 536D3D87267C17350004248C /* PublicUserButton.swift */, 53116A18268B947A003024C9 /* PlainLinkButton.swift */, 53272531268BF09D0035FBF1 /* MediaViewActionButton.swift */, + E100720626BDABC100CE3E31 /* MediaPlayButtonRowView.swift */, ); path = Components; sourceTree = ""; @@ -1084,6 +1087,7 @@ 62E632F4267D54030063E547 /* DetailItemViewModel.swift in Sources */, 6267B3D826710B9800A7371D /* CollectionExtensions.swift in Sources */, 62E632E7267D3F5B0063E547 /* EpisodeItemViewModel.swift in Sources */, + E100720726BDABC100CE3E31 /* MediaPlayButtonRowView.swift in Sources */, 535870A52669D8AE00D05A09 /* ParallaxHeader.swift in Sources */, 53272532268BF09D0035FBF1 /* MediaViewActionButton.swift in Sources */, 531690F0267ABF72005D8AB9 /* NextUpView.swift in Sources */, From e04320b26068ba997ef23ab0d9e4addf57c00076 Mon Sep 17 00:00:00 2001 From: Ethan Pippin Date: Fri, 6 Aug 2021 11:58:20 -0600 Subject: [PATCH 4/4] Add to show view --- JellyfinPlayer tvOS/MovieItemView.swift | 2 +- JellyfinPlayer tvOS/SeriesItemView.swift | 31 ++---------------------- 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/JellyfinPlayer tvOS/MovieItemView.swift b/JellyfinPlayer tvOS/MovieItemView.swift index fe3be443..20967097 100644 --- a/JellyfinPlayer tvOS/MovieItemView.swift +++ b/JellyfinPlayer tvOS/MovieItemView.swift @@ -129,7 +129,7 @@ struct MovieItemView: View { .fontWeight(.medium) .foregroundColor(.primary) - MediaPlayButtonRowView(viewModel: self.viewModel, wrappedScrollView: self.wrappedScrollView) + MediaPlayButtonRowView(viewModel: viewModel, wrappedScrollView: wrappedScrollView) .padding(.top, 15) .addFocusGuide(using: focusBag, name: "actionButtons", destinations: [.bottom: "moreLikeThis"], debug: false) } diff --git a/JellyfinPlayer tvOS/SeriesItemView.swift b/JellyfinPlayer tvOS/SeriesItemView.swift index cab03c10..922a25d8 100644 --- a/JellyfinPlayer tvOS/SeriesItemView.swift +++ b/JellyfinPlayer tvOS/SeriesItemView.swift @@ -135,35 +135,8 @@ struct SeriesItemView: View { .fontWeight(.medium) .foregroundColor(.primary) - HStack { - VStack { - Button { - viewModel.updateFavoriteState() - } label: { - MediaViewActionButton(icon: "heart.fill", scrollView: $wrappedScrollView, iconColor: viewModel.isFavorited ? .red : .white) - }.prefersDefaultFocus(in: namespace) - Text(viewModel.isFavorited ? "Unfavorite" : "Favorite") - .font(.caption) - } - if viewModel.nextUpItem != nil { - VStack { - NavigationLink(destination: VideoPlayerView(item: viewModel.nextUpItem!)) { - MediaViewActionButton(icon: "play.fill", scrollView: $wrappedScrollView) - } - Text("Play • \(viewModel.nextUpItem!.getEpisodeLocator())") - .font(.caption) - } - } - VStack { - Button { - viewModel.updateWatchState() - } label: { - MediaViewActionButton(icon: "eye.fill", scrollView: $wrappedScrollView, iconColor: viewModel.isWatched ? .red : .white) - } - Text(viewModel.isWatched ? "Unwatch" : "Mark Watched") - .font(.caption) - } - }.padding(.top, 15) + MediaPlayButtonRowView(viewModel: viewModel, wrappedScrollView: wrappedScrollView) + .padding(.top, 15) Spacer() } }.padding(.top, 50)