Skip to content

Commit

Permalink
Fix brave/brave-ios#7200: Tx Confirmation auto-dismisses after creati…
Browse files Browse the repository at this point in the history
…ng tx via asset details (brave/brave-ios#7203)

* Fix `WalletPromptView` dismissing views unintentionally. This was causing Transaction Confirmation to dismiss automatically after creating a Send/Swap transaction via Asset Details.

* Remove `buySendSwapDestination` check from `WalletPromptView` now that we only dismiss the presented view controller if we know we presented it.
  • Loading branch information
StephenHeaps authored Apr 5, 2023
1 parent 94df40b commit ad87a90
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Sources/BraveWallet/WalletPromptView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import SwiftUI
import BraveUI
import DesignSystem
import Shared

struct WalletPromptContentView<Content, Footer>: View where Content: View, Footer: View {
let content: () -> Content
Expand Down Expand Up @@ -56,8 +57,6 @@ struct WalletPromptView<Content, Footer>: UIViewControllerRepresentable where Co
var action: (Bool, UINavigationController?) -> Bool
var content: () -> Content
var footer: () -> Footer
@Environment(\.buySendSwapDestination)
private var buySendSwapDestination: Binding<BuySendSwapDestination?>

func makeUIViewController(context: Context) -> UIViewController {
.init()
Expand All @@ -82,13 +81,23 @@ struct WalletPromptView<Content, Footer>: UIViewControllerRepresentable where Co
footer: footer
)
)
context.coordinator.presentedViewController = .init(controller)
uiViewController.present(controller, animated: true)
} else {
if buySendSwapDestination.wrappedValue == nil {
if let presentedViewController = context.coordinator.presentedViewController?.value,
presentedViewController == uiViewController.presentedViewController {
uiViewController.presentedViewController?.dismiss(animated: true)
}
}
}

class Coordinator {
var presentedViewController: WeakRef<UIViewController>?
}

func makeCoordinator() -> Coordinator {
Coordinator()
}
}

extension WalletPromptView where Content: View, Footer == EmptyView {
Expand Down

0 comments on commit ad87a90

Please sign in to comment.