Skip to content

Commit

Permalink
Fix PagingView layout constraints
Browse files Browse the repository at this point in the history
In #668, the logic for menuPosition was removed by accident. This
brings it back and fixes some auto layout warnings.
  • Loading branch information
rechsteiner committed Apr 6, 2023
1 parent f64b593 commit b9d13c1
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Parchment/Classes/PagingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,29 @@ open class PagingView: UIView {

let heightConstraint = collectionView.heightAnchor.constraint(equalToConstant: options.menuHeight)
heightConstraint.isActive = true
heightConstraint.priority = .defaultHigh
self.heightConstraint = heightConstraint

NSLayoutConstraint.activate([
collectionView.leadingAnchor.constraint(equalTo: leadingAnchor),
collectionView.trailingAnchor.constraint(equalTo: trailingAnchor),
collectionView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: pageView.topAnchor),
pageView.leadingAnchor.constraint(equalTo: leadingAnchor),
pageView.trailingAnchor.constraint(equalTo: trailingAnchor),
pageView.bottomAnchor.constraint(equalTo: bottomAnchor),
pageView.trailingAnchor.constraint(equalTo: trailingAnchor)
])

switch options.menuPosition {
case .top:
NSLayoutConstraint.activate([
collectionView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
pageView.topAnchor.constraint(equalTo: collectionView.bottomAnchor),
pageView.bottomAnchor.constraint(equalTo: bottomAnchor),
])
case .bottom:
NSLayoutConstraint.activate([
pageView.topAnchor.constraint(equalTo: safeAreaLayoutGuide.topAnchor),
pageView.bottomAnchor.constraint(equalTo: collectionView.topAnchor),
collectionView.bottomAnchor.constraint(equalTo: safeAreaLayoutGuide.bottomAnchor)
])
}
}
}

0 comments on commit b9d13c1

Please sign in to comment.