Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugRevenueCatOverlay: added support for macOS #2648

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was wrong.

#if swift(>=5.9)

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