Start implementing ItemPersonView

This commit is contained in:
Shav Kinderlehrer 2024-01-13 02:20:20 -05:00
parent 6b8d3372d2
commit 4c98eef120
5 changed files with 146 additions and 6 deletions

View File

@ -48,6 +48,8 @@
3DDD67932B293BC40026781E /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67922B293BC40026781E /* DashboardView.swift */; }; 3DDD67932B293BC40026781E /* DashboardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67922B293BC40026781E /* DashboardView.swift */; };
3DDD67962B29E28B0026781E /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67952B29E28B0026781E /* SettingsView.swift */; }; 3DDD67962B29E28B0026781E /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DDD67952B29E28B0026781E /* SettingsView.swift */; };
3DF1ED3E2B282836000AD8EA /* JellyfinClientController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DF1ED3D2B282836000AD8EA /* JellyfinClientController.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 */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -122,6 +124,8 @@
3DDD67922B293BC40026781E /* DashboardView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardView.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>"; }; 3DDD67952B29E28B0026781E /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
3DF1ED3D2B282836000AD8EA /* JellyfinClientController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JellyfinClientController.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>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -299,6 +303,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
3DAFA8EE2B3B707B00D71AD1 /* ItemMovieView.swift */, 3DAFA8EE2B3B707B00D71AD1 /* ItemMovieView.swift */,
3DFE7AF62B5260FF005461FE /* ItemPersonView.swift */,
); );
path = Types; path = Types;
sourceTree = "<group>"; sourceTree = "<group>";
@ -308,6 +313,7 @@
children = ( children = (
3DBAC9E12B4C31BE005F8764 /* ItemPeopleView.swift */, 3DBAC9E12B4C31BE005F8764 /* ItemPeopleView.swift */,
3DBAC9E92B4C8927005F8764 /* ItemPersonIconView.swift */, 3DBAC9E92B4C8927005F8764 /* ItemPersonIconView.swift */,
3DFE7AF82B5264A4005461FE /* ItemPersonDetailView.swift */,
); );
path = Person; path = Person;
sourceTree = "<group>"; sourceTree = "<group>";
@ -403,7 +409,7 @@
attributes = { attributes = {
BuildIndependentTargetsInParallel = 1; BuildIndependentTargetsInParallel = 1;
LastSwiftUpdateCheck = 1500; LastSwiftUpdateCheck = 1500;
LastUpgradeCheck = 1500; LastUpgradeCheck = 1520;
TargetAttributes = { TargetAttributes = {
3D9063C62B279A310063DD2A = { 3D9063C62B279A310063DD2A = {
CreatedOnToolsVersion = 15.0.1; CreatedOnToolsVersion = 15.0.1;
@ -483,6 +489,7 @@
3D3816C92B4B5648006414D7 /* ItemGenresView.swift in Sources */, 3D3816C92B4B5648006414D7 /* ItemGenresView.swift in Sources */,
3DAFA8EC2B394F9F00D71AD1 /* ViewExtensions.swift in Sources */, 3DAFA8EC2B394F9F00D71AD1 /* ViewExtensions.swift in Sources */,
3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */, 3D9063CB2B279A310063DD2A /* JelApp.swift in Sources */,
3DFE7AF92B5264A4005461FE /* ItemPersonDetailView.swift in Sources */,
3DBAC9E42B4C7404005F8764 /* UIScreenCurrent.swift in Sources */, 3DBAC9E42B4C7404005F8764 /* UIScreenCurrent.swift in Sources */,
3D13F9692B389FA300E91913 /* ViewOffsetKey.swift in Sources */, 3D13F9692B389FA300E91913 /* ViewOffsetKey.swift in Sources */,
3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */, 3D91FDCD2B2907E800919017 /* JellyfinDateFormatter.swift in Sources */,
@ -492,6 +499,7 @@
3D8AB2A82B366353005BD7D0 /* LibraryDetailView.swift in Sources */, 3D8AB2A82B366353005BD7D0 /* LibraryDetailView.swift in Sources */,
3DDD67932B293BC40026781E /* DashboardView.swift in Sources */, 3DDD67932B293BC40026781E /* DashboardView.swift in Sources */,
3D13F9612B37637500E91913 /* ItemMediaView.swift in Sources */, 3D13F9612B37637500E91913 /* ItemMediaView.swift in Sources */,
3DFE7AF72B5260FF005461FE /* ItemPersonView.swift in Sources */,
3D41D1FA2B2CAE0000E58234 /* ItemIconView.swift in Sources */, 3D41D1FA2B2CAE0000E58234 /* ItemIconView.swift in Sources */,
3D8AB2A52B36440D005BD7D0 /* BlurHashDecode.swift in Sources */, 3D8AB2A52B36440D005BD7D0 /* BlurHashDecode.swift in Sources */,
3DBAC9EA2B4C8927005F8764 /* ItemPersonIconView.swift in Sources */, 3DBAC9EA2B4C8927005F8764 /* ItemPersonIconView.swift in Sources */,
@ -665,6 +673,7 @@
CODE_SIGN_ENTITLEMENTS = Jel/Jel.entitlements; CODE_SIGN_ENTITLEMENTS = Jel/Jel.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Jel/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"Jel/Preview Content\"";
DEVELOPMENT_TEAM = H4TSJQG42B; DEVELOPMENT_TEAM = H4TSJQG42B;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -705,6 +714,7 @@
CODE_SIGN_ENTITLEMENTS = Jel/Jel.entitlements; CODE_SIGN_ENTITLEMENTS = Jel/Jel.entitlements;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"Jel/Preview Content\""; DEVELOPMENT_ASSET_PATHS = "\"Jel/Preview Content\"";
DEVELOPMENT_TEAM = H4TSJQG42B; DEVELOPMENT_TEAM = H4TSJQG42B;
ENABLE_HARDENED_RUNTIME = YES; ENABLE_HARDENED_RUNTIME = YES;
@ -743,6 +753,7 @@
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = H4TSJQG42B; DEVELOPMENT_TEAM = H4TSJQG42B;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0; IPHONEOS_DEPLOYMENT_TARGET = 17.0;
@ -766,6 +777,7 @@
BUNDLE_LOADER = "$(TEST_HOST)"; BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = H4TSJQG42B; DEVELOPMENT_TEAM = H4TSJQG42B;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0; IPHONEOS_DEPLOYMENT_TARGET = 17.0;
@ -788,6 +800,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = H4TSJQG42B; DEVELOPMENT_TEAM = H4TSJQG42B;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0; IPHONEOS_DEPLOYMENT_TARGET = 17.0;
@ -810,6 +823,7 @@
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1; CURRENT_PROJECT_VERSION = 1;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_TEAM = H4TSJQG42B; DEVELOPMENT_TEAM = H4TSJQG42B;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 17.0; IPHONEOS_DEPLOYMENT_TARGET = 17.0;

View File

@ -16,6 +16,8 @@ struct ItemView: View {
switch item.type { switch item.type {
case .movie: case .movie:
ItemMovieView(item: item) ItemMovieView(item: item)
case .person:
ItemPersonView(item: item)
default: default:
ItemMediaView(item: item) ItemMediaView(item: item)
} }

View File

@ -7,7 +7,6 @@
import SwiftUI import SwiftUI
import JellyfinKit import JellyfinKit
import NukeUI
struct ItemPeopleView: View { struct ItemPeopleView: View {
@ -24,10 +23,7 @@ struct ItemPeopleView: View {
HStack(alignment: .top) { HStack(alignment: .top) {
ForEach(item.people ?? [], id: \.iterId) {person in ForEach(item.people ?? [], id: \.iterId) {person in
NavigationLink { NavigationLink {
VStack { ItemPersonDetailView(person: person)
ItemPersonIconView(person: person)
Text("Subview")
}
.navigationTitle(person.name ?? "Unnamed") .navigationTitle(person.name ?? "Unnamed")
} label: { } label: {
ItemPersonIconView(person: person) ItemPersonIconView(person: person)

View File

@ -0,0 +1,47 @@
//
// ItemPersonDetailView.swift
// Jel
//
// Created by zerocool on 1/13/24.
//
import SwiftUI
import JellyfinKit
struct ItemPersonDetailView: View {
@StateObject var authState: AuthStateController = AuthStateController.shared
@EnvironmentObject var jellyfinClient: JellyfinClientController
var person: BaseItemPerson
@State var personItem: BaseItemDto?
@State var loading: Bool = true
var body: some View {
VStack {
if loading {
ProgressView()
.progressViewStyle(.circular)
}
if let personItem = personItem {
ItemView(item: personItem)
}
}
.onAppear {
Task {
let request = Paths.getItem(userID: authState.userId ?? "", itemID: person.id ?? "")
do {
let res = try await jellyfinClient.send(request)
personItem = res.value
loading = false
} catch {}
}
}
}
}
//#Preview {
// ItemPersonDetailView()
//}

View File

@ -0,0 +1,81 @@
//
// ItemPersonView.swift
// Jel
//
// Created by zerocool on 1/13/24.
//
import SwiftUI
import JellyfinKit
struct ItemPersonView: View {
@EnvironmentObject var jellyfinClient: JellyfinClientController
var item: BaseItemDto
@State var items: [BaseItemDto]?
var body: some View {
VStack(alignment: .leading) {
Text(item.name ?? "---")
.font(.title)
.padding()
if let overview = item.overview {
Text(overview)
.padding([.horizontal, .bottom])
}
if let items = items {
// TODO: Extract to view to maintain DRY
let movies = items.filter({$0.type == .movie})
if movies.count > 0 {
Text("Movies")
.font(.title2)
.padding(.horizontal)
ScrollView(.horizontal) {
LazyHStack {
ForEach(movies) {movie in
Text(movie.name ?? "")
}
}
.padding(.horizontal)
}
}
let shows = items.filter({$0.type == .series})
if shows.count > 0 {
Text("Shows")
.font(.title2)
.padding(.horizontal)
ScrollView(.horizontal) {
LazyHStack {
ForEach(shows) {show in
Text(show.name ?? "")
}
}
.padding(.horizontal)
}
}
}
}
.onAppear {
Task {
let parameters = Paths.GetItemsParameters(
isRecursive: true,
personIDs: [item.id ?? ""]
)
let request = Paths.getItems(parameters: parameters)
do {
let res = try await jellyfinClient.send(request)
items = res.value.items ?? []
} catch {}
}
}
}
}
//#Preview {
// ItemPersonView()
//}