// // ItemMovieView.swift // Jel // // Created by zerocool on 12/23/23. // import SwiftUI import JellyfinKit struct ItemMovieView: View { @EnvironmentObject var jellyfinClient: JellyfinClientController @StateObject var authState: AuthStateController = AuthStateController.shared @State var item: BaseItemDto @State var loading: Bool = true @State var navigationTitle: String = "" var body: some View { VStack { if loading { ProgressView() .progressViewStyle(.circular) } else { ScrollView { ItemHeaderView(item: item) .padding(.bottom) .background { GeometryReader {geo in EmptyView() .onChange(of: geo.frame(in: .global).minY) { let minY = geo.frame(in: .global).minY if minY < 0 { navigationTitle = item.name ?? "" } else { navigationTitle = "" } } } } VStack(alignment: .leading) { Text(item.taglines?.count ?? 0 > 0 ? item.taglines?[0] ?? "" : "") .font(.headline) .frame(maxWidth: .infinity, alignment: .leading) .padding(.bottom) Text(item.overview ?? "---") } .padding() } } } .toolbarRole(.editor) .navigationBarTitleDisplayMode(.inline) .navigationTitle(navigationTitle) .ignoresSafeArea() .scrollIndicators(.hidden) .onAppear { Task { do { let request = Paths.getItem(userID: authState.userId ?? "", itemID: item.id ?? "") let response = try await jellyfinClient.send(request) item = response.value loading = false } catch { } } } } } //#Preview { // ItemMovieView(item: BaseItemDto()) //}