Message details shows entire message

When viewing a longer message, to avoid the risk of the user not being
aware they can scroll down, we scroll to the last couple lines of the
message, ensuring they can see the meta-data.

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent 0a19e0715a
commit 9ae4a26eb1

@ -25,6 +25,7 @@ class MessageMetadataViewController: OWSViewController {
let databaseConnection: YapDatabaseConnection
let bubbleFactory = OWSMessagesBubbleImageFactory()
var bubbleView: UIView?
var message: TSMessage
@ -69,6 +70,15 @@ class MessageMetadataViewController: OWSViewController {
createViews()
self.view.layoutIfNeeded()
if let bubbleView = self.bubbleView {
let showAtLeast: CGFloat = 50
let middleCenter = CGPoint(x: bubbleView.frame.origin.x + bubbleView.frame.width / 2,
y: bubbleView.frame.origin.y + bubbleView.frame.height - showAtLeast)
let offset = bubbleView.superview!.convert(middleCenter, to: scrollView)
self.scrollView!.setContentOffset(offset, animated: false)
}
NotificationCenter.default.addObserver(self,
selector:#selector(yapDatabaseModified),
name:NSNotification.Name.YapDatabaseModified,
@ -283,8 +293,7 @@ class MessageMetadataViewController: OWSViewController {
bodyLabel.textColor = isIncoming ? UIColor.black : UIColor.white
bodyLabel.font = UIFont.ows_regularFont(withSize:16)
bodyLabel.text = messageBody
// Only show the first N lines.
bodyLabel.numberOfLines = 10
bodyLabel.numberOfLines = 0
bodyLabel.lineBreakMode = .byWordWrapping
let bubbleImageData = isIncoming ? bubbleFactory.incoming : bubbleFactory.outgoing
@ -293,6 +302,7 @@ class MessageMetadataViewController: OWSViewController {
let trailingMargin: CGFloat = isIncoming ? 10 : 15
let bubbleView = UIImageView(image: bubbleImageData.messageBubbleImage)
self.bubbleView = bubbleView
bubbleView.layer.cornerRadius = 10
bubbleView.addSubview(bodyLabel)

Loading…
Cancel
Save