Skip to content

Commit 88a13e6

Browse files
committed
@dev # Fix swift build error
1 parent 3374302 commit 88a13e6

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Package.resolved

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"pins" : [
3+
{
4+
"identity" : "swiftui-introspect",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/siteline/swiftui-introspect",
7+
"state" : {
8+
"revision" : "807f73ce09a9b9723f12385e592b4e0aaebd3336",
9+
"version" : "1.3.0"
10+
}
11+
}
12+
],
13+
"version" : 2
14+
}

Sources/PopupView/Modifiers.swift

+6
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,33 @@ struct OrientationChangeModifier: ViewModifier {
7777
func body(content: Content) -> some View {
7878
content
7979
.onAppear {
80+
#if os(iOS)
8081
NotificationCenter.default.addObserver(forName: UIDevice.orientationDidChangeNotification, object: nil, queue: .main) { _ in
8182
updateOrientation()
8283
}
8384
updateOrientation()
85+
#endif
8486
}
8587
.onDisappear {
88+
#if os(iOS)
8689
NotificationCenter.default.removeObserver(self, name: UIDevice.orientationDidChangeNotification, object: nil)
90+
#endif
8791
}
8892
.onChange(of: isLandscape) { _ in
8993
onOrientationChange()
9094
}
9195
}
9296

9397
private func updateOrientation() {
98+
#if os(iOS)
9499
DispatchQueue.main.async {
95100
let newIsLandscape = UIDevice.current.orientation.isLandscape
96101
if newIsLandscape != isLandscape {
97102
isLandscape = newIsLandscape
98103
onOrientationChange()
99104
}
100105
}
106+
#endif
101107
}
102108
}
103109

Sources/PopupView/PopupView.swift

+6
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,9 @@ public struct Popup<PopupContent: View>: ViewModifier {
390390
/// Variables used to control what is animated and what is not
391391
@State var actualCurrentOffset = CGPoint.pointFarAwayFromScreen
392392
@State var actualScale = 1.0
393+
#if os(iOS)
393394
@State private var isLandscape: Bool = UIDevice.current.orientation.isLandscape
395+
#endif
394396
// MARK: - Drag to dismiss
395397

396398
/// Drag to dismiss gesture state
@@ -707,9 +709,11 @@ public struct Popup<PopupContent: View>: ViewModifier {
707709
.onChange(of: sheetContentRect.size) { sheetContentRect in
708710
positionIsCalculatedCallback()
709711
}
712+
#if os(iOS)
710713
.onOrientationChange(isLandscape: $isLandscape) {
711714
actualCurrentOffset = targetCurrentOffset
712715
}
716+
#endif
713717
}
714718
} else { // ios 16
715719
ZStack {
@@ -750,9 +754,11 @@ public struct Popup<PopupContent: View>: ViewModifier {
750754
.onChange(of: sheetContentRect.size) { sheetContentRect in
751755
positionIsCalculatedCallback()
752756
}
757+
#if os(iOS)
753758
.onOrientationChange(isLandscape: $isLandscape) {
754759
actualCurrentOffset = targetCurrentOffset
755760
}
761+
#endif
756762
}
757763
}
758764
}

0 commit comments

Comments
 (0)