Add playButton child view

This commit is contained in:
Shav Kinderlehrer 2024-01-07 22:47:46 -05:00
parent e807d06319
commit 1f25fa576d
3 changed files with 45 additions and 51 deletions

View File

@ -9,21 +9,17 @@ import SwiftUI
import JellyfinKit
import VisibilityTrackingScrollView
struct ItemMediaView: View {
struct ItemMediaView<Content: View>: View {
@EnvironmentObject var jellyfinClient: JellyfinClientController
@StateObject var authState: AuthStateController = AuthStateController.shared
@State var item: BaseItemDto
@State var loading: Bool = true
@ViewBuilder var playButton: () -> Content
@State var pageScrolled: Bool = false
var body: some View {
GeometryReader {geo in
if loading {
ProgressView()
.progressViewStyle(.circular)
} else {
ScrollView() {
ItemHeaderView(item: item)
.padding(.bottom)
@ -38,6 +34,8 @@ struct ItemMediaView: View {
}
}
playButton()
VStack(alignment: .leading) {
Text(item.taglines?.count ?? 0 > 0 ? item.taglines?[0] ?? "" : "")
.font(.headline)
@ -61,7 +59,6 @@ struct ItemMediaView: View {
}
.ignoresSafeArea()
}
}
.navigationBarTitleDisplayMode(.inline)
.navigationTitle(item.name ?? "Untitled")
.toolbarRole(.editor)
@ -72,17 +69,7 @@ struct ItemMediaView: View {
}
}
.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 {
}
}
}
}
}

View File

@ -15,7 +15,9 @@ struct ItemView: View {
case .movie:
ItemMovieView(item: item)
default:
ItemMediaView(item: item)
ItemMediaView(item: item) {
EmptyView()
}
}
}
}

View File

@ -12,7 +12,12 @@ struct ItemMovieView: View {
@State var item: BaseItemDto
var body: some View {
VStack {
ItemMediaView(item: item)
ItemMediaView(item: item) {
Button("Play") {
}
.buttonStyle(.borderedProminent)
}
}
}
}