|
@@ -79,13 +79,6 @@ class ActionSheet: UIViewController {
|
|
return headerView
|
|
return headerView
|
|
}()
|
|
}()
|
|
|
|
|
|
- lazy var bottomBackgroundView: UIView = {
|
|
|
|
- let bottomBackgroundView = UIView()
|
|
|
|
- bottomBackgroundView.backgroundColor = PresentationTheme.current.colors.background
|
|
|
|
- bottomBackgroundView.translatesAutoresizingMaskIntoConstraints = false
|
|
|
|
- return bottomBackgroundView
|
|
|
|
- }()
|
|
|
|
-
|
|
|
|
lazy var mainStackView: UIStackView = {
|
|
lazy var mainStackView: UIStackView = {
|
|
let mainStackView = UIStackView()
|
|
let mainStackView = UIStackView()
|
|
mainStackView.spacing = 0
|
|
mainStackView.spacing = 0
|
|
@@ -112,27 +105,17 @@ class ActionSheet: UIViewController {
|
|
return collectionViewHeightConstraint
|
|
return collectionViewHeightConstraint
|
|
}()
|
|
}()
|
|
|
|
|
|
- fileprivate lazy var bottomBackgroundViewHeightConstraint: NSLayoutConstraint = {
|
|
|
|
- let bottomBackgroundViewHeightConstraint = bottomBackgroundView.heightAnchor.constraint(equalToConstant: 0)
|
|
|
|
- return bottomBackgroundViewHeightConstraint
|
|
|
|
- }()
|
|
|
|
-
|
|
|
|
override func updateViewConstraints() {
|
|
override func updateViewConstraints() {
|
|
super.updateViewConstraints()
|
|
super.updateViewConstraints()
|
|
|
|
|
|
if let presentingViewController = presentingViewController, let dataSource = dataSource {
|
|
if let presentingViewController = presentingViewController, let dataSource = dataSource {
|
|
- collectionViewHeightConstraint.constant = CGFloat(dataSource.numberOfRows()) * cellHeight
|
|
|
|
|
|
+ collectionViewHeightConstraint.constant = CGFloat(dataSource.numberOfRows()) * cellHeight + cellHeight / 2
|
|
maxCollectionViewHeightConstraint.constant = presentingViewController.view.frame.size.height / 2
|
|
maxCollectionViewHeightConstraint.constant = presentingViewController.view.frame.size.height / 2
|
|
collectionView.setNeedsLayout()
|
|
collectionView.setNeedsLayout()
|
|
collectionView.layoutIfNeeded()
|
|
collectionView.layoutIfNeeded()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- @available(iOS 11.0, *)
|
|
|
|
- override func viewSafeAreaInsetsDidChange() {
|
|
|
|
- bottomBackgroundViewHeightConstraint.constant = view.safeAreaInsets.bottom
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// MARK: UIViewController
|
|
// MARK: UIViewController
|
|
|
|
|
|
override func viewDidLoad() {
|
|
override func viewDidLoad() {
|
|
@@ -146,14 +129,12 @@ class ActionSheet: UIViewController {
|
|
|
|
|
|
mainStackView.addArrangedSubview(headerView)
|
|
mainStackView.addArrangedSubview(headerView)
|
|
mainStackView.addArrangedSubview(collectionView)
|
|
mainStackView.addArrangedSubview(collectionView)
|
|
- mainStackView.addArrangedSubview(bottomBackgroundView)
|
|
|
|
|
|
|
|
backgroundView.frame = UIScreen.main.bounds
|
|
backgroundView.frame = UIScreen.main.bounds
|
|
|
|
|
|
setupMainStackViewConstraints()
|
|
setupMainStackViewConstraints()
|
|
setupCollectionViewConstraints()
|
|
setupCollectionViewConstraints()
|
|
setuplHeaderViewConstraints()
|
|
setuplHeaderViewConstraints()
|
|
- setupBottomBackgroundView()
|
|
|
|
}
|
|
}
|
|
|
|
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
override func viewWillAppear(_ animated: Bool) {
|
|
@@ -206,7 +187,6 @@ class ActionSheet: UIViewController {
|
|
collectionView.backgroundColor = PresentationTheme.current.colors.background
|
|
collectionView.backgroundColor = PresentationTheme.current.colors.background
|
|
headerView.backgroundColor = PresentationTheme.current.colors.background
|
|
headerView.backgroundColor = PresentationTheme.current.colors.background
|
|
headerView.title.textColor = PresentationTheme.current.colors.cellTextColor
|
|
headerView.title.textColor = PresentationTheme.current.colors.cellTextColor
|
|
- bottomBackgroundView.backgroundColor = PresentationTheme.current.colors.background
|
|
|
|
for cell in collectionView.visibleCells {
|
|
for cell in collectionView.visibleCells {
|
|
if let cell = cell as? ActionSheetCell {
|
|
if let cell = cell as? ActionSheetCell {
|
|
cell.backgroundColor = PresentationTheme.current.colors.background
|
|
cell.backgroundColor = PresentationTheme.current.colors.background
|
|
@@ -235,13 +215,6 @@ private extension ActionSheet {
|
|
])
|
|
])
|
|
}
|
|
}
|
|
|
|
|
|
- private func setupBottomBackgroundView() {
|
|
|
|
- NSLayoutConstraint.activate([
|
|
|
|
- bottomBackgroundViewHeightConstraint,
|
|
|
|
- bottomBackgroundView.widthAnchor.constraint(equalTo: view.widthAnchor)
|
|
|
|
- ])
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private func setupMainStackViewConstraints() {
|
|
private func setupMainStackViewConstraints() {
|
|
NSLayoutConstraint.activate([
|
|
NSLayoutConstraint.activate([
|
|
// Extra padding for spring animation
|
|
// Extra padding for spring animation
|