Skip to content

Commit 962ce25

Browse files
committed
Add background sheet modifier
1 parent db617f6 commit 962ce25

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

Modules/Sources/ArticleFeature/Views/ArticleElementView.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,12 +120,7 @@ struct ArticleElementView: View {
120120
showFullScreenImage.toggle()
121121
}
122122
.fullScreenCover(isPresented: $showFullScreenImage) {
123-
if #available(iOS 16.4, *) {
124-
TabViewGallery(gallery: [element], showScreenGallery: $showFullScreenImage, selectedImageID: $selectedImageID)
125-
.presentationBackground(.clear)
126-
} else {
127-
TabViewGallery(gallery: [element], showScreenGallery: $showFullScreenImage, selectedImageID: $selectedImageID)
128-
}
123+
TabViewGallery(gallery: [element.url], showScreenGallery: $showFullScreenImage, selectedImageID: $selectedImageID)
129124
}
130125
}
131126

@@ -161,12 +156,7 @@ struct ArticleElementView: View {
161156
.indexViewStyle(.page(backgroundDisplayMode: .always))
162157
.padding(.bottom, -16)
163158
.fullScreenCover(isPresented: $showFullScreenGallery) {
164-
if #available(iOS 16.4, *) {
165-
TabViewGallery(gallery: element, showScreenGallery: $showFullScreenGallery, selectedImageID: $selectedImageID)
166-
.presentationBackground(.clear)
167-
} else {
168-
TabViewGallery(gallery: element, showScreenGallery: $showFullScreenGallery, selectedImageID: $selectedImageID)
169-
}
159+
TabViewGallery(gallery: element.map{ $0.url }, showScreenGallery: $showFullScreenGallery, selectedImageID: $selectedImageID)
170160
}
171161
}
172162

Modules/Sources/ArticleFeature/Views/Gallery/TabViewGallery.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ struct TabViewGallery: View {
6363
ShareSheet(activityItems: $activityItems)
6464
.presentationDetents([.medium])
6565
}
66+
.presentationBackgroundClear()
6667
}
6768

6869
// MARK: - ToolBarView
@@ -205,6 +206,23 @@ struct ShareSheet: UIViewControllerRepresentable {
205206
func updateUIViewController(_ uiViewController: UIActivityViewController, context: Context) {}
206207
}
207208

209+
extension View {
210+
func presentationBackgroundClear() -> some View {
211+
self.modifier(BackgroundView())
212+
}
213+
}
214+
215+
struct BackgroundView: ViewModifier {
216+
func body(content: Content) -> some View {
217+
if #available(iOS 16.4, *) {
218+
content
219+
.presentationBackground(.clear)
220+
} else {
221+
content
222+
}
223+
}
224+
}
225+
208226
// MARK: - Preview
209227

210228
#Preview {

0 commit comments

Comments
 (0)