add info message view in context menu vc

pull/782/head
ryanzhao 2 years ago
parent d97730ab63
commit f185ccf506

@ -14,31 +14,33 @@ extension ContextMenuVC {
private lazy var messageSentDateLabel: UILabel = { private lazy var messageSentDateLabel: UILabel = {
let result: UILabel = UILabel() let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.mediumFontSize) result.font = .systemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary result.themeTextColor = .textPrimary
result.numberOfLines = 0
return result return result
}() }()
private lazy var messageReceivedDateLabel: UILabel = { private lazy var messageReceivedDateLabel: UILabel = {
let result: UILabel = UILabel() let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.mediumFontSize) result.font = .systemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary result.themeTextColor = .textPrimary
result.numberOfLines = 0
return result return result
}() }()
private lazy var profilePictureView: ProfilePictureView = { private lazy var profilePictureView: ProfilePictureView = {
let result: ProfilePictureView = ProfilePictureView() let result: ProfilePictureView = ProfilePictureView()
result.set(.height, to: Values.verySmallProfilePictureSize) result.set(.height, to: Values.smallProfilePictureSize)
result.size = Values.verySmallProfilePictureSize result.size = Values.smallProfilePictureSize
return result return result
}() }()
private lazy var displayNameLabel: UILabel = { private lazy var displayNameLabel: UILabel = {
let result: UILabel = UILabel() let result: UILabel = UILabel()
result.font = .boldSystemFont(ofSize: Values.verySmallFontSize) result.font = .boldSystemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary result.themeTextColor = .textPrimary
return result return result
@ -48,6 +50,8 @@ extension ContextMenuVC {
let result: UILabel = UILabel() let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.verySmallFontSize) result.font = .systemFont(ofSize: Values.verySmallFontSize)
result.themeTextColor = .textPrimary result.themeTextColor = .textPrimary
result.numberOfLines = 0
result.lineBreakMode = .byCharWrapping
return result return result
}() }()
@ -80,8 +84,9 @@ extension ContextMenuVC {
let stackView: UIStackView = UIStackView() let stackView: UIStackView = UIStackView()
stackView.axis = .vertical stackView.axis = .vertical
stackView.spacing = Values.smallSpacing
backgroundView.addSubview(stackView) backgroundView.addSubview(stackView)
stackView.pin(to: backgroundView) stackView.pin(to: backgroundView, withInset: Values.mediumSpacing)
messageSentDateLabel.text = "MESSAGE_INFO_SENT".localized() + ":\n" + cellViewModel.dateForUI.fromattedForMessageInfo messageSentDateLabel.text = "MESSAGE_INFO_SENT".localized() + ":\n" + cellViewModel.dateForUI.fromattedForMessageInfo
stackView.addArrangedSubview(messageSentDateLabel) stackView.addArrangedSubview(messageSentDateLabel)
@ -91,27 +96,39 @@ extension ContextMenuVC {
let senderTitleLabel: UILabel = { let senderTitleLabel: UILabel = {
let result: UILabel = UILabel() let result: UILabel = UILabel()
result.font = .systemFont(ofSize: Values.mediumFontSize) result.font = .systemFont(ofSize: Values.smallFontSize)
result.themeTextColor = .textPrimary result.themeTextColor = .textPrimary
result.text = "MESSAGE_INFO_FROM".localized() + ":" result.text = "MESSAGE_INFO_FROM".localized() + ":"
return result return result
}() }()
stackView.addArrangedSubview(senderTitleLabel)
let displayNameStackView: UIStackView = UIStackView(arrangedSubviews: [ displayNameLabel, sessionIDLabel ])
displayNameStackView.axis = .vertical
displayNameLabel.text = cellViewModel.authorName displayNameLabel.text = cellViewModel.authorName
sessionIDLabel.text = cellViewModel.authorId sessionIDLabel.text = cellViewModel.authorId
let profileStackView: UIStackView = UIStackView(arrangedSubviews: [ profilePictureView, displayNameStackView ])
profileStackView.axis = .horizontal
profilePictureView.update( profilePictureView.update(
publicKey: cellViewModel.authorId, publicKey: cellViewModel.authorId,
profile: cellViewModel.profile, profile: cellViewModel.profile,
threadVariant: cellViewModel.threadVariant threadVariant: cellViewModel.threadVariant
) )
stackView.addArrangedSubview(profileStackView)
let profileContainerView: UIView = UIView()
profileContainerView.addSubview(senderTitleLabel)
senderTitleLabel.pin([ UIView.HorizontalEdge.leading, UIView.HorizontalEdge.trailing, UIView.VerticalEdge.top ], to: profileContainerView)
profileContainerView.addSubview(profilePictureView)
profilePictureView.pin(.leading, to: .leading, of: profileContainerView)
profilePictureView.pin(.top, to: .bottom, of: senderTitleLabel, withInset: Values.mediumSpacing)
profilePictureView.pin(.bottom, to: .bottom, of: profileContainerView, withInset: -Values.verySmallSpacing)
let infoContainerStackView: UIStackView = UIStackView(arrangedSubviews: [ displayNameLabel, sessionIDLabel ])
infoContainerStackView.axis = .vertical
profileContainerView.addSubview(infoContainerStackView)
infoContainerStackView.pin(.leading, to: .trailing, of: profilePictureView, withInset: Values.mediumSpacing)
infoContainerStackView.pin(.trailing, to: .trailing, of: profileContainerView)
infoContainerStackView.pin(.bottom, to: .bottom, of: profileContainerView)
infoContainerStackView.set(.width, to: 240)
stackView.addArrangedSubview(profileContainerView)
} }
} }
} }

