From f185ccf506772766c37bec42a79db86c6483113f Mon Sep 17 00:00:00 2001 From: ryanzhao Date: Tue, 17 Jan 2023 14:24:21 +1100 Subject: [PATCH] add info message view in context menu vc --- .../ContextMenuVC+MessageInfoView.swift | 47 +++++++++++++------ .../Context Menu/ContextMenuVC.swift | 2 +- .../Shared Models/MessageViewModel.swift | 12 ++--- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/Session/Conversations/Context Menu/ContextMenuVC+MessageInfoView.swift b/Session/Conversations/Context Menu/ContextMenuVC+MessageInfoView.swift index 24a23eb84..01cc7bd40 100644 --- a/Session/Conversations/Context Menu/ContextMenuVC+MessageInfoView.swift +++ b/Session/Conversations/Context Menu/ContextMenuVC+MessageInfoView.swift @@ -14,31 +14,33 @@ extension ContextMenuVC { private lazy var messageSentDateLabel: UILabel = { let result: UILabel = UILabel() - result.font = .systemFont(ofSize: Values.mediumFontSize) + result.font = .systemFont(ofSize: Values.smallFontSize) result.themeTextColor = .textPrimary + result.numberOfLines = 0 return result }() private lazy var messageReceivedDateLabel: UILabel = { let result: UILabel = UILabel() - result.font = .systemFont(ofSize: Values.mediumFontSize) + result.font = .systemFont(ofSize: Values.smallFontSize) result.themeTextColor = .textPrimary + result.numberOfLines = 0 return result }() private lazy var profilePictureView: ProfilePictureView = { let result: ProfilePictureView = ProfilePictureView() - result.set(.height, to: Values.verySmallProfilePictureSize) - result.size = Values.verySmallProfilePictureSize + result.set(.height, to: Values.smallProfilePictureSize) + result.size = Values.smallProfilePictureSize return result }() private lazy var displayNameLabel: UILabel = { let result: UILabel = UILabel() - result.font = .boldSystemFont(ofSize: Values.verySmallFontSize) + result.font = .boldSystemFont(ofSize: Values.smallFontSize) result.themeTextColor = .textPrimary return result @@ -48,6 +50,8 @@ extension ContextMenuVC { let result: UILabel = UILabel() result.font = .systemFont(ofSize: Values.verySmallFontSize) result.themeTextColor = .textPrimary + result.numberOfLines = 0 + result.lineBreakMode = .byCharWrapping return result }() @@ -80,8 +84,9 @@ extension ContextMenuVC { let stackView: UIStackView = UIStackView() stackView.axis = .vertical + stackView.spacing = Values.smallSpacing backgroundView.addSubview(stackView) - stackView.pin(to: backgroundView) + stackView.pin(to: backgroundView, withInset: Values.mediumSpacing) messageSentDateLabel.text = "MESSAGE_INFO_SENT".localized() + ":\n" + cellViewModel.dateForUI.fromattedForMessageInfo stackView.addArrangedSubview(messageSentDateLabel) @@ -91,27 +96,39 @@ extension ContextMenuVC { let senderTitleLabel: UILabel = { let result: UILabel = UILabel() - result.font = .systemFont(ofSize: Values.mediumFontSize) + result.font = .systemFont(ofSize: Values.smallFontSize) result.themeTextColor = .textPrimary result.text = "MESSAGE_INFO_FROM".localized() + ":" return result }() - stackView.addArrangedSubview(senderTitleLabel) - - let displayNameStackView: UIStackView = UIStackView(arrangedSubviews: [ displayNameLabel, sessionIDLabel ]) - displayNameStackView.axis = .vertical + displayNameLabel.text = cellViewModel.authorName sessionIDLabel.text = cellViewModel.authorId - - let profileStackView: UIStackView = UIStackView(arrangedSubviews: [ profilePictureView, displayNameStackView ]) - profileStackView.axis = .horizontal profilePictureView.update( publicKey: cellViewModel.authorId, profile: cellViewModel.profile, 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) + } } } diff --git a/Session/Conversations/Context Menu/ContextMenuVC.swift b/Session/Conversations/Context Menu/ContextMenuVC.swift index efc57f11e..31e2e940a 100644 --- a/Session/Conversations/Context Menu/ContextMenuVC.swift +++ b/Session/Conversations/Context Menu/ContextMenuVC.swift @@ -66,7 +66,7 @@ final class ContextMenuVC: UIViewController { result.layer.shadowOpacity = 0.4 result.layer.shadowRadius = 4 result.alpha = 0 - result.set(.width, lessThanOrEqualTo: 280) + result.set(.width, to: 320) return result }() diff --git a/SessionMessagingKit/Shared Models/MessageViewModel.swift b/SessionMessagingKit/Shared Models/MessageViewModel.swift index 72b939b70..9283df818 100644 --- a/SessionMessagingKit/Shared Models/MessageViewModel.swift +++ b/SessionMessagingKit/Shared Models/MessageViewModel.swift @@ -73,7 +73,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable, public let id: Int64 public let variant: Interaction.Variant public let timestampMs: Int64 - public let receivedTimestampMs: Int64 + public let receivedAtTimestampMs: Int64 public let authorId: String private let authorNameInternal: 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)) } /// 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 public let containsOnlyEmoji: Bool? @@ -165,7 +165,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable, id: self.id, variant: self.variant, timestampMs: self.timestampMs, - receivedTimestampMs: self.receivedTimestampMs, + receivedAtTimestampMs: self.receivedAtTimestampMs, authorId: self.authorId, authorNameInternal: self.authorNameInternal, body: self.body, @@ -321,7 +321,7 @@ public struct MessageViewModel: FetchableRecordWithRowId, Decodable, Equatable, id: self.id, variant: self.variant, timestampMs: self.timestampMs, - receivedTimestampMs: self.receivedTimestampMs, + receivedAtTimestampMs: self.receivedAtTimestampMs, authorId: self.authorId, authorNameInternal: self.authorNameInternal, body: (!self.variant.isInfoMessage ? @@ -500,7 +500,7 @@ public extension MessageViewModel { init( variant: Interaction.Variant = .standardOutgoing, timestampMs: Int64 = Int64.max, - receivedTimestampMs: Int64 = Int64.max, + receivedAtTimestampMs: Int64 = Int64.max, body: String? = nil, quote: Quote? = nil, cellType: CellType = .typingIndicator, @@ -527,7 +527,7 @@ public extension MessageViewModel { self.id = targetId self.variant = variant self.timestampMs = timestampMs - self.receivedTimestampMs = receivedTimestampMs + self.receivedAtTimestampMs = receivedAtTimestampMs self.authorId = "" self.authorNameInternal = nil self.body = body