Apply ParallaxHeaderScrollView to MovieItemView, SeasonItemView

This commit is contained in:
PangMo5 2021-05-30 18:35:49 +09:00
parent e66d0ce742
commit a16d51ae09
2 changed files with 261 additions and 266 deletions

View File

@ -292,13 +292,7 @@ struct MovieItemView: View {
}
}
var body: some View {
LoadingView(isShowing: $isLoading) {
VStack(alignment: .leading) {
if !isLoading {
if orientationInfo.orientation == .portrait {
GeometryReader { geometry in
VStack {
var portraitHeaderView: some View {
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(fullItem.Id)/Images/Backdrop?maxWidth=550&quality=90&tag=\(fullItem.Backdrop)")!)
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
.placeholder {
@ -307,23 +301,16 @@ struct MovieItemView: View {
.BackdropBlurHash,
size: CGSize(width: 32, height: 32))!)
.resizable()
.frame(width: geometry.size.width + geometry.safeAreaInsets.leading + geometry.safeAreaInsets
.trailing,
height: UIDevice.current
.userInterfaceIdiom == .pad ? 350 :
(geometry.size.width + geometry.safeAreaInsets.leading + geometry.safeAreaInsets
.trailing) * 0.5625)
}
.opacity(0.3)
.aspectRatio(contentMode: .fill)
.frame(width: geometry.size.width + geometry.safeAreaInsets.leading + geometry.safeAreaInsets.trailing,
height: UIDevice.current
.userInterfaceIdiom == .pad ? 350 :
(geometry.size.width + geometry.safeAreaInsets.leading + geometry.safeAreaInsets.trailing) *
0.5625)
.shadow(radius: 5)
.overlay(HStack {
}
var portraitHeaderOverlayView: some View {
VStack(alignment: .leading) {
HStack(alignment: .bottom, spacing: 12) {
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(fullItem.Id)/Images/Primary?maxWidth=250&quality=90&tag=\(fullItem.Poster)")!)
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
.placeholder {
@ -373,11 +360,9 @@ struct MovieItemView: View {
}
}
}.frame(maxWidth: .infinity, alignment: .leading)
}.offset(x: 0, y: UIDevice.current.userInterfaceIdiom == .pad ? -98 : -46)
.padding(.trailing, 16)
}.offset(x: 16, y: UIDevice.current.userInterfaceIdiom == .pad ? 135 : 40),
alignment: .bottomLeading)
VStack(alignment: .leading) {
}
.padding(.bottom, UIDevice.current.userInterfaceIdiom == .pad ? 98 : 26)
}
HStack {
// Play button
Button {
@ -418,9 +403,27 @@ struct MovieItemView: View {
}
}
}
}.padding(.leading, 16).padding(.trailing, 16)
ScrollView {
}
}
.padding(.horizontal, 16)
.padding(.bottom, UIDevice.current.userInterfaceIdiom == .pad ? -135 : -60)
}
var body: some View {
LoadingView(isShowing: $isLoading) {
VStack(alignment: .leading) {
if !isLoading {
if orientationInfo.orientation == .portrait {
ParallaxHeaderScrollView(header: portraitHeaderView,
staticOverlayView: portraitHeaderOverlayView,
overlayAlignment: .bottomLeading,
headerHeight: UIDevice.current
.userInterfaceIdiom == .pad ? 350 :
UIScreen.main.bounds.width * 0.5625) {
VStack(alignment: .leading) {
Spacer()
.frame(height: UIDevice.current.userInterfaceIdiom == .pad ? 135 : 60)
.padding(.bottom, 8)
if fullItem.Tagline != "" {
Text(fullItem.Tagline).font(.body).italic().padding(.top, 7)
.fixedSize(horizontal: false, vertical: true).padding(.leading, 16)
@ -517,14 +520,9 @@ struct MovieItemView: View {
Spacer().frame(height: 3)
}
}
}
.padding(EdgeInsets(top: UIDevice.current.userInterfaceIdiom == .pad ? 54 : 24, leading: 0, bottom: 0,
trailing: 0))
}
}
} else {
GeometryReader { geometry in
ZStack() {
ZStack {
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(fullItem.Id)/Images/Backdrop?maxWidth=\(String(Int(geometry.size.width + geometry.safeAreaInsets.leading + geometry.safeAreaInsets.trailing)))&quality=80&tag=\(fullItem.Backdrop)")!)
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
.placeholder {
@ -545,8 +543,8 @@ struct MovieItemView: View {
height: geometry.size.height + geometry.safeAreaInsets.top + geometry.safeAreaInsets.bottom)
.edgesIgnoringSafeArea(.all)
.blur(radius: 2)
HStack() {
VStack() {
HStack {
VStack {
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(fullItem.Id)/Images/Primary?maxWidth=250&quality=90&tag=\(fullItem.Poster)")!)
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
.placeholder {

View File

@ -185,9 +185,8 @@ struct SeasonItemView: View {
return result
}
func portraitHeaderView(proxy: GeometryProxy) -> some View {
let yOffset = proxy.frame(in: .global).minY > 0 ? -proxy.frame(in: .global).minY : 0
return WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(fullItem.SeriesId ?? "")/Images/Backdrop?maxWidth=750&quality=80&tag=\(item.SeasonImage ?? "")")!)
var portraitHeaderView: some View {
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(fullItem.SeriesId ?? "")/Images/Backdrop?maxWidth=750&quality=80&tag=\(item.SeasonImage ?? "")")!)
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
.placeholder {
Image(uiImage: UIImage(blurHash: item
@ -195,15 +194,14 @@ struct SeasonItemView: View {
.SeasonImageBlurHash ?? "",
size: CGSize(width: 32, height: 32))!)
.resizable()
.frame(width: proxy.size.width, height: proxy.size.height - yOffset)
}
.opacity(0.4)
.aspectRatio(contentMode: .fill)
.frame(width: proxy.size.width, height: proxy.size.height - yOffset)
.shadow(radius: 5)
.overlay(HStack(alignment: .bottom, spacing: 12) {
}
var portraitHeaderOverlayView: some View {
HStack(alignment: .bottom, spacing: 12) {
WebImage(url: URL(string: "\(globalData.server?.baseURI ?? "")/Items/\(fullItem.Id)/Images/Primary?maxWidth=250&quality=90&tag=\(fullItem.Poster)")!)
.resizable() // Resizable like SwiftUI.Image, you must use this modifier or the view will use the image bitmap size
.placeholder {
@ -236,9 +234,7 @@ struct SeasonItemView: View {
}
}
}.padding(.horizontal, 16)
.padding(.bottom, -22),
alignment: .bottomLeading)
.offset(y: yOffset)
.padding(.bottom, -22)
}
var body: some View {
@ -246,12 +242,13 @@ struct SeasonItemView: View {
LoadingView(isShowing: $isLoading) {
VStack(alignment: .leading) {
if orientationInfo.orientation == .portrait {
ScrollView {
GeometryReader { proxy in
portraitHeaderView(proxy: proxy)
}
.frame(height: UIScreen.main.bounds.width * 0.5625)
ParallaxHeaderScrollView(header: portraitHeaderView,
staticOverlayView: portraitHeaderOverlayView,
overlayAlignment: .bottomLeading,
headerHeight: UIScreen.main.bounds.width * 0.5625) {
VStack(alignment: .leading) {
Spacer()
.frame(height: 22)
if fullItem.Tagline != "" {
Text(fullItem.Tagline).font(.body).italic().padding(.top, 7)
.fixedSize(horizontal: false, vertical: true).padding(.leading, 16)
@ -383,7 +380,7 @@ struct SeasonItemView: View {
.fixedSize(horizontal: false, vertical: true).padding(.leading, 16)
.padding(.trailing, 16)
}
if(fullItem.Overview != "") {
if fullItem.Overview != "" {
Text(fullItem.Overview).font(.footnote).padding(.top, 3)
.fixedSize(horizontal: false, vertical: true).padding(.bottom, 3).padding(.leading, 16)
.padding(.trailing, 16)