Merge pull request #129 from LePips/tvos-rearrange-media-buttons

UX - TvOS Rearrange Media Buttons
This commit is contained in:
aiden 3 2021-08-06 16:16:05 -06:00 committed by GitHub
commit 7ca106f6fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 57 deletions

View File

@ -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()
}
}
}

View File

@ -129,34 +129,7 @@ struct MovieItemView: View {
.fontWeight(.medium) .fontWeight(.medium)
.foregroundColor(.primary) .foregroundColor(.primary)
HStack { MediaPlayButtonRowView(viewModel: viewModel, wrappedScrollView: wrappedScrollView)
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()
}
.padding(.top, 15) .padding(.top, 15)
.addFocusGuide(using: focusBag, name: "actionButtons", destinations: [.bottom: "moreLikeThis"], debug: false) .addFocusGuide(using: focusBag, name: "actionButtons", destinations: [.bottom: "moreLikeThis"], debug: false)
} }

View File

@ -135,35 +135,8 @@ struct SeriesItemView: View {
.fontWeight(.medium) .fontWeight(.medium)
.foregroundColor(.primary) .foregroundColor(.primary)
HStack { MediaPlayButtonRowView(viewModel: viewModel, wrappedScrollView: wrappedScrollView)
VStack { .padding(.top, 15)
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)
Spacer() Spacer()
} }
}.padding(.top, 50) }.padding(.top, 50)

View File

@ -196,6 +196,7 @@
62EC353226766849000E9F2D /* SessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC352E267666A5000E9F2D /* SessionManager.swift */; }; 62EC353226766849000E9F2D /* SessionManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC352E267666A5000E9F2D /* SessionManager.swift */; };
62EC353426766B03000E9F2D /* DeviceRotationViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC353326766B03000E9F2D /* DeviceRotationViewModifier.swift */; }; 62EC353426766B03000E9F2D /* DeviceRotationViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC353326766B03000E9F2D /* DeviceRotationViewModifier.swift */; };
AE8C3159265D6F90008AA076 /* bitrates.json in Resources */ = {isa = PBXBuildFile; fileRef = AE8C3158265D6F90008AA076 /* bitrates.json */; }; 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 */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy 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 = "<group>"; }; 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 = "<group>"; };
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 = "<group>"; }; 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 = "<group>"; };
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 = "<group>"; }; 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 = "<group>"; };
E100720626BDABC100CE3E31 /* MediaPlayButtonRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaPlayButtonRowView.swift; sourceTree = "<group>"; };
EBFE1F64394BCC2EFFF1610D /* Pods_JellyfinPlayer_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JellyfinPlayer_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EBFE1F64394BCC2EFFF1610D /* Pods_JellyfinPlayer_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_JellyfinPlayer_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */ /* End PBXFileReference section */
@ -581,6 +583,7 @@
536D3D87267C17350004248C /* PublicUserButton.swift */, 536D3D87267C17350004248C /* PublicUserButton.swift */,
53116A18268B947A003024C9 /* PlainLinkButton.swift */, 53116A18268B947A003024C9 /* PlainLinkButton.swift */,
53272531268BF09D0035FBF1 /* MediaViewActionButton.swift */, 53272531268BF09D0035FBF1 /* MediaViewActionButton.swift */,
E100720626BDABC100CE3E31 /* MediaPlayButtonRowView.swift */,
); );
path = Components; path = Components;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1084,6 +1087,7 @@
62E632F4267D54030063E547 /* DetailItemViewModel.swift in Sources */, 62E632F4267D54030063E547 /* DetailItemViewModel.swift in Sources */,
6267B3D826710B9800A7371D /* CollectionExtensions.swift in Sources */, 6267B3D826710B9800A7371D /* CollectionExtensions.swift in Sources */,
62E632E7267D3F5B0063E547 /* EpisodeItemViewModel.swift in Sources */, 62E632E7267D3F5B0063E547 /* EpisodeItemViewModel.swift in Sources */,
E100720726BDABC100CE3E31 /* MediaPlayButtonRowView.swift in Sources */,
535870A52669D8AE00D05A09 /* ParallaxHeader.swift in Sources */, 535870A52669D8AE00D05A09 /* ParallaxHeader.swift in Sources */,
53272532268BF09D0035FBF1 /* MediaViewActionButton.swift in Sources */, 53272532268BF09D0035FBF1 /* MediaViewActionButton.swift in Sources */,
531690F0267ABF72005D8AB9 /* NextUpView.swift in Sources */, 531690F0267ABF72005D8AB9 /* NextUpView.swift in Sources */,