Skip to content

Commit

Permalink
Update standard presenter to use window from vc instead of the shared…
Browse files Browse the repository at this point in the history
… application's keyWindow
  • Loading branch information
danielsaidi committed Aug 10, 2021
1 parent 780a3a0 commit 3031d42
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,18 @@ open class ActionSheetStandardPresenter: ActionSheetPresenterBase {

extension ActionSheetStandardPresenter {

func addActionSheetToKeyWindow(_ sheet: ActionSheet) {
let window = UIApplication.shared.keyWindow
sheet.view.frame = window?.bounds ?? .zero
window?.addSubview(sheet.view)
func addActionSheetToKeyWindow(
_ sheet: ActionSheet,
for viewController: UIViewController) {
guard let window = viewController.view.window else { return }
sheet.view.frame = window.bounds
window.addSubview(sheet.view)
}

func addActionSheet(_ sheet: ActionSheet, to vc: UIViewController) {
if presentationStyle == .keyWindow { return addActionSheetToKeyWindow(sheet) }
func addActionSheet(
_ sheet: ActionSheet,
to vc: UIViewController) {
if presentationStyle == .keyWindow { return addActionSheetToKeyWindow(sheet, for: vc) }
let view = vc.view
sheet.view.frame = view?.bounds ?? .zero
view?.addSubview(sheet.view)
Expand Down

0 comments on commit 3031d42

Please sign in to comment.