Skip to content

Commit

Permalink
Fix brave#1414: Full screen modal presentation style for iOS 13.
Browse files Browse the repository at this point in the history
  • Loading branch information
iccub committed Aug 21, 2019
1 parent 27e1f81 commit d3842a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
13 changes: 12 additions & 1 deletion Client/Frontend/AuthenticationManager/AppAuthenticator.swift
Expand Up @@ -174,7 +174,18 @@ extension AppAuthenticator {
passcodeVC.isCancellable = isCancellable
passcodeVC.delegate = delegate
let navController = UINavigationController(rootViewController: passcodeVC)
navController.modalPresentationStyle = .formSheet

if UIDevice.current.userInterfaceIdiom == .phone {
navController.modalPresentationStyle = .fullScreen
} else {
navController.modalPresentationStyle = .formSheet
}

if #available(iOS 13.0, *) {
// Prevent dismissing the modal by swipe
navController.isModalInPresentation = true
}

controller.present(navController, animated: true, completion: nil)
}
}
Expand Down
Expand Up @@ -180,9 +180,18 @@ class MenuViewController: UITableViewController {
private enum DoneButtonPosition { case left, right }
private typealias DoneButton = (style: UIBarButtonItem.SystemItem, position: DoneButtonPosition)

private func open(_ viewController: UIViewController, doneButton: DoneButton) {
private func open(_ viewController: UIViewController, doneButton: DoneButton,
allowSwipeToDismiss: Bool = true) {
let nav = SettingsNavigationController(rootViewController: viewController)
nav.modalPresentationStyle = .formSheet
if UIDevice.current.userInterfaceIdiom == .phone {
nav.modalPresentationStyle = .fullScreen
} else {
nav.modalPresentationStyle = .formSheet
}

if #available(iOS 13.0, *) {
nav.isModalInPresentation = !allowSwipeToDismiss
}

let button = UIBarButtonItem(barButtonSystemItem: doneButton.style, target: nav, action: #selector(nav.done))

Expand Down Expand Up @@ -225,7 +234,8 @@ class MenuViewController: UITableViewController {
private func openSettings() {
let vc = SettingsViewController(profile: bvc.profile, tabManager: bvc.tabManager)
vc.settingsDelegate = bvc
open(vc, doneButton: DoneButton(style: .done, position: .right))
open(vc, doneButton: DoneButton(style: .done, position: .right),
allowSwipeToDismiss: false)
}

private func openShareSheet() {
Expand Down

0 comments on commit d3842a1

Please sign in to comment.