-
Notifications
You must be signed in to change notification settings - Fork 3
[3.x backport] fix(instant): make forced conversion sheet non-dismissible #126
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,26 @@ class BottomSheetViewController: UIViewController { | |
| var latestTargetHeight: CGFloat = 0.9 | ||
| var isKeyboardOpen = false | ||
|
|
||
| // When true, swipe-to-dismiss and tap-outside-to-dismiss are disabled for this presentation, | ||
| // and the Hub's `can_touch_background_to_dismiss` message cannot re-enable them. Programmatic | ||
| // dismissal (e.g. after a successful sign-in) is unaffected. Reset on viewDidDisappear. | ||
| // The didSet applies the change to a live sheetController, so toggling the lock after | ||
| // presentation still takes effect (and unlock restores the Hub's most recent preference). | ||
| var isUserDismissalDisabled: Bool = false { | ||
| didSet { | ||
| guard isUserDismissalDisabled != oldValue, let sheetController = sheetController else { return } | ||
| if isUserDismissalDisabled { | ||
| sheetController.setCanTouchDimmingBackgroundToDismiss(false) | ||
|
Comment on lines
+27
to
+36
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. issue (bug_risk): The lock currently also blocks programmatic dismissals, which contradicts the comment and may be too strict. The docstring says programmatic dismissal is unaffected, but def hideBottomSheet(_ completion: (() -> Void)? = nil) {
if isUserDismissalDisabled {
logger.debug("Ignoring hideBottomSheet: forced-conversion lock is active")
return
}
sheetController?.dismiss(completion)
}So all calls into |
||
| } else { | ||
| sheetController.setCanTouchDimmingBackgroundToDismiss(hubRequestedCanTouchToDismiss) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Tracks the most recent Hub-requested dismissibility state so that releasing the lock | ||
| // restores whatever the Hub last asked for instead of unconditionally re-enabling. | ||
| private var hubRequestedCanTouchToDismiss: Bool = true | ||
|
|
||
| override func viewWillAppear(_ animated: Bool) { | ||
| super.viewWillAppear(animated) | ||
| guard let controller = controller else { | ||
|
|
@@ -54,6 +74,9 @@ class BottomSheetViewController: UIViewController { | |
|
|
||
| sheetController = presentAsBottomSheet(controller, theme: theme, behavior: behavior) | ||
|
|
||
| if isUserDismissalDisabled { | ||
| sheetController?.setCanTouchDimmingBackgroundToDismiss(false) | ||
| } | ||
| } | ||
|
|
||
| override func viewDidLoad() { | ||
|
|
@@ -69,6 +92,8 @@ class BottomSheetViewController: UIViewController { | |
| override func viewDidDisappear(_ animated: Bool) { | ||
| super.viewDidDisappear(animated) | ||
| self.controller = nil | ||
| self.isUserDismissalDisabled = false | ||
| self.hubRequestedCanTouchToDismiss = true | ||
| } | ||
|
|
||
| func updateBottomSheetHeight(_ number: CGFloat) { | ||
|
|
@@ -77,6 +102,10 @@ class BottomSheetViewController: UIViewController { | |
| } | ||
|
|
||
| public func hideBottomSheet(_ completion: (() -> Void)? = nil) { | ||
| if isUserDismissalDisabled { | ||
| logger.debug("Ignoring hideBottomSheet: forced-conversion lock is active") | ||
| return | ||
| } | ||
| sheetController?.dismiss(completion) | ||
| } | ||
|
|
||
|
|
@@ -99,6 +128,10 @@ class BottomSheetViewController: UIViewController { | |
| } | ||
|
|
||
| func canTouchDimmingBackgroundToDismiss(_ enable: Bool) { | ||
| hubRequestedCanTouchToDismiss = enable | ||
| if isUserDismissalDisabled && enable { | ||
| return | ||
| } | ||
| if let sheetController = sheetController { | ||
| sheetController.setCanTouchDimmingBackgroundToDismiss(enable) | ||
| } | ||
|
|
||
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.
1. Auto-close can be skipped
🐞 Bug☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools