Start creating itemSeriesView

This commit is contained in:
Shav Kinderlehrer 2024-02-20 22:18:15 -05:00
parent c9fea34184
commit 53b0792595
11 changed files with 138 additions and 37 deletions

View File

@ -14,17 +14,17 @@
3D13F95F2B375DB800E91913 /* ItemView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D13F95E2B375DB800E91913 /* ItemView.swift */; };
3D13F9612B37637500E91913 /* ItemMediaView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D13F9602B37637500E91913 /* ItemMediaView.swift */; };
3D13F9652B37EC7A00E91913 /* ItemHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D13F9642B37EC7A00E91913 /* ItemHeaderView.swift */; };
3D13F9692B389FA300E91913 /* ViewOffsetKey.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D13F9682B389FA300E91913 /* ViewOffsetKey.swift */; };
3D13F96F2B38A32500E91913 /* StickyHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D13F96E2B38A32500E91913 /* StickyHeaderView.swift */; };
3D16FC3C2B2CDFB500E6D8B3 /* DashboardLibraryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D16FC3B2B2CDFB500E6D8B3 /* DashboardLibraryView.swift */; };
3D21F4292B69A8B0007207D2 /* ExpandableText in Frameworks */ = {isa = PBXBuildFile; productRef = 3D21F4282B69A8B0007207D2 /* ExpandableText */; };
3D2552462B7A847700192879 /* ItemSeriesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D2552452B7A847700192879 /* ItemSeriesView.swift */; };
3D2552492B7A8B3100192879 /* ItemSeriesSeriesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D2552482B7A8B3100192879 /* ItemSeriesSeriesView.swift */; };
3D2552492B7A8B3100192879 /* ItemSeriesSeasonsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D2552482B7A8B3100192879 /* ItemSeriesSeasonsView.swift */; };
3D3816C92B4B5648006414D7 /* ItemGenresView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D3816C82B4B5648006414D7 /* ItemGenresView.swift */; };
3D41D1FA2B2CAE0000E58234 /* ItemIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D41D1F92B2CAE0000E58234 /* ItemIconView.swift */; };
3D4C15722B3CAA670035373E /* DashboardSectionTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D4C15712B3CAA670035373E /* DashboardSectionTitleView.swift */; };
3D58F07E2B4DB19300DB2936 /* TextRatingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D58F07D2B4DB19300DB2936 /* TextRatingView.swift */; };
3D6A7DB92B7C5D3900A5E31B /* ItemSeasonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D6A7DB82B7C5D3900A5E31B /* ItemSeasonView.swift */; };
3D74AE122B7D4EB000C17F2E /* UIScreenWidthExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */; };
3D7709392B29139700199889 /* Pulse in Frameworks */ = {isa = PBXBuildFile; productRef = 3D7709382B29139700199889 /* Pulse */; };
3D77093B2B29139700199889 /* PulseUI in Frameworks */ = {isa = PBXBuildFile; productRef = 3D77093A2B29139700199889 /* PulseUI */; };
3D8AB2A52B36440D005BD7D0 /* BlurHashDecode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */; };
@ -50,6 +50,8 @@
3DC6BA2D2B2A422300416B9F /* SettingsController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DC6BA2C2B2A422300416B9F /* SettingsController.swift */; };
3DDD67932B293BC40026781E /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67922B293BC40026781E /* DashboardView.swift */; };
3DDD67962B29E28B0026781E /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67952B29E28B0026781E /* SettingsView.swift */; };
3DDF35D52B7D384000423923 /* ItemSeriesEpisodesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDF35D42B7D384000423923 /* ItemSeriesEpisodesView.swift */; };
3DDF35D72B7D4D0100423923 /* ItemSeriesEpisodeIconView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDF35D62B7D4D0100423923 /* ItemSeriesEpisodeIconView.swift */; };
3DF1ED3E2B282836000AD8EA /* JellyfinClientController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DF1ED3D2B282836000AD8EA /* JellyfinClientController.swift */; };
3DFE7AF72B5260FF005461FE /* ItemPersonView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DFE7AF62B5260FF005461FE /* ItemPersonView.swift */; };
3DFE7AF92B5264A4005461FE /* ItemPersonDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DFE7AF82B5264A4005461FE /* ItemPersonDetailView.swift */; };
@ -92,16 +94,16 @@
3D13F95E2B375DB800E91913 /* ItemView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemView.swift; sourceTree = "<group>"; };
3D13F9602B37637500E91913 /* ItemMediaView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemMediaView.swift; sourceTree = "<group>"; };
3D13F9642B37EC7A00E91913 /* ItemHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemHeaderView.swift; sourceTree = "<group>"; };
3D13F9682B389FA300E91913 /* ViewOffsetKey.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewOffsetKey.swift; sourceTree = "<group>"; };
3D13F96E2B38A32500E91913 /* StickyHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StickyHeaderView.swift; sourceTree = "<group>"; };
3D16FC3B2B2CDFB500E6D8B3 /* DashboardLibraryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardLibraryView.swift; sourceTree = "<group>"; };
3D2552452B7A847700192879 /* ItemSeriesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeriesView.swift; sourceTree = "<group>"; };
3D2552482B7A8B3100192879 /* ItemSeriesSeriesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeriesSeriesView.swift; sourceTree = "<group>"; };
3D2552482B7A8B3100192879 /* ItemSeriesSeasonsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeriesSeasonsView.swift; sourceTree = "<group>"; };
3D3816C82B4B5648006414D7 /* ItemGenresView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemGenresView.swift; sourceTree = "<group>"; };
3D41D1F92B2CAE0000E58234 /* ItemIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemIconView.swift; sourceTree = "<group>"; };
3D4C15712B3CAA670035373E /* DashboardSectionTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardSectionTitleView.swift; sourceTree = "<group>"; };
3D58F07D2B4DB19300DB2936 /* TextRatingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TextRatingView.swift; sourceTree = "<group>"; };
3D6A7DB82B7C5D3900A5E31B /* ItemSeasonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeasonView.swift; sourceTree = "<group>"; };
3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIScreenWidthExtension.swift; sourceTree = "<group>"; };
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlurHashDecode.swift; sourceTree = "<group>"; };
3D8AB2A72B366353005BD7D0 /* LibraryDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LibraryDetailView.swift; sourceTree = "<group>"; };
3D9063C72B279A310063DD2A /* Jel.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Jel.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -129,6 +131,8 @@
3DC6BA2C2B2A422300416B9F /* SettingsController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsController.swift; sourceTree = "<group>"; };
3DDD67922B293BC40026781E /* DashboardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardView.swift; sourceTree = "<group>"; };
3DDD67952B29E28B0026781E /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
3DDF35D42B7D384000423923 /* ItemSeriesEpisodesView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeriesEpisodesView.swift; sourceTree = "<group>"; };
3DDF35D62B7D4D0100423923 /* ItemSeriesEpisodeIconView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemSeriesEpisodeIconView.swift; sourceTree = "<group>"; };
3DF1ED3D2B282836000AD8EA /* JellyfinClientController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JellyfinClientController.swift; sourceTree = "<group>"; };
3DFE7AF62B5260FF005461FE /* ItemPersonView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemPersonView.swift; sourceTree = "<group>"; };
3DFE7AF82B5264A4005461FE /* ItemPersonDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ItemPersonDetailView.swift; sourceTree = "<group>"; };
@ -195,9 +199,9 @@
children = (
3D91FDCC2B2907E800919017 /* JellyfinDateFormatter.swift */,
3D8AB2A42B36440D005BD7D0 /* BlurHashDecode.swift */,
3D13F9682B389FA300E91913 /* ViewOffsetKey.swift */,
3DAFA8E92B39039900D71AD1 /* JellyfinKitExtensions.swift */,
3DAFA8EB2B394F9F00D71AD1 /* ViewExtensions.swift */,
3D74AE112B7D4EB000C17F2E /* UIScreenWidthExtension.swift */,
);
path = Models;
sourceTree = "<group>";
@ -230,7 +234,9 @@
3D2552472B7A8A9400192879 /* Series */ = {
isa = PBXGroup;
children = (
3D2552482B7A8B3100192879 /* ItemSeriesSeriesView.swift */,
3D2552482B7A8B3100192879 /* ItemSeriesSeasonsView.swift */,
3DDF35D42B7D384000423923 /* ItemSeriesEpisodesView.swift */,
3DDF35D62B7D4D0100423923 /* ItemSeriesEpisodeIconView.swift */,
);
path = Series;
sourceTree = "<group>";
@ -318,9 +324,9 @@
isa = PBXGroup;
children = (
3DAFA8EE2B3B707B00D71AD1 /* ItemMovieView.swift */,
3DFE7AF62B5260FF005461FE /* ItemPersonView.swift */,
3D2552452B7A847700192879 /* ItemSeriesView.swift */,
3D6A7DB82B7C5D3900A5E31B /* ItemSeasonView.swift */,
3DFE7AF62B5260FF005461FE /* ItemPersonView.swift */,
);
path = Types;
sourceTree = "<group>";
@ -501,6 +507,7 @@
3D13F96F2B38A32500E91913 /* StickyHeaderView.swift in Sources */,
3DF1ED3E2B282836000AD8EA /* JellyfinClientController.swift in Sources */,
3D1015D92B27F57400F5C29A /* AddServerView.swift in Sources */,
3DDF35D52B7D384000423923 /* ItemSeriesEpisodesView.swift in Sources */,
3DAFA8EA2B39039900D71AD1 /* JellyfinKitExtensions.swift in Sources */,
3D13F9652B37EC7A00E91913 /* ItemHeaderView.swift in Sources */,
3D3816C92B4B5648006414D7 /* ItemGenresView.swift in Sources */,
@ -508,7 +515,6 @@
3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */,
3DFE7AF92B5264A4005461FE /* ItemPersonDetailView.swift in Sources */,
3DBAC9E42B4C7404005F8764 /* UIScreenCurrent.swift in Sources */,
3D13F9692B389FA300E91913 /* ViewOffsetKey.swift in Sources */,
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */,
3D58F07E2B4DB19300DB2936 /* TextRatingView.swift in Sources */,
3D6A7DB92B7C5D3900A5E31B /* ItemSeasonView.swift in Sources */,
@ -517,12 +523,14 @@
3D8AB2A82B366353005BD7D0 /* LibraryDetailView.swift in Sources */,
3DDD67932B293BC40026781E /* DashboardView.swift in Sources */,
3D13F9612B37637500E91913 /* ItemMediaView.swift in Sources */,
3D2552492B7A8B3100192879 /* ItemSeriesSeriesView.swift in Sources */,
3D2552492B7A8B3100192879 /* ItemSeriesSeasonsView.swift in Sources */,
3DFE7AF72B5260FF005461FE /* ItemPersonView.swift in Sources */,
3D41D1FA2B2CAE0000E58234 /* ItemIconView.swift in Sources */,
3D8AB2A52B36440D005BD7D0 /* BlurHashDecode.swift in Sources */,
3DBAC9EA2B4C8927005F8764 /* ItemPersonIconView.swift in Sources */,
3DDF35D72B7D4D0100423923 /* ItemSeriesEpisodeIconView.swift in Sources */,
3DC6BA2D2B2A422300416B9F /* SettingsController.swift in Sources */,
3D74AE122B7D4EB000C17F2E /* UIScreenWidthExtension.swift in Sources */,
3DAFA8E82B38AFED00D71AD1 /* ItemInfoView.swift in Sources */,
3D91FDCB2B28CA2500919017 /* SignInToServerView.swift in Sources */,
3D4C15722B3CAA670035373E /* DashboardSectionTitleView.swift in Sources */,

View File

@ -0,0 +1,15 @@
//
// UIScreenWidthExtension.swift
// Jel
//
// Created by zerocool on 2/14/24.
//
import Foundation
import UIKit
extension UIScreen{
static let screenWidth = UIScreen.main.bounds.size.width
static let screenHeight = UIScreen.main.bounds.size.height
static let screenSize = UIScreen.main.bounds.size
}

View File

@ -1,17 +0,0 @@
//
// ViewOffsetKey.swift
// Jel
//
// Created by zerocool on 12/24/23.
//
import SwiftUI
/// A preference key to store ScrollView offset
public struct ViewOffsetKey: PreferenceKey {
public typealias Value = CGFloat
public static var defaultValue = CGFloat.zero
public static func reduce(value: inout Value, nextValue: () -> Value) {
value += nextValue()
}
}

View File

@ -37,8 +37,8 @@ struct DashboardLibraryView: View {
}
.buttonStyle(PlainButtonStyle())
}
}.padding(.horizontal)
}
}.padding(.horizontal)
}
.onAppear {
Task {

View File

@ -70,7 +70,7 @@ struct ItemIconView: View {
case "Primary":
return item.imageBlurHashes?.primary?[item.imageTags?[imageType] ?? ""] ?? ""
case "Backdrop":
return item.imageBlurHashes?.backdrop?[item.backdropImageTags?[0] ?? ""] ?? ""
return item.imageBlurHashes?.backdrop?[item.backdropImageTags?.first ?? ""] ?? ""
default:
return ""
}

View File

@ -14,9 +14,13 @@ struct ItemInfoView: View {
var body: some View {
VStack(alignment: .leading) {
HStack {
Text((item.productionYear != nil) ? String(item.productionYear!) : "---")
if let productionYear = item.productionYear {
Text(String(productionYear))
}
if let genres = item.genres {
Text("")
Text(item.genres?.first ?? "---")
Text(genres.first ?? "---")
}
}
HStack {

View File

@ -0,0 +1,39 @@
//
// ItemSeriesEpisodeIconView.swift
// Jel
//
// Created by zerocool on 2/14/24.
//
import SwiftUI
import JellyfinKit
import ExpandableText
struct ItemSeriesEpisodeIconView: View {
var item: BaseItemDto
var body: some View {
HStack(alignment: .top) {
VStack(alignment: .leading) {
Text("Episode \(item.indexNumber ?? 0)")
.foregroundStyle(Color.secondary)
.font(.callout)
ItemIconView(item: item, width: UIScreen.screenWidth * 0.5, contentMode: .fill)
.setAspectRatio(item.primaryImageAspectRatio ?? 1.7)
}
.frame(width: UIScreen.screenWidth * 0.5)
VStack(alignment: .leading) {
Text(item.name ?? "Episode \(item.indexNumber ?? 0)")
.font(.callout)
.bold()
Text(item.overview ?? "")
.frame(height: (UIScreen.screenWidth * 0.5) / (item.primaryImageAspectRatio ?? 1.7)) // Calculate optimal amount of lines based on episode image
}
}
}
}
//#Preview {
// ItemSeriesEpisodeIconView()
//}

View File

@ -0,0 +1,44 @@
//
// ItemSeriesEpisodesView.swift
// Jel
//
// Created by zerocool on 2/14/24.
//
import SwiftUI
import JellyfinKit
struct ItemSeriesEpisodesView: View {
@EnvironmentObject var jellyfinClient: JellyfinClientController
@StateObject var authState: AuthStateController = AuthStateController.shared
var item: BaseItemDto
@State var episodeItems: [BaseItemDto] = []
var body: some View {
VStack {
ForEach(episodeItems) {episode in
ItemSeriesEpisodeIconView(item: episode)
}
}
.onAppear {
Task {
let parameters = Paths.GetItemsParameters(
userID: authState.userId,
parentID: item.id ?? ""
)
let req = Paths.getItems(parameters: parameters)
do {
let res = try await jellyfinClient.send(req)
episodeItems = res.value.items ?? []
} catch {}
}
}
}
}
//#Preview {
// ItemSeriesEpisodesView()
//}

View File

@ -1,5 +1,5 @@
//
// ItemSeriesSeriesView.swift
// ItemSeriesSeasonsView.swift
// Jel
//
// Created by zerocool on 2/12/24.
@ -8,7 +8,7 @@
import SwiftUI
import JellyfinKit
struct ItemSeriesSeriesView: View {
struct ItemSeriesSeasonsView: View {
var item: BaseItemDto
@EnvironmentObject var jellyfinClient: JellyfinClientController
@ -18,7 +18,7 @@ struct ItemSeriesSeriesView: View {
var body: some View {
VStack(alignment: .leading) {
Text("Series")
Text("Seasons")
.font(.title2)
.padding(.horizontal)

View File

@ -13,8 +13,16 @@ struct ItemSeasonView: View {
var body: some View {
VStack {
if item.overview != nil {
ItemMediaView(item: item)
.padding([.horizontal, .bottom])
}
ItemSeriesEpisodesView(item: item)
.padding(.horizontal)
}
.navigationTitle(item.name ?? "Untitled")
.navigationBarTitleDisplayMode(.large)
}
}

View File

@ -34,7 +34,7 @@ struct ItemSeriesView: View {
ItemGenresView(item: item)
.foregroundStyle(Color.primary)
ItemSeriesSeriesView(item: item)
ItemSeriesSeasonsView(item: item)
.foregroundStyle(Color.primary)
ItemPeopleView(item: item)