Skip to content

Commit

Permalink
debugRevenueCatOverlay: added support for macOS (#2648)
Browse files Browse the repository at this point in the history
  • Loading branch information
NachoSoto authored Jun 15, 2023
1 parent 3e2847d commit 7958e91
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
16 changes: 9 additions & 7 deletions Sources/Support/DebugUI/DebugContentViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
//
// Created by Nacho Soto on 5/30/23.

#if DEBUG && os(iOS) && swift(>=5.8)
#if DEBUG && swift(>=5.8) && (os(iOS) || os(macOS))

import StoreKit
import SwiftUI

@available(iOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
struct DebugSwiftUIRootView: View {

@StateObject
Expand Down Expand Up @@ -56,7 +56,7 @@ private enum DebugViewPath: Hashable {

}

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
internal struct DebugSummaryView: View {

@ObservedObject
Expand All @@ -74,7 +74,9 @@ internal struct DebugSummaryView: View {

self.offeringsSection
}
#if os(iOS)
.listStyle(.insetGrouped)
#endif
.scrollContentBackground(.hidden)
.navigationTitle("RevenueCat Debug")
}
Expand Down Expand Up @@ -166,7 +168,7 @@ internal struct DebugSummaryView: View {

}

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
private struct DebugOfferingView: View {

@State private var showingSubscriptionSheet = false
Expand Down Expand Up @@ -268,7 +270,7 @@ private struct DebugOfferingView: View {

}

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
private struct DebugPackageView: View {

var package: Package
Expand Down Expand Up @@ -334,7 +336,7 @@ private struct DebugPackageView: View {

}

@available(iOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
extension DebugViewModel.Configuration: Transferable {

static var transferRepresentation: some TransferRepresentation {
Expand All @@ -349,7 +351,7 @@ extension DebugViewModel.Configuration: Transferable {
}

#if swift(>=5.9)
@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
@available(iOS 17.0, macOS 14.0, *)
private struct ProductStyle: ProductViewStyle {

func makeBody(configuration: ProductViewStyleConfiguration) -> some View {
Expand Down
7 changes: 5 additions & 2 deletions Sources/Support/DebugUI/DebugView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
//
// Created by Nacho Soto on 5/30/23.

#if DEBUG && os(iOS) && swift(>=5.8)
#if DEBUG && swift(>=5.8) && (os(iOS) || os(macOS))

import SwiftUI

@available(iOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
public extension View {

/// Adds a bottom sheet overlay to the current view which allows debugging the current SDK setup.
Expand Down Expand Up @@ -63,6 +63,9 @@ public extension View {
cornerRadius: DebugSwiftUIRootView.cornerRadius,
content: {
DebugSwiftUIRootView()
#if os(macOS)
.frame(width: 500, height: 600)
#endif
}
)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Support/DebugUI/DebugViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

import Foundation

#if DEBUG && os(iOS) && swift(>=5.8)
#if DEBUG && swift(>=5.8) && (os(iOS) || os(macOS))

import SwiftUI

@MainActor
@available(iOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
final class DebugViewModel: ObservableObject {

struct Configuration: Codable {
Expand Down Expand Up @@ -65,7 +65,7 @@ final class DebugViewModel: ObservableObject {

}

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
extension DebugViewModel {

var diagnosticsStatus: String {
Expand Down Expand Up @@ -116,7 +116,7 @@ extension LoadingState where Error == NSError {

}

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
private extension DebugViewModel.Configuration {

static func create(with purchases: Purchases = .shared) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Support/DebugUI/DebugViewSheetPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
//
// Created by Nacho Soto on 5/30/23.

#if DEBUG && os(iOS) && swift(>=5.8)
#if DEBUG && swift(>=5.8) && (os(iOS) || os(macOS))

import SwiftUI

@available(iOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
extension View {

@ViewBuilder
Expand Down
12 changes: 8 additions & 4 deletions Tests/APITesters/SwiftAPITester/SwiftAPITester/OtherAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import RevenueCat
import StoreKit
import SwiftUI

#if DEBUG && os(iOS) && swift(>=5.8)
#if DEBUG && swift(>=5.8) && (os(iOS) || os(macOS))

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
@available(iOS 16.0, macOS 13.0, *)
struct AppView: View {

@State private var debugOverlayVisible: Bool = false
Expand All @@ -26,7 +26,11 @@ struct AppView: View {

}

@available(iOS 16.0, macOS 13.0, tvOS 16.0, *)
#endif

#if DEBUG && os(iOS) && swift(>=5.8)

@available(iOS 16.0, *)
func debugViewController() {
let _: UIViewController = DebugViewController()
UIViewController().presentDebugRevenueCatOverlay()
Expand All @@ -35,7 +39,7 @@ func debugViewController() {

#endif

#if os(iOS) && swift(>=5.9)
#if swift(>=5.9)

@available(iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, *)
struct PaywallViews: View {
Expand Down

0 comments on commit 7958e91

Please sign in to comment.