-
Notifications
You must be signed in to change notification settings - Fork 334
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Customer Center] Build feedback survey from JSON (#3959)
Based off #3933 https://github.com/RevenueCat/purchases-ios/assets/664544/11eae984-294a-4e14-8c40-7c2d50994c09 Can probably use some animations, but tuning that up will come up later It will open a feedback survey for an option if there's one
- Loading branch information
Showing
6 changed files
with
180 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// 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 | ||
// | ||
// FeedbackSurveyData.swift | ||
// | ||
// | ||
// Created by Cesar de la Vega on 14/6/24. | ||
// | ||
|
||
import Foundation | ||
import RevenueCat | ||
|
||
#if os(iOS) | ||
|
||
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | ||
@available(macOS, unavailable) | ||
@available(tvOS, unavailable) | ||
@available(watchOS, unavailable) | ||
class FeedbackSurveyData: ObservableObject { | ||
|
||
var configuration: CustomerCenterConfigData.HelpPath.FeedbackSurvey | ||
var action: (() -> Void) | ||
|
||
init(configuration: CustomerCenterConfigData.HelpPath.FeedbackSurvey, action: @escaping (() -> Void)) { | ||
self.configuration = configuration | ||
self.action = action | ||
} | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
RevenueCatUI/CustomerCenter/Views/FeedbackSurveyView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// | ||
// 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 | ||
// | ||
// FeedbackSurveyView.swift | ||
// | ||
// | ||
// Created by Cesar de la Vega on 12/6/24. | ||
// | ||
|
||
import RevenueCat | ||
import SwiftUI | ||
|
||
#if os(iOS) | ||
|
||
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | ||
@available(macOS, unavailable) | ||
@available(tvOS, unavailable) | ||
@available(watchOS, unavailable) | ||
@available(visionOS, unavailable) | ||
struct FeedbackSurveyView: View { | ||
|
||
@ObservedObject | ||
var feedbackSurveyData: FeedbackSurveyData | ||
|
||
var body: some View { | ||
VStack { | ||
Text(feedbackSurveyData.configuration.title) | ||
.font(.title) | ||
.padding() | ||
|
||
Spacer() | ||
|
||
FeedbackSurveyButtonsView(options: feedbackSurveyData.configuration.options, | ||
action: feedbackSurveyData.action) | ||
} | ||
} | ||
|
||
} | ||
|
||
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | ||
@available(macOS, unavailable) | ||
@available(tvOS, unavailable) | ||
@available(watchOS, unavailable) | ||
@available(visionOS, unavailable) | ||
struct FeedbackSurveyButtonsView: View { | ||
|
||
let options: [CustomerCenterConfigData.HelpPath.FeedbackSurvey.Option] | ||
let action: (() -> Void) | ||
|
||
var body: some View { | ||
VStack(spacing: Self.buttonSpacing) { | ||
ForEach(options, id: \.id) { option in | ||
AsyncButton(action: { | ||
self.action() | ||
}, label: { | ||
Text(option.title) | ||
}) | ||
.buttonStyle(ManageSubscriptionsButtonStyle()) | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
@available(iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0, *) | ||
@available(macOS, unavailable) | ||
@available(tvOS, unavailable) | ||
@available(watchOS, unavailable) | ||
@available(visionOS, unavailable) | ||
extension FeedbackSurveyButtonsView { | ||
|
||
private static let buttonSpacing: CGFloat = 16 | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters