Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Move magic numbers into variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed May 6, 2021
1 parent 72fdcf7 commit ba1b006
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,17 @@ private class MenuHostingController<MenuContent: View>: UIHostingController<Menu
self.navigationController?.preferredContentSize = {
let controller = UIHostingController(rootView: self.rootView.content)
let size = controller.view.sizeThatFits(CGSize(width: 375, height: 0))
// Have to increase the content size by the hidden nav bar height so that the size
// doesn't change when the user navigates within the menu where the nav bar is visible
let navBarHeight = navigationController?.navigationBar.bounds.height ?? 0
return CGSize(width: 375, height: min(max(size.height + 16, 240), 580 + navBarHeight))
let preferredPopoverWidth: CGFloat = 375.0
let minimumPopoverHeight: CGFloat = 240.0
let maximumPopoverHeight: CGFloat = 580.0
return CGSize(
width: preferredPopoverWidth,
// Have to increase the content size by the hidden nav bar height so that the size
// doesn't change when the user navigates within the menu where the nav bar is
// visible.
height: min(max(size.height + 16, minimumPopoverHeight), maximumPopoverHeight + navBarHeight)
)
}()
view.backgroundColor = Theme.of(nil).colors.home
}
Expand Down

0 comments on commit ba1b006

Please sign in to comment.