add timestamp to call message UI

pull/560/head
Ryan Zhao 4 years ago
parent 35f75490a4
commit 6703d8c7f4

@ -7,6 +7,14 @@ final class CallMessageCell : MessageCell {
// MARK: UI Components // MARK: UI Components
private lazy var iconImageView = UIImageView() private lazy var iconImageView = UIImageView()
private lazy var timestampLabel: UILabel = {
let result = UILabel()
result.font = .boldSystemFont(ofSize: Values.verySmallFontSize)
result.textColor = Colors.text
result.textAlignment = .center
return result
}()
private lazy var label: UILabel = { private lazy var label: UILabel = {
let result = UILabel() let result = UILabel()
result.numberOfLines = 0 result.numberOfLines = 0
@ -30,6 +38,14 @@ final class CallMessageCell : MessageCell {
return result return result
}() }()
private lazy var stackView: UIStackView = {
let result = UIStackView(arrangedSubviews: [ timestampLabel, container ])
result.axis = .vertical
result.alignment = .center
result.spacing = Values.smallSpacing
return result
}()
// MARK: Settings // MARK: Settings
private static let iconSize: CGFloat = 16 private static let iconSize: CGFloat = 16
private static let inset = Values.mediumSpacing private static let inset = Values.mediumSpacing
@ -42,11 +58,12 @@ final class CallMessageCell : MessageCell {
super.setUpViewHierarchy() super.setUpViewHierarchy()
iconImageViewWidthConstraint.isActive = true iconImageViewWidthConstraint.isActive = true
iconImageViewHeightConstraint.isActive = true iconImageViewHeightConstraint.isActive = true
addSubview(container) addSubview(stackView)
container.pin(.left, to: .left, of: self, withInset: CallMessageCell.margin) container.autoPinWidthToSuperview()
container.pin(.top, to: .top, of: self, withInset: CallMessageCell.inset) stackView.pin(.left, to: .left, of: self, withInset: CallMessageCell.margin)
container.pin(.right, to: .right, of: self, withInset: -CallMessageCell.margin) stackView.pin(.top, to: .top, of: self, withInset: CallMessageCell.inset)
container.pin(.bottom, to: .bottom, of: self, withInset: -CallMessageCell.inset) stackView.pin(.right, to: .right, of: self, withInset: -CallMessageCell.margin)
stackView.pin(.bottom, to: .bottom, of: self, withInset: -CallMessageCell.inset)
} }
// MARK: Updating // MARK: Updating
@ -60,10 +77,14 @@ final class CallMessageCell : MessageCell {
default: icon = nil default: icon = nil
} }
if let icon = icon { if let icon = icon {
iconImageView.image = icon.withTint(Colors.text) iconImageView.image = icon
} }
iconImageViewWidthConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0 iconImageViewWidthConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
iconImageViewHeightConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0 iconImageViewHeightConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
self.label.text = message.customMessage self.label.text = message.customMessage
let date = message.dateForUI()
let description = DateUtil.formatDate(forDisplay: date)
timestampLabel.text = description
} }
} }

@ -113,6 +113,8 @@ NSUInteger TSInfoMessageSchemaVersion = 1;
return NSLocalizedString(@"GROUP_YOU_LEFT", @""); return NSLocalizedString(@"GROUP_YOU_LEFT", @"");
case TSInfoMessageTypeGroupUpdated: case TSInfoMessageTypeGroupUpdated:
return _customMessage != nil ? _customMessage : NSLocalizedString(@"GROUP_UPDATED", @""); return _customMessage != nil ? _customMessage : NSLocalizedString(@"GROUP_UPDATED", @"");
case TSInfoMessageTypeCall:
return _customMessage;
default: default:
break; break;
} }

Loading…
Cancel
Save