Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix entire Wallet dismissing on lock / auto-lock on iOS 16.4 and later
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenHeaps committed Oct 10, 2023
1 parent 9bcd406 commit 4409307
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
5 changes: 1 addition & 4 deletions Sources/BraveWallet/Crypto/MainMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,7 @@ struct MainMenuView: View {
LazyVStack(spacing: 0) {
Button(action: {
presentationMode.dismiss()
// wait for view to dismiss so entire Wallet does not dismiss
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
keyringStore.lock()
}
keyringStore.lock()
}) {
MenuRowView(
iconBraveSystemName: "leo.lock",
Expand Down
11 changes: 7 additions & 4 deletions Sources/BraveWallet/WalletHostingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,17 @@ public class WalletHostingViewController: UIHostingController<CryptoView> {
if !isLocked {
onUnlock?()
}
// SwiftUI has a bug where nested sheets do not dismiss correctly if the root View holding onto
// the sheet is removed from the view hierarchy. The root's sheet stays visible even though the
// root doesn't exist anymore.
// Prior to iOS 16.4, SwiftUI has a bug where nested sheets do not dismiss correctly if the
// root View holding onto the sheet is removed from the view hierarchy. The root's sheet
// stays visible even though the root doesn't exist anymore.
//
// As a workaround to this issue, we can just watch keyring's `isLocked` value from here
// and dismiss the first sheet ourselves to ensure we dont get stuck with a child view visible
// while the wallet is locked.
if let self = self, isLocked, self.presentedViewController != nil {
if #unavailable(iOS 16.4),
let self = self,
isLocked,
self.presentedViewController != nil {
self.dismiss(animated: true)
}
}
Expand Down

0 comments on commit 4409307

Please sign in to comment.