     fatalError("init(coder:) has not been implemented")
   }
 
+  // MARK: - Lifecycle
+
   override func viewDidLoad() {
     super.viewDidLoad()
 
     navController.delegate = self
 
-    let svController = UISplitViewController()
+    // Set `viewControllers` first to avoid warnings.
+    svController.viewControllers = [navController, detailNavController]
     svController.presentsWithGesture = false
-    svController.viewControllers = [navController, detailNavController]
+    // When set to `automatic`, iPad uses `primaryOverlay` in portrait orientations, which
+    // can result in `viewDidAppear` not being called on detail view controllers.
+    svController.preferredDisplayMode = .allVisible
     svController.delegate = self
-    self.svController = svController
+
+    let longestDimension = max(UIScreen.main.bounds.height, UIScreen.main.bounds.width)
+    svController.minimumPrimaryColumnWidth =
+      floor(longestDimension * Metrics.preferredPrimaryColumnWidthFraction)
+    svController.maximumPrimaryColumnWidth = longestDimension
 
     let buttonBarViewController =
       ActionAreaButtonBarViewController(contentViewController: svController)

  private let detailNavController: UINavigationController = {
    let nc = UINavigationController()
    nc.isNavigationBarHidden = true
    return nc
  }()

  // TODO: Make these non-optional
  private var buttonBarViewController: ActionAreaButtonBarViewController?
  private var svController: UISplitViewController?

  private var viewControllerBarItems: [UIViewController: BarItemMode] = [:]

  private var state: State = .normal {
    willSet {


}

extension ActionAreaController: UISplitViewControllerDelegate {

  func primaryViewController(
    forCollapsing splitViewController: UISplitViewController
  ) -> UIViewController? {
    return nil // nil for default behavior
  }

  func splitViewController(_ splitViewController: UISplitViewController,
                           collapseSecondary secondaryViewController: UIViewController,
                           onto primaryViewController: UIViewController) -> Bool {
    if presentedDetailViewController != nil {
      // Return `false` to delegate to the primary navigation controller, which will push the
      // `navDetailController` onto its navigation stack.
      return false
    } else {
      // Otherwise the empty state of the detail view would cover the primary content, so return
      // `true` to do nothing.
      return true
    }
    // false for default behavior
  }

  func primaryViewController(
    forExpanding splitViewController: UISplitViewController
  ) -> UIViewController? {
    return nil // nil for default behavior
  }

  func splitViewController(_ splitViewController: UISplitViewController,
                           separateSecondaryFrom primaryViewController: UIViewController
  ) -> UIViewController? {
    if presentedDetailViewController != nil {
      // Return `nil` to delegate to the primary navigation controller, which will pop the
      // `navDetailController` and return it to be installed as the secondary view controller.
      return nil
    } else {
      // Otherwise return the `detailNavController` directly.
      return detailNavController
    }
    // nil for default behavior
  }

  func splitViewController(_ splitViewController: UISplitViewController,
                           show vc: UIViewController, sender: Any?) -> Bool {
    return false // false for default behavior
  }

  func splitViewController(_ splitViewController: UISplitViewController,
                           showDetail vc: UIViewController, sender: Any?) -> Bool {
    presentedDetailViewController = vc
    if splitViewController.isCollapsed {
      navController.pushViewController(vc, animated: true)
    } else {
      detailNavController.pushViewController(vc, animated: true)
    }
    return true // false for default behavior
  }

}

extension ActionAreaController: UINavigationControllerDelegate {
