jel/Jel/Views/Library/Item/ItemHeaderView.swift

60 lines
1.6 KiB
Swift
Raw Normal View History

2023-12-24 04:47:21 +00:00
//
// ItemHeaderView.swift
// Jel
//
// Created by zerocool on 12/23/23.
//
import SwiftUI
import JellyfinKit
struct ItemHeaderView: View {
@State var item: BaseItemDto
let overlayGradient = LinearGradient(gradient: Gradient(stops: [
.init(color: .clear, location: 0),
2023-12-25 01:01:52 +00:00
.init(color: .black, location: 0.5),
// .init(color: .black, location: 0.7),
// .init(color: .clear, location: 1)
2023-12-24 04:47:21 +00:00
]), startPoint: .bottom, endPoint: .top)
var body: some View {
ZStack(alignment: .bottom) {
2023-12-25 01:01:52 +00:00
StickyHeaderView(minHeight: 300) {
LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill)
.hideCaption()
.setCornerRadius(0)
.mask(overlayGradient)
.background {
LibraryIconView(library: item, imageType: "Backdrop", contentMode: .fill)
.hideCaption()
.setCornerRadius(0)
.blur(radius: 50)
}
}
2023-12-24 04:47:21 +00:00
HStack {
LibraryIconView(library: item, imageType: "Logo", width: 200, height: 100, placeHolder: AnyView(Text(item.name ?? "Unknown").font(.title).bold().truncationMode(.middle)))
2023-12-24 04:47:21 +00:00
.hideCaption()
.setCornerRadius(0)
.shadow(radius: 10)
2023-12-25 01:01:52 +00:00
.frame(alignment: .leading)
2023-12-24 04:47:21 +00:00
Spacer()
2023-12-25 01:01:52 +00:00
ItemInfoView(item: item)
.foregroundStyle(.white)
2023-12-24 04:47:21 +00:00
}
2023-12-25 01:01:52 +00:00
.padding([.leading, .trailing])
}
.scrollTransition {content, phase in
content
.scaleEffect(phase.isIdentity ? 1 : 2)
.opacity(phase.isIdentity ? 1 : 0.1)
.blur(radius: phase.isIdentity ? 0 : 50)
2023-12-24 04:47:21 +00:00
}
}
}
// #Preview {
// ItemHeaderView(item: BaseItemDto())
// }