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..20967097 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: 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) 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 */,