[TF-1658] dismiss addingVC

This commit is contained in:
gmachnio 2024-10-30 20:25:05 +01:00
parent 99168aed38
commit ca86a21dbc

View File

@ -64,18 +64,6 @@ final class TokensPlainFlowController: FlowController, TokensNavigationFlowContr
private weak var mainSplitViewController: MainSplitViewController?
private var galleryViewController: UIViewController?
private var isMainSplitViewControllerReadyToPresentAlert: Bool {
guard let mainSplitViewController else { return false }
if let presentedViewController = mainSplitViewController.presentedViewController,
presentedViewController is AddingServiceViewController {
presentedViewController.dismiss(animated: false)
return false
}
return true
}
static func showAsTab(
viewController: TokensViewController,
in navigationController: UINavigationController
@ -109,6 +97,19 @@ final class TokensPlainFlowController: FlowController, TokensNavigationFlowContr
) {
navigationController.setRootViewController(viewController)
}
private func presentAlertOnMainSplitViewController(_ alert: UIAlertController) {
guard let mainSplitViewController else { return }
if let presentedViewController = mainSplitViewController.presentedViewController,
presentedViewController is AddingServiceViewController {
presentedViewController.dismiss(animated: false) {
mainSplitViewController.present(alert, animated: true)
}
} else {
mainSplitViewController.present(alert, animated: true)
}
}
}
extension TokensPlainFlowController: TokensPlainFlowControlling {
@ -239,7 +240,6 @@ extension TokensPlainFlowController: TokensPlainFlowControlling {
// MARK: - Link actions
func toDuplicatedCode(forceAdd: @escaping Callback, cancel: @escaping Callback) {
if isMainSplitViewControllerReadyToPresentAlert {
let alert = UIAlertController(
title: T.Commons.warning,
message: T.Tokens.serviceAlreadyExists,
@ -253,12 +253,10 @@ extension TokensPlainFlowController: TokensPlainFlowControlling {
cancel()
}))
mainSplitViewController!.present(alert, animated: true)
}
presentAlertOnMainSplitViewController(alert)
}
func toShowShouldAddCode(with descriptionText: String?) {
if isMainSplitViewControllerReadyToPresentAlert {
let msg = T.Notifications.addCodeQuestionTitle(descriptionText ?? T.Browser.unkownName)
let alert = UIAlertController(title: T.Notifications.addingCode, message: msg, preferredStyle: .alert)
@ -269,12 +267,10 @@ extension TokensPlainFlowController: TokensPlainFlowControlling {
self?.viewController.presenter.handleAddStoredCode()
})
mainSplitViewController!.present(alert, animated: true)
}
presentAlertOnMainSplitViewController(alert)
}
func toIncorrectCode() {
if isMainSplitViewControllerReadyToPresentAlert {
let alert = UIAlertController(
title: T.Commons.warning,
message: T.Tokens.thisQrCodeIsInavlid,
@ -282,8 +278,7 @@ extension TokensPlainFlowController: TokensPlainFlowControlling {
)
alert.addAction(UIAlertAction(title: T.Commons.cancel, style: .cancel, handler: { _ in }))
mainSplitViewController!.present(alert, animated: true)
}
presentAlertOnMainSplitViewController(alert)
}
func toSendLogs(auditID: UUID) {