add SeasonItemViewModel
This commit is contained in:
parent
4fb792ec24
commit
3d22456968
|
@ -127,6 +127,8 @@
|
||||||
62E632E4267D3BA60063E547 /* MovieItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E2267D3BA60063E547 /* MovieItemViewModel.swift */; };
|
62E632E4267D3BA60063E547 /* MovieItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E2267D3BA60063E547 /* MovieItemViewModel.swift */; };
|
||||||
62E632E6267D3F5B0063E547 /* EpisodeItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */; };
|
62E632E6267D3F5B0063E547 /* EpisodeItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */; };
|
||||||
62E632E7267D3F5B0063E547 /* EpisodeItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */; };
|
62E632E7267D3F5B0063E547 /* EpisodeItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */; };
|
||||||
|
62E632E9267D3FF50063E547 /* SeasonItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E8267D3FF50063E547 /* SeasonItemViewModel.swift */; };
|
||||||
|
62E632EA267D3FF50063E547 /* SeasonItemViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62E632E8267D3FF50063E547 /* SeasonItemViewModel.swift */; };
|
||||||
62EC3527267665D8000E9F2D /* MobileVLCKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53D5E3DC264B47EE00BADDC8 /* MobileVLCKit.xcframework */; };
|
62EC3527267665D8000E9F2D /* MobileVLCKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53D5E3DC264B47EE00BADDC8 /* MobileVLCKit.xcframework */; };
|
||||||
62EC3528267665D8000E9F2D /* MobileVLCKit.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 53D5E3DC264B47EE00BADDC8 /* MobileVLCKit.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
62EC3528267665D8000E9F2D /* MobileVLCKit.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 53D5E3DC264B47EE00BADDC8 /* MobileVLCKit.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
62EC352C26766675000E9F2D /* ServerEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC352B26766675000E9F2D /* ServerEnvironment.swift */; };
|
62EC352C26766675000E9F2D /* ServerEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62EC352B26766675000E9F2D /* ServerEnvironment.swift */; };
|
||||||
|
@ -280,6 +282,7 @@
|
||||||
62E632DF267D30CA0063E547 /* LibraryViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryViewModel.swift; sourceTree = "<group>"; };
|
62E632DF267D30CA0063E547 /* LibraryViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryViewModel.swift; sourceTree = "<group>"; };
|
||||||
62E632E2267D3BA60063E547 /* MovieItemViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieItemViewModel.swift; sourceTree = "<group>"; };
|
62E632E2267D3BA60063E547 /* MovieItemViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MovieItemViewModel.swift; sourceTree = "<group>"; };
|
||||||
62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EpisodeItemViewModel.swift; sourceTree = "<group>"; };
|
62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EpisodeItemViewModel.swift; sourceTree = "<group>"; };
|
||||||
|
62E632E8267D3FF50063E547 /* SeasonItemViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SeasonItemViewModel.swift; sourceTree = "<group>"; };
|
||||||
62EC352B26766675000E9F2D /* ServerEnvironment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerEnvironment.swift; sourceTree = "<group>"; };
|
62EC352B26766675000E9F2D /* ServerEnvironment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerEnvironment.swift; sourceTree = "<group>"; };
|
||||||
62EC352E267666A5000E9F2D /* SessionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionManager.swift; sourceTree = "<group>"; };
|
62EC352E267666A5000E9F2D /* SessionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionManager.swift; sourceTree = "<group>"; };
|
||||||
62EC353326766B03000E9F2D /* DeviceRotationViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceRotationViewModifier.swift; sourceTree = "<group>"; };
|
62EC353326766B03000E9F2D /* DeviceRotationViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceRotationViewModifier.swift; sourceTree = "<group>"; };
|
||||||
|
@ -346,6 +349,7 @@
|
||||||
62E632DF267D30CA0063E547 /* LibraryViewModel.swift */,
|
62E632DF267D30CA0063E547 /* LibraryViewModel.swift */,
|
||||||
62E632E2267D3BA60063E547 /* MovieItemViewModel.swift */,
|
62E632E2267D3BA60063E547 /* MovieItemViewModel.swift */,
|
||||||
62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */,
|
62E632E5267D3F5B0063E547 /* EpisodeItemViewModel.swift */,
|
||||||
|
62E632E8267D3FF50063E547 /* SeasonItemViewModel.swift */,
|
||||||
);
|
);
|
||||||
path = ViewModels;
|
path = ViewModels;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -714,6 +718,7 @@
|
||||||
53ABFDE8267974EF00886593 /* SplashViewModel.swift in Sources */,
|
53ABFDE8267974EF00886593 /* SplashViewModel.swift in Sources */,
|
||||||
62E632DE267D2E170063E547 /* LatestMediaViewModel.swift in Sources */,
|
62E632DE267D2E170063E547 /* LatestMediaViewModel.swift in Sources */,
|
||||||
536D3D88267C17350004248C /* PublicUserButton.swift in Sources */,
|
536D3D88267C17350004248C /* PublicUserButton.swift in Sources */,
|
||||||
|
62E632EA267D3FF50063E547 /* SeasonItemViewModel.swift in Sources */,
|
||||||
536D3D7F267BDF100004248C /* LatestMediaView.swift in Sources */,
|
536D3D7F267BDF100004248C /* LatestMediaView.swift in Sources */,
|
||||||
531690ED267ABF46005D8AB9 /* ContinueWatchingView.swift in Sources */,
|
531690ED267ABF46005D8AB9 /* ContinueWatchingView.swift in Sources */,
|
||||||
62EC3530267666A5000E9F2D /* SessionManager.swift in Sources */,
|
62EC3530267666A5000E9F2D /* SessionManager.swift in Sources */,
|
||||||
|
@ -780,6 +785,7 @@
|
||||||
53DF641E263D9C0600A7CD1A /* LibraryView.swift in Sources */,
|
53DF641E263D9C0600A7CD1A /* LibraryView.swift in Sources */,
|
||||||
6267B3D626710B8900A7371D /* CollectionExtensions.swift in Sources */,
|
6267B3D626710B8900A7371D /* CollectionExtensions.swift in Sources */,
|
||||||
53A089D0264DA9DA00D57806 /* MovieItemView.swift in Sources */,
|
53A089D0264DA9DA00D57806 /* MovieItemView.swift in Sources */,
|
||||||
|
62E632E9267D3FF50063E547 /* SeasonItemViewModel.swift in Sources */,
|
||||||
625CB56A2678B71200530A6E /* SplashViewModel.swift in Sources */,
|
625CB56A2678B71200530A6E /* SplashViewModel.swift in Sources */,
|
||||||
53DE4BD2267098F300739748 /* SearchBarView.swift in Sources */,
|
53DE4BD2267098F300739748 /* SearchBarView.swift in Sources */,
|
||||||
53E4E649263F725B00F67C6B /* MultiSelectorView.swift in Sources */,
|
53E4E649263F725B00F67C6B /* MultiSelectorView.swift in Sources */,
|
||||||
|
|
|
@ -41,7 +41,7 @@ struct ItemView: View {
|
||||||
if item.type == "Movie" {
|
if item.type == "Movie" {
|
||||||
MovieItemView(viewModel: .init(item: item))
|
MovieItemView(viewModel: .init(item: item))
|
||||||
} else if item.type == "Season" {
|
} else if item.type == "Season" {
|
||||||
SeasonItemView(item: item)
|
SeasonItemView(viewModel: .init(item: item))
|
||||||
} else if item.type == "Series" {
|
} else if item.type == "Series" {
|
||||||
SeriesItemView(item: item)
|
SeriesItemView(item: item)
|
||||||
} else if item.type == "Episode" {
|
} else if item.type == "Episode" {
|
||||||
|
|
|
@ -11,45 +11,17 @@ import JellyfinAPI
|
||||||
|
|
||||||
struct SeasonItemView: View {
|
struct SeasonItemView: View {
|
||||||
@StateObject
|
@StateObject
|
||||||
var tempViewModel = ViewModel()
|
var viewModel: SeasonItemViewModel
|
||||||
@State private var orientation = UIDeviceOrientation.unknown
|
@State private var orientation = UIDeviceOrientation.unknown
|
||||||
@Environment(\.horizontalSizeClass) var hSizeClass
|
@Environment(\.horizontalSizeClass) var hSizeClass
|
||||||
@Environment(\.verticalSizeClass) var vSizeClass
|
@Environment(\.verticalSizeClass) var vSizeClass
|
||||||
|
|
||||||
var item: BaseItemDto = BaseItemDto()
|
|
||||||
@State private var episodes: [BaseItemDto] = []
|
|
||||||
|
|
||||||
@State private var isLoading: Bool = true
|
|
||||||
@State private var viewDidLoad: Bool = false
|
|
||||||
|
|
||||||
init(item: BaseItemDto) {
|
|
||||||
self.item = item
|
|
||||||
}
|
|
||||||
|
|
||||||
func onAppear() {
|
|
||||||
if viewDidLoad {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
|
||||||
TvShowsAPI.getEpisodes(seriesId: item.seriesId ?? "", userId: SessionManager.current.user.user_id!, fields: [.primaryImageAspectRatio, .seriesPrimaryImage, .seasonUserData, .overview, .genres, .people], seasonId: item.id ?? "")
|
|
||||||
.sink(receiveCompletion: { completion in
|
|
||||||
print(completion)
|
|
||||||
isLoading = false
|
|
||||||
}, receiveValue: { response in
|
|
||||||
viewDidLoad = true
|
|
||||||
episodes = response.items ?? []
|
|
||||||
})
|
|
||||||
.store(in: &tempViewModel.cancellables)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ViewBuilder
|
@ViewBuilder
|
||||||
var portraitHeaderView: some View {
|
var portraitHeaderView: some View {
|
||||||
if isLoading {
|
if viewModel.isLoading {
|
||||||
EmptyView()
|
EmptyView()
|
||||||
} else {
|
} else {
|
||||||
ImageView(src: item.getSeriesBackdropImage(maxWidth: UIDevice.current.userInterfaceIdiom == .pad ? 622 : Int(UIScreen.main.bounds.width)), bh: item.getSeriesBackdropImageBlurHash())
|
ImageView(src: viewModel.item.getSeriesBackdropImage(maxWidth: UIDevice.current.userInterfaceIdiom == .pad ? 622 : Int(UIScreen.main.bounds.width)), bh: viewModel.item.getSeriesBackdropImageBlurHash())
|
||||||
.opacity(0.4)
|
.opacity(0.4)
|
||||||
.blur(radius: 2.0)
|
.blur(radius: 2.0)
|
||||||
}
|
}
|
||||||
|
@ -57,17 +29,17 @@ struct SeasonItemView: View {
|
||||||
|
|
||||||
var portraitHeaderOverlayView: some View {
|
var portraitHeaderOverlayView: some View {
|
||||||
HStack(alignment: .bottom, spacing: 12) {
|
HStack(alignment: .bottom, spacing: 12) {
|
||||||
ImageView(src: item.getPrimaryImage(maxWidth: 120), bh: item.getPrimaryImageBlurHash())
|
ImageView(src: viewModel.item.getPrimaryImage(maxWidth: 120), bh: viewModel.item.getPrimaryImageBlurHash())
|
||||||
.frame(width: 120, height: 180)
|
.frame(width: 120, height: 180)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Text(item.name ?? "").font(.headline)
|
Text(viewModel.item.name ?? "").font(.headline)
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
.fixedSize(horizontal: false, vertical: true)
|
.fixedSize(horizontal: false, vertical: true)
|
||||||
.offset(y: -4)
|
.offset(y: -4)
|
||||||
if item.productionYear != nil {
|
if viewModel.item.productionYear != nil {
|
||||||
Text(String(item.productionYear!)).font(.subheadline)
|
Text(String(viewModel.item.productionYear!)).font(.subheadline)
|
||||||
.fontWeight(.medium)
|
.fontWeight(.medium)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
|
@ -85,15 +57,15 @@ struct SeasonItemView: View {
|
||||||
overlayAlignment: .bottomLeading,
|
overlayAlignment: .bottomLeading,
|
||||||
headerHeight: UIScreen.main.bounds.width * 0.5625) {
|
headerHeight: UIScreen.main.bounds.width * 0.5625) {
|
||||||
LazyVStack(alignment: .leading) {
|
LazyVStack(alignment: .leading) {
|
||||||
if !(item.taglines ?? []).isEmpty {
|
if !(viewModel.item.taglines ?? []).isEmpty {
|
||||||
Text(item.taglines!.first!).font(.body).italic().padding(.top, 7)
|
Text(viewModel.item.taglines!.first!).font(.body).italic().padding(.top, 7)
|
||||||
.fixedSize(horizontal: false, vertical: true).padding(.leading, 16)
|
.fixedSize(horizontal: false, vertical: true).padding(.leading, 16)
|
||||||
.padding(.trailing, 16)
|
.padding(.trailing, 16)
|
||||||
}
|
}
|
||||||
Text(item.overview ?? "").font(.footnote).padding(.top, 3)
|
Text(viewModel.item.overview ?? "").font(.footnote).padding(.top, 3)
|
||||||
.fixedSize(horizontal: false, vertical: true).padding(.bottom, 3).padding(.leading, 16)
|
.fixedSize(horizontal: false, vertical: true).padding(.bottom, 3).padding(.leading, 16)
|
||||||
.padding(.trailing, 16)
|
.padding(.trailing, 16)
|
||||||
ForEach(episodes, id: \.id) { episode in
|
ForEach(viewModel.episodes, id: \.id) { episode in
|
||||||
NavigationLink(destination: ItemView(item: episode)) {
|
NavigationLink(destination: ItemView(item: episode)) {
|
||||||
HStack {
|
HStack {
|
||||||
ImageView(src: episode.getPrimaryImage(maxWidth: 150), bh: episode.getPrimaryImageBlurHash())
|
ImageView(src: episode.getPrimaryImage(maxWidth: 150), bh: episode.getPrimaryImageBlurHash())
|
||||||
|
@ -133,11 +105,11 @@ struct SeasonItemView: View {
|
||||||
}.offset(x: 12, y: 0)
|
}.offset(x: 12, y: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !(item.studios ?? []).isEmpty {
|
if !(viewModel.item.studios ?? []).isEmpty {
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
HStack {
|
HStack {
|
||||||
Text("Studios:").font(.callout).fontWeight(.semibold)
|
Text("Studios:").font(.callout).fontWeight(.semibold)
|
||||||
ForEach(item.studios!, id: \.id) { studio in
|
ForEach(viewModel.item.studios!, id: \.id) { studio in
|
||||||
NavigationLink(destination: LazyView {
|
NavigationLink(destination: LazyView {
|
||||||
LibraryView(viewModel: .init(studio: studio), title: studio.name ?? "")
|
LibraryView(viewModel: .init(studio: studio), title: studio.name ?? "")
|
||||||
}) {
|
}) {
|
||||||
|
@ -155,7 +127,7 @@ struct SeasonItemView: View {
|
||||||
} else {
|
} else {
|
||||||
GeometryReader { geometry in
|
GeometryReader { geometry in
|
||||||
ZStack {
|
ZStack {
|
||||||
ImageView(src: item.getSeriesBackdropImage(maxWidth: 200), bh: item.getSeriesBackdropImageBlurHash())
|
ImageView(src: viewModel.item.getSeriesBackdropImage(maxWidth: 200), bh: viewModel.item.getSeriesBackdropImageBlurHash())
|
||||||
.opacity(0.4)
|
.opacity(0.4)
|
||||||
.frame(width: geometry.size.width + geometry.safeAreaInsets.leading + geometry.safeAreaInsets.trailing,
|
.frame(width: geometry.size.width + geometry.safeAreaInsets.leading + geometry.safeAreaInsets.trailing,
|
||||||
height: geometry.size.height + geometry.safeAreaInsets.top + geometry.safeAreaInsets.bottom)
|
height: geometry.size.height + geometry.safeAreaInsets.top + geometry.safeAreaInsets.bottom)
|
||||||
|
@ -164,12 +136,12 @@ struct SeasonItemView: View {
|
||||||
HStack {
|
HStack {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Spacer().frame(height: 16)
|
Spacer().frame(height: 16)
|
||||||
ImageView(src: item.getPrimaryImage(maxWidth: 120), bh: item.getPrimaryImageBlurHash())
|
ImageView(src: viewModel.item.getPrimaryImage(maxWidth: 120), bh: viewModel.item.getPrimaryImageBlurHash())
|
||||||
.frame(width: 120, height: 180)
|
.frame(width: 120, height: 180)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
Spacer().frame(height: 4)
|
Spacer().frame(height: 4)
|
||||||
if item.productionYear != nil {
|
if viewModel.item.productionYear != nil {
|
||||||
Text(String(item.productionYear!)).font(.subheadline)
|
Text(String(viewModel.item.productionYear!)).font(.subheadline)
|
||||||
.fontWeight(.medium)
|
.fontWeight(.medium)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
@ -178,15 +150,15 @@ struct SeasonItemView: View {
|
||||||
ScrollView {
|
ScrollView {
|
||||||
Spacer().frame(height: 16)
|
Spacer().frame(height: 16)
|
||||||
LazyVStack(alignment: .leading) {
|
LazyVStack(alignment: .leading) {
|
||||||
if !(item.taglines ?? []).isEmpty {
|
if !(viewModel.item.taglines ?? []).isEmpty {
|
||||||
Text(item.taglines!.first!).font(.body).italic().padding(.top, 7)
|
Text(viewModel.item.taglines!.first!).font(.body).italic().padding(.top, 7)
|
||||||
.fixedSize(horizontal: false, vertical: true).padding(.leading, 16)
|
.fixedSize(horizontal: false, vertical: true).padding(.leading, 16)
|
||||||
.padding(.trailing, 16)
|
.padding(.trailing, 16)
|
||||||
}
|
}
|
||||||
Text(item.overview ?? "").font(.footnote).padding(.top, 3)
|
Text(viewModel.item.overview ?? "").font(.footnote).padding(.top, 3)
|
||||||
.fixedSize(horizontal: false, vertical: true).padding(.bottom, 3).padding(.leading, 16)
|
.fixedSize(horizontal: false, vertical: true).padding(.bottom, 3).padding(.leading, 16)
|
||||||
.padding(.trailing, 16)
|
.padding(.trailing, 16)
|
||||||
ForEach(episodes, id: \.id) { episode in
|
ForEach(viewModel.episodes, id: \.id) { episode in
|
||||||
NavigationLink(destination: ItemView(item: episode)) {
|
NavigationLink(destination: ItemView(item: episode)) {
|
||||||
HStack {
|
HStack {
|
||||||
ImageView(src: episode.getPrimaryImage(maxWidth: 150), bh: episode.getPrimaryImageBlurHash())
|
ImageView(src: episode.getPrimaryImage(maxWidth: 150), bh: episode.getPrimaryImageBlurHash())
|
||||||
|
@ -226,11 +198,11 @@ struct SeasonItemView: View {
|
||||||
}.offset(x: 12, y: 0)
|
}.offset(x: 12, y: 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !(item.studios ?? []).isEmpty {
|
if !(viewModel.item.studios ?? []).isEmpty {
|
||||||
ScrollView(.horizontal, showsIndicators: false) {
|
ScrollView(.horizontal, showsIndicators: false) {
|
||||||
HStack {
|
HStack {
|
||||||
Text("Studios:").font(.callout).fontWeight(.semibold)
|
Text("Studios:").font(.callout).fontWeight(.semibold)
|
||||||
ForEach(item.studios!, id: \.id) { studio in
|
ForEach(viewModel.item.studios!, id: \.id) { studio in
|
||||||
NavigationLink(destination: LazyView {
|
NavigationLink(destination: LazyView {
|
||||||
LibraryView(viewModel: .init(studio: studio), title: studio.name ?? "")
|
LibraryView(viewModel: .init(studio: studio), title: studio.name ?? "")
|
||||||
}) {
|
}) {
|
||||||
|
@ -250,16 +222,15 @@ struct SeasonItemView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
if isLoading {
|
if viewModel.isLoading {
|
||||||
ProgressView()
|
ProgressView()
|
||||||
.onAppear(perform: onAppear)
|
|
||||||
} else {
|
} else {
|
||||||
innerBody
|
innerBody
|
||||||
.onRotate {
|
.onRotate {
|
||||||
orientation = $0
|
orientation = $0
|
||||||
}
|
}
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.navigationTitle("\(item.name ?? "") - \(item.seriesName ?? "")")
|
.navigationTitle("\(viewModel.item.name ?? "") - \(viewModel.item.seriesName ?? "")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
* 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 Combine
|
||||||
|
import Foundation
|
||||||
|
import JellyfinAPI
|
||||||
|
|
||||||
|
final class SeasonItemViewModel: ViewModel {
|
||||||
|
@Published
|
||||||
|
var item: BaseItemDto
|
||||||
|
|
||||||
|
@Published
|
||||||
|
var episodes = [BaseItemDto]()
|
||||||
|
|
||||||
|
init(item: BaseItemDto) {
|
||||||
|
self.item = item
|
||||||
|
super.init()
|
||||||
|
|
||||||
|
refresh()
|
||||||
|
}
|
||||||
|
|
||||||
|
func refresh() {
|
||||||
|
TvShowsAPI.getEpisodes(seriesId: item.seriesId ?? "", userId: SessionManager.current.user.user_id!,
|
||||||
|
fields: [.primaryImageAspectRatio, .seriesPrimaryImage, .seasonUserData, .overview, .genres, .people],
|
||||||
|
seasonId: item.id ?? "")
|
||||||
|
.trackActivity(loading)
|
||||||
|
.sink(receiveCompletion: { [weak self] completion in
|
||||||
|
self?.HandleAPIRequestCompletion(completion: completion)
|
||||||
|
}, receiveValue: { [weak self] response in
|
||||||
|
self?.episodes = response.items ?? []
|
||||||
|
})
|
||||||
|
.store(in: &cancellables)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue