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

Commit

Permalink
Fix #7200: Tx Confirmation auto-dismisses after creating tx via asset…
Browse files Browse the repository at this point in the history
… details (#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 and iccub committed Apr 12, 2023
1 parent bf1a092 commit 5ee8eb3
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 5ee8eb3

Please sign in to comment.