Skip to content

Commit

Permalink
chore(Mobile): Fixed popover issues on iPadOS
Browse files Browse the repository at this point in the history
  • Loading branch information
macmade committed Dec 9, 2024
1 parent 750fcec commit 5896ead
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 68 deletions.
17 changes: 0 additions & 17 deletions SDO-Mobile/Views/ImageInfoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 )
}
}
}
}
Expand Down
52 changes: 15 additions & 37 deletions SDO-Mobile/Views/ImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 )
}
Expand All @@ -77,47 +77,25 @@ 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 )
}
}

if let url = self.image.imageURL
{
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 ] )
}
}
}
Expand Down
19 changes: 5 additions & 14 deletions SDO-Mobile/Views/VideoView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct VideoView: View
{
Spacer()
}

ZStack
{
if let url = self.download?.url
Expand All @@ -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 )
}
Expand Down

0 comments on commit 5896ead

Please sign in to comment.