Skip to content

Commit

Permalink
[Customer Center] Fix FeedbackSurveyView not opening (#4208)
Browse files Browse the repository at this point in the history
For some reason, the dismiss environment variable was causing the view
to constantly recreate, which was causing a loop when trying to launch
the feedback survey view, and the app would freeze.

I moved the `dismiss` to the `DismissCircleButton` and looks like it has
solved it.
  • Loading branch information
vegaro authored Aug 22, 2024
1 parent 2a786c0 commit bb71e05
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 24 deletions.
9 changes: 3 additions & 6 deletions RevenueCatUI/CustomerCenter/ButtonStyles.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,11 @@ struct ProminentButtonStyle: PrimitiveButtonStyle {
struct DismissCircleButton: View {

@Environment(\.localization) private var localization

var action: () -> Void
@Environment(\.dismiss) private var dismiss

var body: some View {
Button {
action()
self.dismiss()
} label: {
Circle()
.fill(Color(uiColor: .secondarySystemFill))
Expand Down Expand Up @@ -88,9 +87,7 @@ struct ButtonStyles_Previews: PreviewProvider {
Button("Didn't receive purchase") {}
.buttonStyle(ProminentButtonStyle())

DismissCircleButton {

}
DismissCircleButton()
}.padding()
.environment(\.appearance, CustomerCenterConfigTestData.standardAppearance)
.environment(\.localization, CustomerCenterConfigTestData.customerCenterData.localization)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ import SwiftUI
@available(watchOS, unavailable)
struct ManageSubscriptionsView: View {

@Environment(\.dismiss)
var dismiss

@Environment(\.appearance)
private var appearance: CustomerCenterConfigData.Appearance
@Environment(\.localization)
Expand Down Expand Up @@ -102,9 +99,7 @@ struct ManageSubscriptionsView: View {
}
.toolbar {
ToolbarItem(placement: .compatibleTopBarTrailing) {
DismissCircleButton {
dismiss()
}
DismissCircleButton()
}
}
.task {
Expand Down
7 changes: 1 addition & 6 deletions RevenueCatUI/CustomerCenter/Views/NoSubscriptionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ struct NoSubscriptionsView: View {
// TODO: build screen using this configuration
let configuration: CustomerCenterConfigData

@Environment(\.dismiss)
var dismiss

@Environment(\.localization)
private var localization: CustomerCenterConfigData.Localization
@Environment(\.appearance)
Expand Down Expand Up @@ -73,9 +70,7 @@ struct NoSubscriptionsView: View {
}
.toolbar {
ToolbarItem(placement: .compatibleTopBarTrailing) {
DismissCircleButton {
dismiss()
}
DismissCircleButton()
}
}
}
Expand Down
7 changes: 1 addition & 6 deletions RevenueCatUI/CustomerCenter/Views/WrongPlatformView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ struct WrongPlatformView: View {
@State
private var store: Store?

@Environment(\.dismiss)
var dismiss

@Environment(\.localization)
private var localization: CustomerCenterConfigData.Localization
@Environment(\.appearance)
Expand Down Expand Up @@ -84,9 +81,7 @@ struct WrongPlatformView: View {
}
.toolbar {
ToolbarItem(placement: .compatibleTopBarTrailing) {
DismissCircleButton {
dismiss()
}
DismissCircleButton()
}
}
.task {
Expand Down

0 comments on commit bb71e05

Please sign in to comment.