Skip to content

Commit

Permalink
Merge pull request #1699 from ToddLa/ios-13-tweak
Browse files Browse the repository at this point in the history
Ios 13 UX tweaks
  • Loading branch information
JoeMatt authored Jan 9, 2022
2 parents 4f0e3c0 + c331ebc commit a64e2e8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
18 changes: 17 additions & 1 deletion Provenance/Emulator/PVEmulatorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,14 @@ extension NSNumber {

extension GCController {
func setupPauseHandler(onPause: @escaping () -> Void) {
// Use buttonHome for iOS/tvOS14 and later
if let buttonHome = buttonHome {
buttonHome.pressedChangedHandler = { _, _, isPressed in
if isPressed {
onPause()
}
}
}
// Using buttonMenu is the recommended way for iOS/tvOS13 and later
if let buttonMenu = buttonMenu {
buttonMenu.pressedChangedHandler = { _, _, isPressed in
Expand All @@ -887,7 +895,8 @@ extension GCController {
}
} else {
// Fallback to the old method
controllerPausedHandler = { _ in onPause()
controllerPausedHandler = { _ in
onPause()
}
}
}
Expand All @@ -902,4 +911,11 @@ extension GCController {
}
return nil
}

private var buttonHome: GCControllerButtonInput? {
if #available(iOS 14.0, tvOS 14.0, *) {
return extendedGamepad?.buttonHome
}
return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,17 @@ open class QuickTableViewController: UIViewController, UITableViewDataSource, UI
open var clearsSelectionOnViewWillAppear = true

/// Returns the table view managed by the controller object.
open var tableView: UITableView = UITableView(frame: .zero, style: .grouped)
#if os(iOS) || os(macOS)
open var tableView: UITableView = {
if #available(iOS 13.0, *) {
return UITableView(frame: .zero, style: .insetGrouped)
} else {
return UITableView(frame: .zero, style: .grouped)
}
}()
#else
open var tableView: UITableView = UITableView(frame: .zero, style: .grouped)
#endif

/// The layout of sections and rows to display in the table view.
open var tableContents: [Section] = [] {
Expand Down
2 changes: 2 additions & 0 deletions Provenance/Provenance-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@
</array>
<key>UISupportsDocumentBrowser</key>
<true/>
<key>UIUserInterfaceStyle</key>
<string>Dark</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
Expand Down

0 comments on commit a64e2e8

Please sign in to comment.