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

Fix #7200: Tx Confirmation auto-dismisses after creating tx via asset details #7203

Merged
merged 2 commits into from
Apr 5, 2023
Merged
Changes from all commits
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
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