Skip to content

Commit

Permalink
add PromotionalOfferView
Browse files Browse the repository at this point in the history
  • Loading branch information
vegaro committed Jun 27, 2024
1 parent bd3e629 commit e4f7611
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ import RevenueCat
@available(macOS, unavailable)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@MainActor
class FeedbackSurveyViewModel: ObservableObject {

@Published var feedbackSurveyData: FeedbackSurveyData
@Published
var feedbackSurveyData: FeedbackSurveyData
@Published
var isShowingPromotionalOffer: Bool = false
@Published
var selectedPromotionalOffer: CustomerCenterConfigData.HelpPath.PromotionalOffer?

init(feedbackSurveyData: FeedbackSurveyData) {
self.feedbackSurveyData = feedbackSurveyData
Expand All @@ -39,7 +45,8 @@ class FeedbackSurveyViewModel: ObservableObject {
}

private func applyPromotionalOffer(_ offer: CustomerCenterConfigData.HelpPath.PromotionalOffer) {

selectedPromotionalOffer = offer
isShowingPromotionalOffer = true
}

}
Expand Down
5 changes: 5 additions & 0 deletions RevenueCatUI/CustomerCenter/Views/FeedbackSurveyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ struct FeedbackSurveyView: View {
FeedbackSurveyButtonsView(options: viewModel.feedbackSurveyData.configuration.options,
action: viewModel.handleAction(for:))
}
.sheet(isPresented: $viewModel.isShowingPromotionalOffer) {
if let promotionalOffer = viewModel.selectedPromotionalOffer {
PromotionalOfferView(promotionalOffer: promotionalOffer)
}
}
}

}
Expand Down
43 changes: 43 additions & 0 deletions RevenueCatUI/CustomerCenter/Views/PromotionalOfferView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//
// 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
//
// PromotionalOfferView.swift
//
//
// Created by Cesar de la Vega on 17/6/24.
//

import RevenueCat
import StoreKit
import SwiftUI

@available(iOS 15.0, *)
struct PromotionalOfferView: View {

let promotionalOffer: CustomerCenterConfigData.HelpPath.PromotionalOffer

var body: some View {
VStack {
Text("Special Promotional Offer!")
.font(.largeTitle)
.padding()

Button("Redeem Offer") {
redeemOffer(promotionalOffer)
}
.buttonStyle(ManageSubscriptionsButtonStyle())
}
.padding()
}

private func redeemOffer(_ offer: CustomerCenterConfigData.HelpPath.PromotionalOffer) {

}

}

0 comments on commit e4f7611

Please sign in to comment.