diff options
author | Shav Kinderlehrer <[email protected]> | 2024-02-13 21:37:02 -0500 |
---|---|---|
committer | Shav Kinderlehrer <[email protected]> | 2024-02-13 21:37:02 -0500 |
commit | 5c0aeedc3d9b2f7a8427fb7973d2ce8ec24ae257 (patch) | |
tree | 99c98fbe6c0164c9834ea76d636293ba70e44247 /Jel/Views | |
parent | 2d9d946bae8e2fa2dd0daea741442c7fa8350ad5 (diff) | |
download | jel-5c0aeedc3d9b2f7a8427fb7973d2ce8ec24ae257.tar.gz jel-5c0aeedc3d9b2f7a8427fb7973d2ce8ec24ae257.zip |
Create ItemSeriesView + start ItemSeasonView
Diffstat (limited to 'Jel/Views')
-rw-r--r-- | Jel/Views/Item/ItemIconView.swift | 16 | ||||
-rw-r--r-- | Jel/Views/Item/ItemMediaView.swift | 3 | ||||
-rw-r--r-- | Jel/Views/Item/ItemView.swift | 4 | ||||
-rw-r--r-- | Jel/Views/Item/Series/ItemSeriesSeriesView.swift | 58 | ||||
-rw-r--r-- | Jel/Views/Item/Types/ItemPersonView.swift | 1 | ||||
-rw-r--r-- | Jel/Views/Item/Types/ItemSeasonView.swift | 23 | ||||
-rw-r--r-- | Jel/Views/Item/Types/ItemSeriesView.swift | 58 |
7 files changed, 153 insertions, 10 deletions
diff --git a/Jel/Views/Item/ItemIconView.swift b/Jel/Views/Item/ItemIconView.swift index c4e958e..906ed01 100644 --- a/Jel/Views/Item/ItemIconView.swift +++ b/Jel/Views/Item/ItemIconView.swift @@ -18,11 +18,11 @@ struct ItemIconView: View { var width: CGFloat? var height: CGFloat? - @State var blurHashImage: UIImage = UIImage() + @State var blurHashImage: UIImage? = UIImage() @State var imageUrl: URL? @State var contentMode: ContentMode = .fit - var placeHolder: AnyView? = AnyView(Color(uiColor: UIColor.secondarySystemBackground)) + var placeHolder: AnyView? var shouldShowCaption: Bool = false var imageCornerRadius: CGFloat = 5 @@ -37,9 +37,13 @@ struct ItemIconView: View { if let content = placeHolder { content } else { - Image(uiImage: blurHashImage) - .resizable() - .aspectRatio(contentMode: .fill) + if let blurHash = blurHashImage { + Image(uiImage: blurHash) + .resizable() + .aspectRatio(contentMode: .fill) + } else { + Color(uiColor: UIColor.secondarySystemBackground) + } } } } @@ -47,7 +51,7 @@ struct ItemIconView: View { .clipShape(RoundedRectangle(cornerRadius: imageCornerRadius)) .onAppear { let blurhash = getBlurHash(imageType: imageType) - blurHashImage = UIImage(blurHash: blurhash, size: CGSize(width: 32, height: 32)) ?? UIImage() + blurHashImage = UIImage(blurHash: blurhash, size: CGSize(width: 32, height: 32)) let imageId = item.id ?? "" let request = Paths.getItemImage(itemID: imageId, imageType: imageType) diff --git a/Jel/Views/Item/ItemMediaView.swift b/Jel/Views/Item/ItemMediaView.swift index 75fa2e1..efcfb55 100644 --- a/Jel/Views/Item/ItemMediaView.swift +++ b/Jel/Views/Item/ItemMediaView.swift @@ -10,9 +10,6 @@ import JellyfinKit import ExpandableText struct ItemMediaView: View { - @EnvironmentObject var jellyfinClient: JellyfinClientController - @StateObject var authState: AuthStateController = AuthStateController.shared - var item: BaseItemDto diff --git a/Jel/Views/Item/ItemView.swift b/Jel/Views/Item/ItemView.swift index 7611450..f8eba43 100644 --- a/Jel/Views/Item/ItemView.swift +++ b/Jel/Views/Item/ItemView.swift @@ -16,6 +16,10 @@ struct ItemView: View { switch item.type { case .movie: ItemMovieView(item: item) + case .series: + ItemSeriesView(item: item) + case .season: + ItemSeasonView(item: item) case .person: ItemPersonView(item: item) default: diff --git a/Jel/Views/Item/Series/ItemSeriesSeriesView.swift b/Jel/Views/Item/Series/ItemSeriesSeriesView.swift new file mode 100644 index 0000000..1e54185 --- /dev/null +++ b/Jel/Views/Item/Series/ItemSeriesSeriesView.swift @@ -0,0 +1,58 @@ +// +// ItemSeriesSeriesView.swift +// Jel +// +// Created by zerocool on 2/12/24. +// + +import SwiftUI +import JellyfinKit + +struct ItemSeriesSeriesView: View { + var item: BaseItemDto + + @EnvironmentObject var jellyfinClient: JellyfinClientController + @StateObject var authState: AuthStateController = AuthStateController.shared + + @State var seriesItems: [BaseItemDto] = [] + + var body: some View { + VStack(alignment: .leading) { + Text("Series") + .font(.title2) + .padding(.horizontal) + + ScrollView(.horizontal) { + LazyHStack { + ForEach(seriesItems) {series in + NavigationLink { + ItemView(item: series) + } label: { + ItemIconView(item: series, height: 170) + .setAspectRatio(series.primaryImageAspectRatio ?? 0.6) + .showCaption() + } + } + }.padding(.horizontal) + } + } + .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) + seriesItems = res.value.items ?? [] + } catch {} + } + } + } +} + +//#Preview { +// ItemSeriesSeriesView() +//} diff --git a/Jel/Views/Item/Types/ItemPersonView.swift b/Jel/Views/Item/Types/ItemPersonView.swift index 0d93281..d9b991d 100644 --- a/Jel/Views/Item/Types/ItemPersonView.swift +++ b/Jel/Views/Item/Types/ItemPersonView.swift @@ -80,7 +80,6 @@ struct ItemPersonView: View { do { let res = try await jellyfinClient.send(request) items = res.value.items ?? [] - print(items![0]) } catch {} } } diff --git a/Jel/Views/Item/Types/ItemSeasonView.swift b/Jel/Views/Item/Types/ItemSeasonView.swift new file mode 100644 index 0000000..9d02dfe --- /dev/null +++ b/Jel/Views/Item/Types/ItemSeasonView.swift @@ -0,0 +1,23 @@ +// +// ItemSeasonView.swift +// Jel +// +// Created by zerocool on 2/13/24. +// + +import SwiftUI +import JellyfinKit + +struct ItemSeasonView: View { + var item: BaseItemDto + + var body: some View { + VStack { + ItemMediaView(item: item) + } + } +} + +//#Preview { +// ItemSeasonView() +//} diff --git a/Jel/Views/Item/Types/ItemSeriesView.swift b/Jel/Views/Item/Types/ItemSeriesView.swift new file mode 100644 index 0000000..f0559b9 --- /dev/null +++ b/Jel/Views/Item/Types/ItemSeriesView.swift @@ -0,0 +1,58 @@ +// +// ItemSeriesView.swift +// Jel +// +// Created by zerocool on 2/12/24. +// + +import SwiftUI +import JellyfinKit + +struct ItemSeriesView: View { + var item: BaseItemDto + + @State var pageScrolled: Bool = false + + var body: some View { + VStack { + ItemHeaderView(item: item) + .foregroundStyle(.white) + .background { + GeometryReader {geo in + EmptyView() + .onChange(of: geo.frame(in: .global).minY) { + let minY = geo.frame(in: .global).minY + + pageScrolled = minY < -150 + } + } + } + + ItemMediaView(item: item) + .padding() + + ItemGenresView(item: item) + .foregroundStyle(Color.primary) + + ItemSeriesSeriesView(item: item) + .foregroundStyle(Color.primary) + + ItemPeopleView(item: item) + .foregroundStyle(Color.primary) + } + .navigationBarTitleDisplayMode(.inline) + .navigationTitle(item.name ?? "Untitled") + .toolbarRole(.editor) + .toolbar { + ToolbarItem(placement: .principal) { + Text(pageScrolled ? item.name ?? "Untitled" : "") + .bold() + } + } + .toolbarBackground(pageScrolled ? .visible : .hidden) + } +} + +//#Preview { +// ItemShowView() +//} |