mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
### Context:
`#if os(iOS)` no longer evaluates to `true` when compiling for
`visionOS`
Which means we need `|| os(xrOS)`.
But to support older Xcode we need `#if swift(>=5.9) && os(xrOS)`.
But, fun fact, short-circuiting doesn’t work in `Xcode 13`.
And we still need that to run iOS <15 tests (`FB12223404` /
`FB12805891`)
💩
This works around that by defining our own `VISION_OS` flag.
### Changes:
- Added `VISION_OS` compile time flag to determine SDK
- Replaced `#if os(xrOS)` with `#if VISION_OS`
- Added flag to `Package.swift` (thanks @neonichu for helping with this)
49 lines
1.5 KiB
Swift
49 lines
1.5 KiB
Swift
//
|
|
// Copyright RevenueCat Inc. All Rights Reserved.
|
|
//
|
|
// Licensed under the MIT License (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// https://opensource.org/licenses/MIT
|
|
//
|
|
// DebugViewSheetPresentation.swift
|
|
//
|
|
// Created by Nacho Soto on 5/30/23.
|
|
|
|
#if DEBUG && swift(>=5.8) && (os(iOS) || os(macOS) || VISION_OS)
|
|
|
|
import SwiftUI
|
|
|
|
@available(iOS 16.0, macOS 13.0, *)
|
|
extension View {
|
|
|
|
@ViewBuilder
|
|
func bottomSheet(
|
|
presentationDetents: Set<PresentationDetent>,
|
|
isPresented: Binding<Bool>,
|
|
largestUndimmedIdentifier: PresentationDetent = .large,
|
|
cornerRadius: CGFloat,
|
|
interactiveDismissDisabled: Bool = false,
|
|
@ViewBuilder content: @escaping () -> some View
|
|
) -> some View {
|
|
self
|
|
.sheet(isPresented: isPresented) {
|
|
let result = content()
|
|
.presentationDetents(presentationDetents)
|
|
.presentationDragIndicator(.automatic)
|
|
.interactiveDismissDisabled(interactiveDismissDisabled)
|
|
|
|
if #available(iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4, *) {
|
|
result
|
|
.presentationCornerRadius(cornerRadius)
|
|
.presentationBackgroundInteraction(.enabled(upThrough: largestUndimmedIdentifier))
|
|
} else {
|
|
result
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|