[ios] Fixed rich pp layout.

This commit is contained in:
VladiMihaylenko 2017-03-06 14:42:44 +03:00 committed by Sergey Yershov
parent 4daf2393f0
commit 84ae8fb084

View file

@ -8,19 +8,29 @@ final class PPHotelDescriptionCell: MWMTableViewCell
@IBOutlet private weak var buttonZeroHeight: NSLayoutConstraint!
@IBOutlet private weak var button: UIButton!
private weak var updateDelegate: MWMPlacePageCellUpdateProtocol?
private var isNeedToForceLayout: Bool = false
func config(with description: String, delegate: MWMPlacePageCellUpdateProtocol) {
descriptionText.text = description;
descriptionText.sizeToFit()
updateDelegate = delegate
let isCompact = descriptionText.height > kMaximumDescriptionHeight;
if (isCompact) {
compactModeConstraints.forEach { $0.priority = UILayoutPriorityDefaultHigh }
}
hideButton(!isCompact)
setNeedsLayout()
isNeedToForceLayout = true
layoutIfNeeded()
}
override func layoutSubviews() {
super.layoutSubviews()
if isNeedToForceLayout {
isNeedToForceLayout = false
let isCompact = descriptionText.height > kMaximumDescriptionHeight;
if (isCompact) {
compactModeConstraints.forEach { $0.priority = UILayoutPriorityDefaultHigh }
}
hideButton(!isCompact)
}
}
private func hideButton(_ isHidden:Bool = true) {