blob: 68dff23467a65b52f8db388fb1c278ae00493189 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
//
// ItemPersonView.swift
// Jel
//
// Created by zerocool on 1/13/24.
//
import SwiftUI
import JellyfinKit
import ExpandableText
struct ItemPersonViewItemsRow: View {
var items: [BaseItemDto]
var body: some View {
ScrollView(.horizontal) {
HStack(alignment: .top) {
ForEach(items) {item in
NavigationLink {
ItemView(item: item)
} label: {
ItemIconView(item: item, width: 150)
.showCaption()
.setAspectRatio(item.primaryImageAspectRatio ?? 0.6)
}
.buttonStyle(PlainButtonStyle())
}
}
.padding(.horizontal)
}
}
}
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([.horizontal, .top])
if let overview = item.overviewNL {
ExpandableText(overview)
.lineLimit(8)
.padding([.horizontal, .bottom])
}
if let items = items {
let movies = items.filter({$0.type == .movie})
if movies.count > 0 {
Text("Movies")
.font(.title2)
.padding(.horizontal)
ItemPersonViewItemsRow(items: movies)
}
let shows = items.filter({$0.type == .series})
if shows.count > 0 {
Text("Shows")
.font(.title2)
.padding(.horizontal)
ItemPersonViewItemsRow(items: shows)
}
}
}
.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()
//}
|