Skip to content

Commit

Permalink
Fixed containerAlreadyPresenting error handing (#121)
Browse files Browse the repository at this point in the history
* Fixed containerAlreadyPresenting error handing

* Try to fix
  • Loading branch information
almazrafi authored May 29, 2024
1 parent b2392c4 commit 6c32215
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions Sources/Screen/Actions/Modal/ScreenPresentAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,25 @@ public struct ScreenPresentAction<
) {
navigator.logInfo("Presenting \(screen) on \(type(of: container))")

let canPresent = container.presented.map { presented in
presented.isBeingDismissed || presented.modalPresentationStyle == .overCurrentContext
} ?? true
let presented = screen.build(navigator: navigator)
var completed = false

guard canPresent else {
return completion(.containerAlreadyPresenting(container, for: self))
}
let completion = { result in
guard !completed else {
return
}

let presented = screen.build(navigator: navigator)
completed = true
completion(result)
}

container.present(presented, animated: animated) {
completion(.success(presented))
}

if container.presented !== presented {
completion(.containerAlreadyPresenting(container, for: self))
}
}
}

Expand Down

0 comments on commit 6c32215

Please sign in to comment.