2023-12-22 22:14:21 +00:00
|
|
|
//
|
|
|
|
// 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) {
|
2023-12-23 00:29:07 +00:00
|
|
|
HStack {
|
2023-12-22 22:14:21 +00:00
|
|
|
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()
|
|
|
|
//}
|