add timestamp to call message UI

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

@ -7,6 +7,14 @@ final class CallMessageCell : MessageCell {
// MARK: UI Components
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 = {
let result = UILabel()
result.numberOfLines = 0
@ -30,6 +38,14 @@ final class CallMessageCell : MessageCell {
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
private static let iconSize: CGFloat = 16
private static let inset = Values.mediumSpacing
@ -42,11 +58,12 @@ final class CallMessageCell : MessageCell {
super.setUpViewHierarchy()
iconImageViewWidthConstraint.isActive = true
iconImageViewHeightConstraint.isActive = true
addSubview(container)
container.pin(.left, to: .left, of: self, withInset: CallMessageCell.margin)
container.pin(.top, to: .top, of: self, withInset: CallMessageCell.inset)
container.pin(.right, to: .right, of: self, withInset: -CallMessageCell.margin)
container.pin(.bottom, to: .bottom, of: self, withInset: -CallMessageCell.inset)
addSubview(stackView)
container.autoPinWidthToSuperview()
stackView.pin(.left, to: .left, of: self, withInset: CallMessageCell.margin)
stackView.pin(.top, to: .top, 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
@ -60,10 +77,14 @@ final class CallMessageCell : MessageCell {
default: icon = nil
}
if let icon = icon {
iconImageView.image = icon.withTint(Colors.text)
iconImageView.image = icon
}
iconImageViewWidthConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
iconImageViewHeightConstraint.constant = (icon != nil) ? CallMessageCell.iconSize : 0
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", @"");
case TSInfoMessageTypeGroupUpdated:
return _customMessage != nil ? _customMessage : NSLocalizedString(@"GROUP_UPDATED", @"");
case TSInfoMessageTypeCall:
return _customMessage;
default:
break;
}

Loading…
Cancel
Save