diff options
Diffstat (limited to 'Jel/Views/Dashboard/Library')
-rw-r--r-- | Jel/Views/Dashboard/Library/LibraryIconView.swift | 22 | ||||
-rw-r--r-- | Jel/Views/Dashboard/Library/LibraryView.swift | 44 |
2 files changed, 63 insertions, 3 deletions
diff --git a/Jel/Views/Dashboard/Library/LibraryIconView.swift b/Jel/Views/Dashboard/Library/LibraryIconView.swift index 4f6c711..c4dbde0 100644 --- a/Jel/Views/Dashboard/Library/LibraryIconView.swift +++ b/Jel/Views/Dashboard/Library/LibraryIconView.swift @@ -6,13 +6,29 @@ // import SwiftUI +import JellyfinKit +import BlurHashKit struct LibraryIconView: View { - var body: some View { - Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + @EnvironmentObject var jellyfinClient: JellyfinClientController + + @State var library: BaseItemDto + @State var loadingImage: Bool = true + + @State var loadedImageBinaryData: Data? + + var body: some View { + VStack { + AsyncImageView(imageId: library.id ?? "", + blurhash: library.imageBlurHashes?.primary?[library.imageTags?["Primary"] ?? ""] ?? "", + imageType: "Primary") + + Text(library.name ?? "Unknown") + .font(.subheadline) } + } } #Preview { - LibraryIconView() + LibraryIconView(library: BaseItemDto()) } diff --git a/Jel/Views/Dashboard/Library/LibraryView.swift b/Jel/Views/Dashboard/Library/LibraryView.swift new file mode 100644 index 0000000..39ca6ba --- /dev/null +++ b/Jel/Views/Dashboard/Library/LibraryView.swift @@ -0,0 +1,44 @@ +// +// LibraryView.swift +// Jel +// +// Created by zerocool on 12/15/23. +// + +import SwiftUI +import JellyfinKit + +struct LibraryView: View { + @EnvironmentObject var jellyfinClient: JellyfinClientController + + @StateObject var authState: AuthStateController = AuthStateController.shared + + @State var libraries: [BaseItemDto] = [] + var body: some View { + ScrollView(.horizontal, showsIndicators: false) { + LazyHStack { + ForEach(libraries) {library in + if library.collectionType == "movies" || library.collectionType == "tvshows" { + LibraryIconView(library: library) + } + } + } + } + .onAppear { + Task { + do { + let request = Paths.getUserViews(userID: authState.userId ?? "") + if let results = try await jellyfinClient.send(request).value.items { + libraries = results + } + } catch { + print(error) + } + } + } + } +} + +//#Preview { +// LibraryView() +//} |