attempt 1: QMV doesn't have intrinsic content size, and requires a fixed

width to compute it's size, which we don't currently have.

// FREEBIE
pull/1/head
Michael Kirk 7 years ago
parent a6afa2cc06
commit 5807ba69ca

@ -29,6 +29,7 @@
#import "OWSMessageCell.h" #import "OWSMessageCell.h"
#import "OWSNavigationController.h" #import "OWSNavigationController.h"
#import "OWSProgressView.h" #import "OWSProgressView.h"
#import "OWSQuotedMessageView.h"
#import "OWSWebRTCDataProtos.pb.h" #import "OWSWebRTCDataProtos.pb.h"
#import "PinEntryView.h" #import "PinEntryView.h"
#import "PrivacySettingsTableViewController.h" #import "PrivacySettingsTableViewController.h"

@ -20,6 +20,8 @@ class QuotedReplyPreview: UIView {
init(quotedReply: OWSQuotedReplyModel) { init(quotedReply: OWSQuotedReplyModel) {
super.init(frame: .zero) super.init(frame: .zero)
let quotedMessageView = OWSQuotedMessageView(forPreview: quotedReply)
let isQuotingSelf = quotedReply.authorId == TSAccountManager.localNumber() let isQuotingSelf = quotedReply.authorId == TSAccountManager.localNumber()
// used for stripe and author // used for stripe and author
@ -29,40 +31,40 @@ class QuotedReplyPreview: UIView {
// used for text and cancel // used for text and cancel
let foregroundColor: UIColor = .darkGray let foregroundColor: UIColor = .darkGray
let authorLabel: UILabel = UILabel() // let authorLabel: UILabel = UILabel()
authorLabel.textColor = authorColor // authorLabel.textColor = authorColor
if isQuotingSelf { // if isQuotingSelf {
authorLabel.text = NSLocalizedString("MEDIA_GALLERY_SENDER_NAME_YOU", comment: "") // authorLabel.text = NSLocalizedString("MEDIA_GALLERY_SENDER_NAME_YOU", comment: "")
} else { // } else {
authorLabel.text = Environment.current().contactsManager.displayName(forPhoneIdentifier: quotedReply.authorId) // authorLabel.text = Environment.current().contactsManager.displayName(forPhoneIdentifier: quotedReply.authorId)
} // }
authorLabel.font = .ows_dynamicTypeHeadline // authorLabel.font = .ows_dynamicTypeHeadline
//
let bodyLabel: UILabel = UILabel() // let bodyLabel: UILabel = UILabel()
bodyLabel.textColor = foregroundColor // bodyLabel.textColor = foregroundColor
bodyLabel.font = .ows_dynamicTypeFootnote // bodyLabel.font = .ows_dynamicTypeFootnote
//
bodyLabel.text = { // bodyLabel.text = {
if let contentType = quotedReply.contentType { // if let contentType = quotedReply.contentType {
let emoji = TSAttachmentStream.emoji(forMimeType: contentType) // let emoji = TSAttachmentStream.emoji(forMimeType: contentType)
return "\(emoji) \(quotedReply.body ?? "")" // return "\(emoji) \(quotedReply.body ?? "")"
} else { // } else {
return quotedReply.body // return quotedReply.body
} // }
}() // }()
//
let thumbnailView: UIView? = { // let thumbnailView: UIView? = {
if let image = quotedReply.thumbnailImage { // if let image = quotedReply.thumbnailImage {
let imageView = UIImageView(image: image) // let imageView = UIImageView(image: image)
imageView.contentMode = .scaleAspectFill // imageView.contentMode = .scaleAspectFill
imageView.autoPinToSquareAspectRatio() // imageView.autoPinToSquareAspectRatio()
imageView.layer.cornerRadius = 3.0 // imageView.layer.cornerRadius = 3.0
imageView.clipsToBounds = true // imageView.clipsToBounds = true
//
return imageView // return imageView
} // }
return nil // return nil
}() // }()
let cancelButton: UIButton = UIButton(type: .custom) let cancelButton: UIButton = UIButton(type: .custom)
// FIXME proper image asset/size // FIXME proper image asset/size
@ -71,35 +73,37 @@ class QuotedReplyPreview: UIView {
cancelButton.imageView?.tintColor = foregroundColor cancelButton.imageView?.tintColor = foregroundColor
cancelButton.addTarget(self, action: #selector(didTapCancel), for: .touchUpInside) cancelButton.addTarget(self, action: #selector(didTapCancel), for: .touchUpInside)
let quoteStripe: UIView = UIView() // let quoteStripe: UIView = UIView()
quoteStripe.backgroundColor = authorColor // quoteStripe.backgroundColor = authorColor
//
let textColumn = UIView.container() // let textColumn = UIView.container()
textColumn.addSubview(authorLabel) // textColumn.addSubview(authorLabel)
textColumn.addSubview(bodyLabel) // textColumn.addSubview(bodyLabel)
//
authorLabel.autoPinEdges(toSuperviewMarginsExcludingEdge: .bottom) // authorLabel.autoPinEdges(toSuperviewMarginsExcludingEdge: .bottom)
authorLabel.autoPinEdge(.bottom, to: .top, of: bodyLabel) // authorLabel.autoPinEdge(.bottom, to: .top, of: bodyLabel)
bodyLabel.autoPinEdges(toSuperviewMarginsExcludingEdge: .top) // bodyLabel.autoPinEdges(toSuperviewMarginsExcludingEdge: .top)
//
// let contentViews: [UIView] = [textColumn, thumbnailView, cancelButton].flatMap { return $0 }
let contentViews: [UIView] = [textColumn, thumbnailView, cancelButton].flatMap { return $0 } let contentViews: [UIView] = [quotedMessageView, cancelButton]
let contentRow = UIStackView(arrangedSubviews: contentViews) let contentRow = UIStackView(arrangedSubviews: contentViews)
contentRow.axis = .horizontal contentRow.axis = .horizontal
self.addSubview(contentRow) self.addSubview(contentRow)
self.addSubview(quoteStripe) // self.addSubview(quoteStripe)
//
// Layout // // Layout
//
let kQuoteStripeWidth: CGFloat = 4 // let kQuoteStripeWidth: CGFloat = 4
self.layoutMargins = UIEdgeInsets(top: 6, // self.layoutMargins = UIEdgeInsets(top: 6,
left: kQuoteStripeWidth + 8, // left: kQuoteStripeWidth + 8,
bottom: 2, // bottom: 2,
right: 4) // right: 4)
//
quoteStripe.autoPinEdge(toSuperviewEdge: .leading) // quoteStripe.autoPinEdge(toSuperviewEdge: .leading)
quoteStripe.autoPinHeightToSuperview() // quoteStripe.autoPinHeightToSuperview()
quoteStripe.autoSetDimension(.width, toSize: kQuoteStripeWidth) // quoteStripe.autoSetDimension(.width, toSize: kQuoteStripeWidth)
//
contentRow.autoPinEdgesToSuperviewMargins() contentRow.autoPinEdgesToSuperviewMargins()
cancelButton.autoSetDimensions(to: CGSize(width: 40, height: 40)) cancelButton.autoSetDimensions(to: CGSize(width: 40, height: 40))

Loading…
Cancel
Save