diff --git a/Delta/Base.lproj/Settings.storyboard b/Delta/Base.lproj/Settings.storyboard index b68c00e..d35837e 100644 --- a/Delta/Base.lproj/Settings.storyboard +++ b/Delta/Base.lproj/Settings.storyboard @@ -1048,6 +1048,7 @@ + diff --git a/Delta/Settings/Controllers/ControllerInputsViewController.swift b/Delta/Settings/Controllers/ControllerInputsViewController.swift index 97e8be3..2051891 100644 --- a/Delta/Settings/Controllers/ControllerInputsViewController.swift +++ b/Delta/Settings/Controllers/ControllerInputsViewController.swift @@ -40,6 +40,8 @@ class ControllerInputsViewController: UIViewController private var activeCalloutView: InputCalloutView? + private var _didLayoutSubviews = false + @IBOutlet private var actionsMenuViewControllerHeightConstraint: NSLayoutConstraint! @IBOutlet private var cancelTapGestureRecognizer: UITapGestureRecognizer! @@ -65,7 +67,15 @@ class ControllerInputsViewController: UIViewController self.gameViewController.controllerView.addReceiver(self) - self.navigationController?.navigationBar.barStyle = .black + if let navigationController = self.navigationController, #available(iOS 13, *) + { + navigationController.overrideUserInterfaceStyle = .dark + navigationController.navigationBar.scrollEdgeAppearance = navigationController.navigationBar.standardAppearance // Fixes invisible navigation bar on iPad. + } + else + { + self.navigationController?.navigationBar.barStyle = .black + } NSLayoutConstraint.activate([self.gameViewController.gameView.centerYAnchor.constraint(equalTo: self.actionsMenuViewController.view.centerYAnchor)]) @@ -81,6 +91,23 @@ class ControllerInputsViewController: UIViewController { self.actionsMenuViewControllerHeightConstraint.constant = self.actionsMenuViewController.preferredContentSize.height } + + if let window = self.view.window, !_didLayoutSubviews + { + var traits = DeltaCore.ControllerSkin.Traits.defaults(for: window) + traits.orientation = .portrait + + if traits.device == .ipad + { + // Use standard iPhone skins instead of iPad skins. + traits.device = .iphone + traits.displayType = .standard + } + + self.gameViewController.controllerView.overrideControllerSkinTraits = traits + + _didLayoutSubviews = true + } } override func viewDidAppear(_ animated: Bool) @@ -403,6 +430,7 @@ private extension ControllerInputsViewController } let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) + alertController.popoverPresentationController?.barButtonItem = sender alertController.addAction(.cancel) alertController.addAction(UIAlertAction(title: NSLocalizedString("Reset Controls to Defaults", comment: ""), style: .destructive, handler: { (action) in reset() @@ -562,3 +590,15 @@ extension ControllerInputsViewController: SMCalloutViewDelegate self.toggle(calloutView) } } + +extension ControllerInputsViewController: UIAdaptivePresentationControllerDelegate +{ + func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle + { + switch (traitCollection.horizontalSizeClass, traitCollection.verticalSizeClass) + { + case (.regular, .regular): return .formSheet // Regular width and height, so display as form sheet + default: return .fullScreen // Compact width and/or height, so display full screen + } + } +} diff --git a/Delta/Settings/Controllers/ControllersSettingsViewController.swift b/Delta/Settings/Controllers/ControllersSettingsViewController.swift index 97771d4..8ea38f5 100644 --- a/Delta/Settings/Controllers/ControllersSettingsViewController.swift +++ b/Delta/Settings/Controllers/ControllersSettingsViewController.swift @@ -108,9 +108,18 @@ extension ControllersSettingsViewController switch identifier { case "controllerInputsSegue": - let controllerInputsViewController = (segue.destination as! UINavigationController).topViewController as! ControllerInputsViewController + let navigationController = segue.destination as! UINavigationController + + let controllerInputsViewController = navigationController.topViewController as! ControllerInputsViewController controllerInputsViewController.gameController = self.gameController + if self.view.traitCollection.userInterfaceIdiom == .pad + { + // For now, only iPads can display ControllerInputsViewController as a form sheet. + navigationController.modalPresentationStyle = .formSheet + navigationController.presentationController?.delegate = controllerInputsViewController + } + default: break }