Skip to content
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

feat(user-feedback): capture envelopes #4535

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
show widget after dismissing
  • Loading branch information
armcknight committed Nov 5, 2024
commit 114a2f5195a4364d4d3737d843905a1a28124267
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,13 @@ var displayingForm = false
@available(iOS 13.0, *)
struct SentryUserFeedbackWidget {
class Window: UIWindow {
class RootViewController: UIViewController, SentryUserFeedbackFormDelegate {
class RootViewController: UIViewController, SentryUserFeedbackFormDelegate, UIAdaptivePresentationControllerDelegate {
let defaultWidgetSpacing: CGFloat = 8

lazy var button = SentryUserFeedbackWidgetButtonView(config: config, action: { sender in
if self.config.widgetConfig.animations {
UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseInOut) {
sender.alpha = 0
}
} else {
sender.isHidden = true
}

displayingForm = true
self.setWidget(visible: false)
let form = SentryUserFeedbackForm(config: self.config, delegate: self)
form.presentationController?.delegate = self
self.present(form, animated: self.config.widgetConfig.animations)
})

Expand Down Expand Up @@ -52,16 +45,22 @@ struct SentryUserFeedbackWidget {
fatalError("init(coder:) has not been implemented")
}

func closeForm() {
// MARK: Helpers

func setWidget(visible: Bool) {
if config.widgetConfig.animations {
UIView.animate(withDuration: 0.3, delay: 0, options: .curveEaseInOut) {
self.button.alpha = 1
self.button.alpha = visible ? 1 : 0
}
} else {
button.isHidden = false
button.isHidden = !visible
}

displayingForm = false
displayingForm = !visible
}

func closeForm() {
setWidget(visible: true)
dismiss(animated: config.widgetConfig.animations)
}

Expand All @@ -75,6 +74,12 @@ struct SentryUserFeedbackWidget {
// TODO: submit
closeForm()
}

// MARK: UIAdaptivePresentationControllerDelegate

func presentationControllerWillDismiss(_ presentationController: UIPresentationController) {
setWidget(visible: true)
}
}

init(config: SentryUserFeedbackConfiguration) {
Expand Down