@ -66,7 +66,7 @@ final class ContextMenuVC: UIViewController {
result.layer.shadowOpacity = 0.4 result.layer.shadowOpacity = 0.4
result.layer.shadowRadius = 4 result.layer.shadowRadius = 4
result.alpha = 0 result.alpha = 0
result.set(.width, lessThanOrEqualTo: 280) result.set(.width, to: 320)
return result return result
}() }()

@ -73,7 +73,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
public let id: Int64 public let id: Int64
public let variant: Interaction.Variant public let variant: Interaction.Variant
public let timestampMs: Int64 public let timestampMs: Int64
public let receivedTimestampMs: Int64 public let receivedAtTimestampMs: Int64
public let authorId: String public let authorId: String
private let authorNameInternal: String? private let authorNameInternal: String?
public let body: String? public let body: String?
@ -124,7 +124,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
public var dateForUI: Date { Date(timeIntervalSince1970: (TimeInterval(self.timestampMs) / 1000)) } public var dateForUI: Date { Date(timeIntervalSince1970: (TimeInterval(self.timestampMs) / 1000)) }
/// This value will be used to populate the Message Info (if present) /// This value will be used to populate the Message Info (if present)
public var receivedDateForUI: Date { Date(timeIntervalSince1970: (TimeInterval(self.receivedTimestampMs) / 1000)) } public var receivedDateForUI: Date { Date(timeIntervalSince1970: (TimeInterval(self.receivedAtTimestampMs) / 1000)) }
/// This value specifies whether the body contains only emoji characters /// This value specifies whether the body contains only emoji characters
public let containsOnlyEmoji: Bool? public let containsOnlyEmoji: Bool?
@ -165,7 +165,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
id: self.id, id: self.id,
variant: self.variant, variant: self.variant,
timestampMs: self.timestampMs, timestampMs: self.timestampMs,
receivedTimestampMs: self.receivedTimestampMs, receivedAtTimestampMs: self.receivedAtTimestampMs,
authorId: self.authorId, authorId: self.authorId,
authorNameInternal: self.authorNameInternal, authorNameInternal: self.authorNameInternal,
body: self.body, body: self.body,
@ -321,7 +321,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable,
id: self.id, id: self.id,
variant: self.variant, variant: self.variant,
timestampMs: self.timestampMs, timestampMs: self.timestampMs,
receivedTimestampMs: self.receivedTimestampMs, receivedAtTimestampMs: self.receivedAtTimestampMs,
authorId: self.authorId, authorId: self.authorId,
authorNameInternal: self.authorNameInternal, authorNameInternal: self.authorNameInternal,
body: (!self.variant.isInfoMessage ? body: (!self.variant.isInfoMessage ?
@ -500,7 +500,7 @@ public extension MessageViewModel {
init( init(
variant: Interaction.Variant = .standardOutgoing, variant: Interaction.Variant = .standardOutgoing,
timestampMs: Int64 = Int64.max, timestampMs: Int64 = Int64.max,
receivedTimestampMs: Int64 = Int64.max, receivedAtTimestampMs: Int64 = Int64.max,
body: String? = nil, body: String? = nil,
quote: Quote? = nil, quote: Quote? = nil,
cellType: CellType = .typingIndicator, cellType: CellType = .typingIndicator,
@ -527,7 +527,7 @@ public extension MessageViewModel {
self.id = targetId self.id = targetId
self.variant = variant self.variant = variant
self.timestampMs = timestampMs self.timestampMs = timestampMs
self.receivedTimestampMs = receivedTimestampMs self.receivedAtTimestampMs = receivedAtTimestampMs
self.authorId = "" self.authorId = ""
self.authorNameInternal = nil self.authorNameInternal = nil
self.body = body self.body = body

Loading…
Cancel
Save