fix layout issue of ItemView when landscape

This commit is contained in:
PangMo5 2021-11-10 18:50:08 +09:00
parent 0f78534157
commit 443fcc4b66
1 changed files with 28 additions and 26 deletions

View File

@ -15,25 +15,25 @@ struct ItemLandscapeMainView: View {
@Binding private var videoIsLoading: Bool @Binding private var videoIsLoading: Bool
@EnvironmentObject private var viewModel: ItemViewModel @EnvironmentObject private var viewModel: ItemViewModel
@EnvironmentObject private var videoPlayerItem: VideoPlayerItem @EnvironmentObject private var videoPlayerItem: VideoPlayerItem
init(videoIsLoading: Binding<Bool>) { init(videoIsLoading: Binding<Bool>) {
self._videoIsLoading = videoIsLoading self._videoIsLoading = videoIsLoading
} }
// MARK: innerBody // MARK: innerBody
private var innerBody: some View { private var innerBody: some View {
HStack { HStack {
// MARK: Sidebar Image // MARK: Sidebar Image
VStack { VStack {
ImageView(src: viewModel.item.getPrimaryImage(maxWidth: 130), ImageView(src: viewModel.item.getPrimaryImage(maxWidth: 130),
bh: viewModel.item.getPrimaryImageBlurHash()) bh: viewModel.item.getPrimaryImageBlurHash())
.frame(width: 130, height: 195) .frame(width: 130, height: 195)
.cornerRadius(10) .cornerRadius(10)
Spacer().frame(height: 15) Spacer().frame(height: 15)
Button { Button {
if let playButtonItem = viewModel.playButtonItem { if let playButtonItem = viewModel.playButtonItem {
self.videoPlayerItem.itemToPlay = playButtonItem self.videoPlayerItem.itemToPlay = playButtonItem
@ -41,7 +41,7 @@ struct ItemLandscapeMainView: View {
} }
} label: { } label: {
// MARK: Play // MARK: Play
HStack { HStack {
Image(systemName: "play.fill") Image(systemName: "play.fill")
.foregroundColor(viewModel.playButtonItem == nil ? Color(UIColor.secondaryLabel) : Color.white) .foregroundColor(viewModel.playButtonItem == nil ? Color(UIColor.secondaryLabel) : Color.white)
@ -55,19 +55,19 @@ struct ItemLandscapeMainView: View {
.background(viewModel.playButtonItem == nil ? Color(UIColor.secondarySystemFill) : Color.jellyfinPurple) .background(viewModel.playButtonItem == nil ? Color(UIColor.secondarySystemFill) : Color.jellyfinPurple)
.cornerRadius(10) .cornerRadius(10)
}.disabled(viewModel.playButtonItem == nil) }.disabled(viewModel.playButtonItem == nil)
Spacer() Spacer()
} }
ScrollView { ScrollView {
VStack(alignment: .leading) { VStack(alignment: .leading) {
// MARK: ItemLandscapeTopBarView // MARK: ItemLandscapeTopBarView
ItemLandscapeTopBarView() ItemLandscapeTopBarView()
.environmentObject(viewModel) .environmentObject(viewModel)
// MARK: ItemViewBody // MARK: ItemViewBody
if let episodeViewModel = viewModel as? SeasonItemViewModel { if let episodeViewModel = viewModel as? SeasonItemViewModel {
EpisodeCardVStackView(items: episodeViewModel.episodes) { episode in EpisodeCardVStackView(items: episodeViewModel.episodes) { episode in
itemRouter.route(to: \.item, episode) itemRouter.route(to: \.item, episode)
@ -80,28 +80,30 @@ struct ItemLandscapeMainView: View {
} }
} }
} }
// MARK: body // MARK: body
var body: some View { var body: some View {
VStack { ZStack {
ZStack { // MARK: Backdrop
// MARK: Backdrop
ImageView(src: viewModel.item.getBackdropImage(maxWidth: 200),
ImageView(src: viewModel.item.getBackdropImage(maxWidth: 200), bh: viewModel.item.getBackdropImageBlurHash())
bh: viewModel.item.getBackdropImageBlurHash()) .opacity(0.3)
.opacity(0.3) .edgesIgnoringSafeArea(.all)
.edgesIgnoringSafeArea(.all) .blur(radius: 4)
.blur(radius: 4) .layoutPriority(1)
// iPadOS is making the view go all the way to the edge. // iPadOS is making the view go all the way to the edge.
// We have to accomodate this here // We have to accomodate this here
Group {
if UIDevice.current.userInterfaceIdiom == .pad { if UIDevice.current.userInterfaceIdiom == .pad {
innerBody.padding(.horizontal, 25) innerBody.padding(.horizontal, 25)
} else { } else {
innerBody innerBody
} }
} }
.layoutPriority(2)
} }
} }
} }