diff options
author | Shav Kinderlehrer <[email protected]> | 2024-01-11 20:44:49 -0500 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2024-01-11 20:44:49 -0500 |
commit | 6b8d3372d21149ed0efb4d43bf0cab44bd24f9a4 (patch) | |
tree | a6c393738b67dd753efe839aff59193da94b7bb3 /Jel/Views/Item/Person | |
parent | 6edc39791a577a500c92f32361cf1e7d2590ec37 (diff) | |
download | jel-6b8d3372d21149ed0efb4d43bf0cab44bd24f9a4.tar.gz jel-6b8d3372d21149ed0efb4d43bf0cab44bd24f9a4.zip |
Implement peopleView
Diffstat (limited to 'Jel/Views/Item/Person')
-rw-r--r-- | Jel/Views/Item/Person/ItemPeopleView.swift | 46 | ||||
-rw-r--r-- | Jel/Views/Item/Person/ItemPersonIconView.swift | 75 |
2 files changed, 121 insertions, 0 deletions
diff --git a/Jel/Views/Item/Person/ItemPeopleView.swift b/Jel/Views/Item/Person/ItemPeopleView.swift new file mode 100644 index 0000000..f007796 --- /dev/null +++ b/Jel/Views/Item/Person/ItemPeopleView.swift @@ -0,0 +1,46 @@ +// +// ItemPeopleView.swift +// Jel +// +// Created by zerocool on 1/8/24. +// + +import SwiftUI +import JellyfinKit +import NukeUI + +struct ItemPeopleView: View { + + var item: BaseItemDto + + var body: some View { + VStack(alignment: .leading) { + Text("Cast and Crew") + .font(.title2) + .padding(.leading) + + ScrollView(.horizontal) { + // FIXME: For some reason, a LazyHStack clips the text for this view + HStack(alignment: .top) { + ForEach(item.people ?? [], id: \.iterId) {person in + NavigationLink { + VStack { + ItemPersonIconView(person: person) + Text("Subview") + } + .navigationTitle(person.name ?? "Unnamed") + } label: { + ItemPersonIconView(person: person) + } + } + } + .padding(.horizontal) + } + .scrollIndicators(.hidden) + } + } +} + +//#Preview { +// ItemPeopleView() +//} diff --git a/Jel/Views/Item/Person/ItemPersonIconView.swift b/Jel/Views/Item/Person/ItemPersonIconView.swift new file mode 100644 index 0000000..b839deb --- /dev/null +++ b/Jel/Views/Item/Person/ItemPersonIconView.swift @@ -0,0 +1,75 @@ +// +// ItemPersonIconView.swift +// Jel +// +// Created by zerocool on 1/8/24. +// + +import SwiftUI +import JellyfinKit +import NukeUI + +struct ItemPersonIconPlaceholderView: View { + var body: some View { + ZStack { + Color(uiColor: UIColor.secondarySystemBackground) + Image(systemName: "person.fill") + .resizable() + .aspectRatio(contentMode: .fit) + .padding() + .foregroundStyle(Color(uiColor: UIColor.secondarySystemFill)) + } + .frame(height: 150) + .clipShape(RoundedRectangle(cornerRadius: 5)) + } +} + +struct ItemPersonIconView: View { + @StateObject var authState: AuthStateController = AuthStateController.shared + @EnvironmentObject var jellyfinClient: JellyfinClientController + + var person: BaseItemPerson + + @State var personImageUrl: URL? + + var body: some View { + VStack { + LazyImage(url: personImageUrl) {state in + if let image = state.image { + image + .resizable() + .aspectRatio(contentMode: .fit) + .clipShape(RoundedRectangle(cornerRadius: 5)) + } else { + ItemPersonIconPlaceholderView() + } + } + .frame(height: 170) + + VStack(alignment: .leading) { + Text(person.name ?? "---") + .font(.footnote) + .lineLimit(nil) + Text(person.role ?? "---") + .font(.caption) + .foregroundStyle(Color(uiColor: UIColor.secondaryLabel)) + .fixedSize(horizontal: false, vertical: true) + .lineLimit(nil) + } + .multilineTextAlignment(.leading) + } + .frame(width: 100) + .onAppear { + Task { + let request = Paths.getItemImage(itemID: person.id ?? "", imageType: "Primary") + + let serverUrl = jellyfinClient.getUrl() + personImageUrl = serverUrl?.appending(path: request.url?.absoluteString ?? "") + } + } + } +} + +//#Preview { +// ItemPersonView() +//} |