Use contact cells in message metadata view.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 0b60b521c6
commit a231834a73

@ -4,6 +4,7 @@
#import "AppSettingsViewController.h" #import "AppSettingsViewController.h"
#import "AttachmentSharing.h" #import "AttachmentSharing.h"
#import "ContactTableViewCell.h"
#import "DateUtil.h" #import "DateUtil.h"
#import "DebugUIPage.h" #import "DebugUIPage.h"
#import "Environment.h" #import "Environment.h"

@ -11,6 +11,8 @@ class MessageMetadataViewController: OWSViewController {
// MARK: Properties // MARK: Properties
let contactsManager: OWSContactsManager
let databaseConnection: YapDatabaseConnection let databaseConnection: YapDatabaseConnection
var message: TSMessage var message: TSMessage
@ -28,6 +30,7 @@ class MessageMetadataViewController: OWSViewController {
@available(*, unavailable, message:"use message: constructor instead.") @available(*, unavailable, message:"use message: constructor instead.")
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
self.contactsManager = Environment.getCurrent().contactsManager
self.message = TSMessage() self.message = TSMessage()
self.databaseConnection = TSStorageManager.shared().newDatabaseConnection()! self.databaseConnection = TSStorageManager.shared().newDatabaseConnection()!
super.init(coder: aDecoder) super.init(coder: aDecoder)
@ -35,6 +38,7 @@ class MessageMetadataViewController: OWSViewController {
} }
required init(message: TSMessage) { required init(message: TSMessage) {
self.contactsManager = Environment.getCurrent().contactsManager
self.message = message self.message = message
self.databaseConnection = TSStorageManager.shared().newDatabaseConnection()! self.databaseConnection = TSStorageManager.shared().newDatabaseConnection()!
super.init(nibName: nil, bundle: nil) super.init(nibName: nil, bundle: nil)
@ -92,6 +96,7 @@ class MessageMetadataViewController: OWSViewController {
contentView.autoPinTrailingToSuperView() contentView.autoPinTrailingToSuperView()
contentView.autoPinEdge(toSuperviewEdge:.top) contentView.autoPinEdge(toSuperviewEdge:.top)
contentView.autoPinEdge(toSuperviewEdge:.bottom) contentView.autoPinEdge(toSuperviewEdge:.bottom)
scrollView.layoutMargins = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
let hasAttachment = message.attachmentIds.count > 0 let hasAttachment = message.attachmentIds.count > 0
@ -127,21 +132,8 @@ class MessageMetadataViewController: OWSViewController {
} }
var rows = [UIView]() var rows = [UIView]()
let contactsManager = Environment.getCurrent().contactsManager! let contactsManager = Environment.getCurrent().contactsManager!
// Group?
let thread = message.thread let thread = message.thread
if let groupThread = thread as? TSGroupThread {
var groupName = groupThread.name()
if groupName.characters.count < 1 {
groupName = NSLocalizedString("NEW_GROUP_DEFAULT_TITLE", comment: "")
}
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_GROUP_NAME",
comment: "Label for the 'group name' field of the 'message metadata' view."),
value:groupName))
}
// Sender? // Sender?
if let incomingMessage = message as? TSIncomingMessage { if let incomingMessage = message as? TSIncomingMessage {
@ -154,14 +146,33 @@ class MessageMetadataViewController: OWSViewController {
// Recipient(s) // Recipient(s)
if let outgoingMessage = message as? TSOutgoingMessage { if let outgoingMessage = message as? TSOutgoingMessage {
// TODO: It'd be nice to inset these dividers from the edge of the screen.
let addDivider = {
let divider = UIView()
divider.backgroundColor = UIColor(white:0.9, alpha:1.0)
divider.autoSetDimension(.height, toSize:0.5)
rows.append(divider)
}
addDivider()
for recipientId in thread.recipientIdentifiers { for recipientId in thread.recipientIdentifiers {
let recipientName = contactsManager.contactOrProfileName(forPhoneIdentifier:recipientId)
let recipientStatus = self.recipientStatus(forOutgoingMessage: outgoingMessage, recipientId: recipientId) let recipientStatus = self.recipientStatus(forOutgoingMessage: outgoingMessage, recipientId: recipientId)
rows.append(valueRow(name: NSLocalizedString("MESSAGE_METADATA_VIEW_RECIPIENT", let cell = ContactTableViewCell()
comment: "Label for the 'recipient' field of the 'message metadata' view."), cell.configure(withRecipientId: recipientId, contactsManager: self.contactsManager)
value:recipientName, let statusLabel = UILabel()
subtitle:recipientStatus)) statusLabel.text = recipientStatus
statusLabel.textColor = UIColor.ows_darkGray()
statusLabel.font = UIFont.ows_footnote()
statusLabel.sizeToFit()
cell.accessoryView = statusLabel
cell.autoSetDimension(.height, toSize:ContactTableViewCell.rowHeight())
cell.setContentHuggingLow()
rows.append(cell)
addDivider()
} }
} }
@ -365,8 +376,8 @@ class MessageMetadataViewController: OWSViewController {
let valueLabel = self.valueLabel(text:value) let valueLabel = self.valueLabel(text:value)
row.addSubview(nameLabel) row.addSubview(nameLabel)
row.addSubview(valueLabel) row.addSubview(valueLabel)
nameLabel.autoPinLeadingToSuperView() nameLabel.autoPinLeadingToSuperView(withMargin:20)
valueLabel.autoPinTrailingToSuperView() valueLabel.autoPinTrailingToSuperView(withMargin:20)
valueLabel.autoPinLeading(toTrailingOf:nameLabel, margin: 10) valueLabel.autoPinLeading(toTrailingOf:nameLabel, margin: 10)
nameLabel.autoPinEdge(toSuperviewEdge:.top) nameLabel.autoPinEdge(toSuperviewEdge:.top)
valueLabel.autoPinEdge(toSuperviewEdge:.top) valueLabel.autoPinEdge(toSuperviewEdge:.top)

@ -52,6 +52,11 @@ const NSUInteger kContactTableViewCellAvatarSize = 40;
return NSStringFromClass(self.class); return NSStringFromClass(self.class);
} }
- (CGSize)intrinsicContentSize
{
return CGSizeMake(self.width, ContactTableViewCell.rowHeight);
}
+ (CGFloat)rowHeight + (CGFloat)rowHeight
{ {
return 59.f; return 59.f;

Loading…
Cancel
Save