minor tweak on the width of fake chat bubble

pull/699/head
ryanzhao 2 years ago
parent bd1e1b266b
commit cc3591a207

@ -22,7 +22,7 @@ final class FakeChatView : UIView {
return result
}()
private static let bubbleWidth = CGFloat(224)
private static let bubbleWidth = UIDevice.current.isIPad ? CGFloat(468) : CGFloat(224)
private static let bubbleCornerRadius = CGFloat(10)
private static let startDelay: TimeInterval = 1
private static let animationDuration: TimeInterval = 0.4
@ -61,7 +61,7 @@ final class FakeChatView : UIView {
private func getChatBubble(withText text: String, wasSentByCurrentUser: Bool) -> UIView {
let result = UIView()
let bubbleView = UIView()
bubbleView.set(.width, to: FakeChatView.bubbleWidth)
bubbleView.set(.width, lessThanOrEqualTo: FakeChatView.bubbleWidth)
bubbleView.layer.cornerRadius = FakeChatView.bubbleCornerRadius
bubbleView.layer.shadowColor = UIColor.black.cgColor
bubbleView.layer.shadowRadius = isLightMode ? 4 : 8

@ -127,4 +127,17 @@ public extension UIView {
constraint.isActive = true
return constraint
}
@discardableResult
func set(_ dimension: Dimension, lessThanOrEqualTo size: CGFloat) -> NSLayoutConstraint {
translatesAutoresizingMaskIntoConstraints = false
let constraint: NSLayoutConstraint = {
switch dimension {
case .width: return widthAnchor.constraint(lessThanOrEqualToConstant: size)
case .height: return heightAnchor.constraint(lessThanOrEqualToConstant: size)
}
}()
constraint.isActive = true
return constraint
}
}

Loading…
Cancel
Save