Skip to content

Commit

Permalink
Paywalls: disabled PaywallViewModes for now (#2874)
Browse files Browse the repository at this point in the history
We won't ship these initially, but still leaving the infrastructure in
place.
  • Loading branch information
NachoSoto committed Sep 14, 2023
1 parent 3bdc58c commit 7792581
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 19 deletions.
4 changes: 2 additions & 2 deletions RevenueCatUI/Data/PaywallViewMode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ public enum PaywallViewMode {
case fullScreen

/// Paywall is displayed with a square aspect ratio. It can be embedded inside any other SwiftUI view.
@available(*, unavailable, message: "Other modes coming soon.")
case card

/// Paywall is displayed in a condensed format. It can be embedded inside any other SwiftUI view.
@available(*, unavailable, message: "Other modes coming soon.")
case banner

/// The default ``PaywallViewMode``: ``PaywallViewMode/fullScreen``.
public static let `default`: Self = .fullScreen

}

extension PaywallViewMode: CaseIterable {}

extension PaywallViewMode {

var isFullScreen: Bool {
Expand Down
6 changes: 5 additions & 1 deletion RevenueCatUI/Views/PurchaseButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,16 @@ struct PurchaseButton_Previews: PreviewProvider {
}

static var previews: some View {
ForEach(PaywallViewMode.allCases, id: \.self) { mode in
ForEach(Self.modes, id: \.self) { mode in
Preview(mode: mode)
.previewLayout(.sizeThatFits)
}
}

private static let modes: [PaywallViewMode] = [
.fullScreen
]

}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct App: View {
PaywallView()
PaywallView(mode: .fullScreen)
PaywallView(offering: self.offering)
PaywallView(offering: self.offering, mode: .card)
PaywallView(offering: self.offering, mode: .fullScreen)
}

@ViewBuilder
Expand Down
4 changes: 4 additions & 0 deletions Tests/RevenueCatUITests/BaseSnapshotTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@ extension BaseSnapshotTest {
static let purchaseHandler: PurchaseHandler = .mock()

static let fullScreenSize: CGSize = .init(width: 460, height: 950)

// Disabled until we bring modes back.
/*
static let cardSize: CGSize = .init(width: 460, height: 460)
static let bannerSize: CGSize = .init(width: 380, height: 70)
*/

}
3 changes: 3 additions & 0 deletions Tests/RevenueCatUITests/SinglePackagePaywallViewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class SinglePackagePaywallViewTests: BaseSnapshotTest {
view.snapshot(size: Self.fullScreenSize)
}

// Disabled until we bring modes back.
/*
func testCardPaywall() {
let view = PaywallView(offering: Self.offeringWithNoIntroOffer,
mode: .card,
Expand All @@ -35,6 +37,7 @@ class SinglePackagePaywallViewTests: BaseSnapshotTest {
view.snapshot(size: Self.bannerSize)
}
*/

func testSamplePaywallWithIntroOffer() {
let view = PaywallView(offering: Self.offeringWithIntroOffer,
Expand Down
16 changes: 1 addition & 15 deletions Tests/TestingApps/SimpleApp/SimpleApp/Views/AppContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,12 @@ struct AppContentView: View {
Text(verbatim: "You're signed in: \(info.originalAppUserId)")
.font(.callout)

if self.shouldDisplayPaywall {
PaywallView(mode: .banner)
}

Spacer()

BarChartView(data: (0..<10).map { _ in Double.random(in: 0..<100)})
.frame(maxWidth: .infinity)

if self.shouldDisplayPaywall {
PaywallView(mode: .card)
} else if let date = info.latestExpirationDate {
if let date = info.latestExpirationDate {
Text(verbatim: "Your subscription expires: \(date.formatted())")
.font(.caption)
}
Expand All @@ -71,14 +65,6 @@ struct AppContentView: View {
}
}

private var displayNonFullScreenPaywalls: Bool {
return false
}

private var shouldDisplayPaywall: Bool {
return self.displayNonFullScreenPaywalls && self.customerInfo?.hasPro == false
}

}


Expand Down

0 comments on commit 7792581

Please sign in to comment.