Skip to content

Commit

Permalink
Support from iOS 15.
Browse files Browse the repository at this point in the history
  • Loading branch information
nagavcindriqim committed Sep 19, 2024
1 parent 910fe57 commit cd02de4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Sources/UI/SwiftUI/View Modifiers/PhotoPreviewModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

@available(iOS 14.0, *)
@available(iOS 15.0, *)
struct PhotoPreviewModifier: ViewModifier {
@Binding var presented: Bool
let items: [PhotoPreviewItem]
Expand All @@ -26,7 +26,7 @@ struct PhotoPreviewModifier: ViewModifier {
}
}

@available(iOS 14.0, *)
@available(iOS 15.0, *)
public extension View {
func photoPreview(
present: Binding<Bool>,
Expand Down
32 changes: 15 additions & 17 deletions Sources/UI/SwiftUI/Views/PhotoPreview/PhotoPreview.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#if os(iOS)
import SwiftUI

@available(iOS 14.0, *)
@available(iOS 15.0, *)
public struct PhotoPreview: View {
let items: [PhotoPreviewItem]
let configuration: PhotoPreviewConfiguration
Expand All @@ -35,26 +35,24 @@ public struct PhotoPreview: View {
}

public var body: some View {
ZStack {
scrollView
.ignoresSafeArea()
if configuration.showDismissButton {
dismissView
scrollView
.ignoresSafeArea()
.overlay {
if configuration.showDismissButton {
dismissView
}
}
}
.background(
configuration
.backgroundColor
.ignoresSafeArea()
.opacity(backgroundOpacity)
)
.background(
configuration
.backgroundColor
.opacity(backgroundOpacity)
)
}
}

// MARK: - ViewBuilders
@available(iOS 14.0, *)
@available(iOS 15.0, *)
extension PhotoPreview {
@ViewBuilder
var scrollView: some View {
GeometryReader { geometry in
ScrollView(.horizontal, showsIndicators: false) {
Expand Down Expand Up @@ -101,7 +99,7 @@ extension PhotoPreview {
}

// MARK: - Helpers
@available(iOS 14.0, *)
@available(iOS 15.0, *)
extension PhotoPreview {
enum Direction {
case vertical
Expand Down Expand Up @@ -196,7 +194,7 @@ extension PhotoPreview {
}

// MARK: - Gestures
@available(iOS 14.0, *)
@available(iOS 15.0, *)
extension PhotoPreview {
func dragGesture(with geometry: GeometryProxy) -> some Gesture {
DragGesture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Kingfisher
#endif
import SwiftUI

@available(iOS 14.0, *)
@available(iOS 15.0, *)
struct PhotoPreviewItemView: View {
typealias VoidHandler = () -> Swift.Void
typealias DragHandler = (CGFloat) -> Swift.Void
Expand Down Expand Up @@ -60,7 +60,7 @@ struct PhotoPreviewItemView: View {
}

// MARK: - Views
@available(iOS 14.0, *)
@available(iOS 15.0, *)
extension PhotoPreviewItemView {
var imageView: some View {
Group {
Expand Down Expand Up @@ -91,7 +91,7 @@ extension PhotoPreviewItemView {
}

// MARK: - Helper methods
@available(iOS 14.0, *)
@available(iOS 15.0, *)
extension PhotoPreviewItemView {
func endDrag(animated: Bool = true) {
let imageWidth = screenSize.width * scale
Expand Down Expand Up @@ -147,7 +147,7 @@ extension PhotoPreviewItemView {
}

// MARK: - Gestures
@available(iOS 14.0, *)
@available(iOS 15.0, *)
extension PhotoPreviewItemView {
var magnificationGesture: some Gesture {
MagnificationGesture()
Expand Down

0 comments on commit cd02de4

Please sign in to comment.