|
|
|
@ -4,6 +4,9 @@
|
|
|
|
|
@objc weak var delegate: FriendRequestViewDelegate?
|
|
|
|
|
|
|
|
|
|
// MARK: Components
|
|
|
|
|
private lazy var buttonFont = UIFont.ows_dynamicTypeBodyClamped.ows_mediumWeight()
|
|
|
|
|
private lazy var buttonHeight = buttonFont.pointSize * 48 / 17
|
|
|
|
|
|
|
|
|
|
private lazy var label: UILabel = {
|
|
|
|
|
let result = UILabel()
|
|
|
|
|
result.textColor = Theme.secondaryColor
|
|
|
|
@ -34,8 +37,6 @@
|
|
|
|
|
buttonStackView.axis = .horizontal
|
|
|
|
|
buttonStackView.distribution = .fillEqually
|
|
|
|
|
mainStackView.addArrangedSubview(buttonStackView)
|
|
|
|
|
let buttonFont = UIFont.ows_dynamicTypeBodyClamped.ows_mediumWeight()
|
|
|
|
|
let buttonHeight = buttonFont.pointSize * 48 / 17
|
|
|
|
|
let acceptButton = OWSFlatButton.button(title: NSLocalizedString("Accept", comment: ""), font: buttonFont, titleColor: .ows_materialBlue, backgroundColor: .white, target: self, selector: #selector(accept))
|
|
|
|
|
acceptButton.autoSetDimension(.height, toSize: buttonHeight)
|
|
|
|
|
buttonStackView.addArrangedSubview(acceptButton)
|
|
|
|
@ -60,4 +61,16 @@
|
|
|
|
|
@objc private func decline() {
|
|
|
|
|
delegate?.declineFriendRequest(message)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MARK: Measuring
|
|
|
|
|
@objc static func calculateHeight(message: TSIncomingMessage, conversationStyle: ConversationStyle) -> CGFloat {
|
|
|
|
|
let width = conversationStyle.contentWidth
|
|
|
|
|
let topSpacing: CGFloat = 12
|
|
|
|
|
let dummyFriendRequestView = FriendRequestView()
|
|
|
|
|
dummyFriendRequestView.message = message
|
|
|
|
|
let messageHeight = dummyFriendRequestView.label.sizeThatFits(CGSize(width: width, height: CGFloat.greatestFiniteMagnitude)).height
|
|
|
|
|
let buttonHeight = dummyFriendRequestView.buttonHeight
|
|
|
|
|
let totalHeight = topSpacing + messageHeight + buttonHeight
|
|
|
|
|
return totalHeight.rounded(.up)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|