From 5896eadd1d53cedc8142bd6a8f399a19c41ed097 Mon Sep 17 00:00:00 2001 From: macmade Date: Mon, 9 Dec 2024 23:11:46 +0100 Subject: [PATCH] chore(Mobile): Fixed popover issues on iPadOS --- SDO-Mobile/Views/ImageInfoView.swift | 17 --------- SDO-Mobile/Views/ImageView.swift | 52 ++++++++-------------------- SDO-Mobile/Views/VideoView.swift | 19 +++------- 3 files changed, 20 insertions(+), 68 deletions(-) diff --git a/SDO-Mobile/Views/ImageInfoView.swift b/SDO-Mobile/Views/ImageInfoView.swift index 7d5c01b..b68e245 100644 --- a/SDO-Mobile/Views/ImageInfoView.swift +++ b/SDO-Mobile/Views/ImageInfoView.swift @@ -28,17 +28,10 @@ struct ImageInfoView: View { @State public var image: ImageData - @Environment( \.dismiss ) var dismiss - var body: some View { VStack { - if UIDevice.current.userInterfaceIdiom == .pad - { - Spacer() - } - Text( self.image.title ) .font( .largeTitle ) .bold() @@ -74,16 +67,6 @@ struct ImageInfoView: View } .padding( .top, 20 ) .frame( maxWidth: .infinity, alignment: .leading ) - - if UIDevice.current.userInterfaceIdiom == .pad - { - Spacer() - SymbolButton( image: "xmark.circle.fill", title: "Close" ) - { - dismiss() - } - .padding( .top ) - } } } } diff --git a/SDO-Mobile/Views/ImageView.swift b/SDO-Mobile/Views/ImageView.swift index 523d87e..9bae8cf 100644 --- a/SDO-Mobile/Views/ImageView.swift +++ b/SDO-Mobile/Views/ImageView.swift @@ -26,10 +26,10 @@ import SwiftUI struct ImageView: View { - @State public var image: ImageData - @State private var isShowingInfoPopover = false - @State private var isShowingVideoPopover = false - @State private var isShowingShareSheet = false + @State public var image: ImageData + @State private var isShowingInfoSheet = false + @State private var isShowingVideoSheet = false + @State private var isShowingShareSheet = false var body: some View { @@ -55,18 +55,18 @@ struct ImageView: View { SymbolButton( image: "video.circle.fill", title: "Show Video" ) { - self.isShowingVideoPopover = true + self.isShowingVideoSheet = true } .iPadOnly { - $0.fullScreenCover( isPresented: $isShowingVideoPopover ) + $0.fullScreenCover( isPresented: $isShowingVideoSheet ) { VideoView( title: self.image.title, video: video ) } } .iPhoneOnly { - $0.popover( isPresented: $isShowingVideoPopover, arrowEdge: .bottom ) + $0.sheet( isPresented: $isShowingVideoSheet ) { VideoView( title: self.image.title, video: video ) } @@ -77,25 +77,13 @@ struct ImageView: View { SymbolButton( image: "info.circle.fill", title: "Show Info" ) { - self.isShowingInfoPopover = true + self.isShowingInfoSheet = true } - .iPadOnly - { - $0.fullScreenCover( isPresented: $isShowingInfoPopover ) - { - ImageInfoView( image: self.image ) - .padding() - .presentationBackground( .regularMaterial ) - } - } - .iPhoneOnly + .sheet( isPresented: $isShowingInfoSheet ) { - $0.popover( isPresented: $isShowingInfoPopover, arrowEdge: .bottom ) - { - ImageInfoView( image: self.image ) - .padding() - .presentationBackground( .regularMaterial ) - } + ImageInfoView( image: self.image ) + .padding() + .presentationBackground( .regularMaterial ) } } @@ -103,21 +91,11 @@ struct ImageView: View { SymbolButton( image: "paperplane.circle.fill", title: "Share" ) { - if UIDevice.current.userInterfaceIdiom == .pad - { - self.isShowingShareSheet = true - } - else - { - SDOApp.share( url: url ) - } + self.isShowingShareSheet = true } - .iPadOnly + .sheet( isPresented: $isShowingShareSheet ) { - $0.sheet( isPresented: $isShowingShareSheet ) - { - ActivityViewController( activityItems: [ url ] ) - } + ActivityViewController( activityItems: [ url ] ) } } } diff --git a/SDO-Mobile/Views/VideoView.swift b/SDO-Mobile/Views/VideoView.swift index 5fcc2a8..26651bc 100644 --- a/SDO-Mobile/Views/VideoView.swift +++ b/SDO-Mobile/Views/VideoView.swift @@ -43,6 +43,7 @@ struct VideoView: View { Spacer() } + ZStack { if let url = self.download?.url @@ -55,23 +56,13 @@ struct VideoView: View .font( .largeTitle ) .bold() .frame( maxWidth: .infinity ) - SymbolButton( image: "paperplane", title: "Share" ) + SymbolButton( image: "paperplane.circle.fill", title: "Share" ) { - if UIDevice.current.userInterfaceIdiom == .pad - { - self.isShowingShareSheet = true - } - else - { - SDOApp.share( url: url ) - } + self.isShowingShareSheet = true } - .iPadOnly + .sheet( isPresented: $isShowingShareSheet ) { - $0.sheet( isPresented: $isShowingShareSheet ) - { - ActivityViewController( activityItems: [ url ] ) - } + ActivityViewController( activityItems: [ url ] ) } .padding( .trailing ) }