-
Notifications
You must be signed in to change notification settings - Fork 428
Add onCustomerCenterManagementOptionSelected modifier
#4872
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d9528e
Add CustomerCenterManagementOption handler
vegaro fbc4c7b
fix linter
vegaro be637a9
remove CustomerCenterManagementOptionWrapper
vegaro e12cc23
Merge branch 'main' into button-tapped
vegaro f8b9f7c
update label
vegaro 1975519
made CustomerCenterManagementOption items public
vegaro 7547888
fix linter
vegaro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
38 changes: 38 additions & 0 deletions
38
RevenueCatUI/CustomerCenter/Data/CustomerCenterManagementOption.swift
This file contains hidden or 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,38 @@ | ||
| // | ||
| // 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 | ||
| // | ||
| // CustomerCenterManagementOption.swift | ||
| // | ||
| // Created by Cesar de la Vega on 11/3/25. | ||
|
|
||
| import Foundation | ||
|
|
||
| /// Protocol for action types that can be handled by the Customer Center | ||
| public protocol CustomerCenterActionable {} | ||
|
|
||
| /// Management options that can be triggered by buttons in the Customer Center | ||
| public enum CustomerCenterManagementOption { | ||
| /// Represents a cancel action | ||
| public struct Cancel: CustomerCenterActionable {} | ||
|
|
||
| /// Represents an action to open a custom URL | ||
| public struct CustomUrl: CustomerCenterActionable { | ||
| /// The URL that will be opened | ||
| public let url: URL | ||
| } | ||
|
|
||
| /// Represents a missing purchase (restore) action | ||
| public struct MissingPurchase: CustomerCenterActionable {} | ||
|
|
||
| /// Represents a refund request action | ||
| public struct RefundRequest: CustomerCenterActionable {} | ||
|
|
||
| /// Represents a change plans action | ||
| public struct ChangePlans: CustomerCenterActionable {} | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -147,6 +147,7 @@ extension View { | |
| refundRequestStarted: CustomerCenterView.RefundRequestStartedHandler? = nil, | ||
| refundRequestCompleted: CustomerCenterView.RefundRequestCompletedHandler? = nil, | ||
| feedbackSurveyCompleted: CustomerCenterView.FeedbackSurveyCompletedHandler? = nil, | ||
| managementOptionSelected: CustomerCenterView.ManagementOptionSelectedHandler? = nil, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! I totally missed this |
||
| onDismiss: (() -> Void)? = nil | ||
| ) -> some View { | ||
| self.modifier( | ||
|
|
@@ -161,7 +162,8 @@ extension View { | |
| showingManageSubscriptions: showingManageSubscriptions, | ||
| refundRequestStarted: refundRequestStarted, | ||
| refundRequestCompleted: refundRequestCompleted, | ||
| feedbackSurveyCompleted: feedbackSurveyCompleted | ||
| feedbackSurveyCompleted: feedbackSurveyCompleted, | ||
| managementOptionSelected: managementOptionSelected | ||
| ) | ||
| ) | ||
| } | ||
|
|
@@ -181,6 +183,7 @@ private struct PresentingCustomerCenterModifier: ViewModifier { | |
| let refundRequestStarted: CustomerCenterView.RefundRequestStartedHandler? | ||
| let refundRequestCompleted: CustomerCenterView.RefundRequestCompletedHandler? | ||
| let feedbackSurveyCompleted: CustomerCenterView.FeedbackSurveyCompletedHandler? | ||
| let managementOptionSelected: CustomerCenterView.ManagementOptionSelectedHandler? | ||
|
|
||
| /// The closure to execute when dismissing the sheet / fullScreen present | ||
| let onDismiss: (() -> Void)? | ||
|
|
@@ -197,6 +200,7 @@ private struct PresentingCustomerCenterModifier: ViewModifier { | |
| refundRequestStarted: CustomerCenterView.RefundRequestStartedHandler? = nil, | ||
| refundRequestCompleted: CustomerCenterView.RefundRequestCompletedHandler? = nil, | ||
| feedbackSurveyCompleted: CustomerCenterView.FeedbackSurveyCompletedHandler? = nil, | ||
| managementOptionSelected: CustomerCenterView.ManagementOptionSelectedHandler? = nil, | ||
| purchaseHandler: PurchaseHandler? = nil | ||
| ) { | ||
| self._isPresented = isPresented | ||
|
|
@@ -209,6 +213,7 @@ private struct PresentingCustomerCenterModifier: ViewModifier { | |
| self.refundRequestStarted = refundRequestStarted | ||
| self.refundRequestCompleted = refundRequestCompleted | ||
| self.feedbackSurveyCompleted = feedbackSurveyCompleted | ||
| self.managementOptionSelected = managementOptionSelected | ||
| self._purchaseHandler = .init(wrappedValue: purchaseHandler ?? | ||
| PurchaseHandler.default(performPurchase: myAppPurchaseLogic?.performPurchase, | ||
| performRestore: myAppPurchaseLogic?.performRestore)) | ||
|
|
@@ -265,6 +270,9 @@ private struct PresentingCustomerCenterModifier: ViewModifier { | |
| .onCustomerCenterFeedbackSurveyCompleted { [feedbackSurveyCompleted] optionId in | ||
| feedbackSurveyCompleted?(optionId) | ||
| } | ||
| .onCustomerCenterManagementOptionSelected { action in | ||
| managementOptionSelected?(action) | ||
| } | ||
| .interactiveDismissDisabled(self.purchaseHandler.actionInProgress) | ||
| } | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is painful, not being able to use a "real"
enumfor this 😢