From 8804b05ae6ada0d64d749d30a9491b6c9fa784f6 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 12 Feb 2021 13:34:20 +1100 Subject: [PATCH] Show timestamps --- .../Context Menu/ContextMenuVC.swift | 18 ++++++++++++++++++ Session/Conversations V2/ConversationVC.swift | 1 - .../Message Cells/VisibleMessageCell.swift | 13 +++++++------ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Session/Conversations V2/Context Menu/ContextMenuVC.swift b/Session/Conversations V2/Context Menu/ContextMenuVC.swift index 76469c115..e02d1e5c0 100644 --- a/Session/Conversations V2/Context Menu/ContextMenuVC.swift +++ b/Session/Conversations V2/Context Menu/ContextMenuVC.swift @@ -18,6 +18,14 @@ final class ContextMenuVC : UIViewController { return result }() + private lazy var timestampLabel: UILabel = { + let result = UILabel() + result.text = DateUtil.formatTimestamp(asTime: viewItem.interaction.timestampForUI()) + result.font = .systemFont(ofSize: Values.verySmallFontSize) + result.textColor = Colors.text + return result + }() + // MARK: Settings private static let actionViewHeight: CGFloat = 40 @@ -56,6 +64,15 @@ final class ContextMenuVC : UIViewController { snapshot.pin(.top, to: .top, of: view, withInset: frame.origin.y) snapshot.set(.width, to: frame.width) snapshot.set(.height, to: frame.height) + // Timestamp + view.addSubview(timestampLabel) + timestampLabel.center(.vertical, in: snapshot) + let isOutgoing = (viewItem.interaction.interactionType() == .outgoingMessage) + if isOutgoing { + timestampLabel.pin(.right, to: .left, of: snapshot, withInset: -Values.smallSpacing) + } else { + timestampLabel.pin(.left, to: .right, of: snapshot, withInset: Values.smallSpacing) + } // Menu let menuBackgroundView = UIView() menuBackgroundView.backgroundColor = Colors.receivedMessageBackground @@ -110,6 +127,7 @@ final class ContextMenuVC : UIViewController { UIView.animate(withDuration: 0.25, animations: { self.blurView.effect = nil self.menuView.alpha = 0 + self.timestampLabel.alpha = 0 }, completion: { _ in self.dismiss() }) diff --git a/Session/Conversations V2/ConversationVC.swift b/Session/Conversations V2/ConversationVC.swift index 3f6174bba..b0939b219 100644 --- a/Session/Conversations V2/ConversationVC.swift +++ b/Session/Conversations V2/ConversationVC.swift @@ -8,7 +8,6 @@ // • Tapping links in link previews // • Link previews // • Animation glitch when leaving conversation (probably because vc is resigning first responder) -// • Timestamps final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewDataSource, UITableViewDelegate { let thread: TSThread diff --git a/Session/Conversations V2/Message Cells/VisibleMessageCell.swift b/Session/Conversations V2/Message Cells/VisibleMessageCell.swift index 4b88bcbb2..7dc0e5f3b 100644 --- a/Session/Conversations V2/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations V2/Message Cells/VisibleMessageCell.swift @@ -410,10 +410,7 @@ final class VisibleMessageCell : MessageCell, UITextViewDelegate, BodyTextViewDe if abs(translationX) > VisibleMessageCell.swipeToReplyThreshold { reply() } else { - UIView.animate(withDuration: 0.25) { - viewsToMove.forEach { $0.transform = CGAffineTransform(translationX: -VisibleMessageCell.maxBubbleTranslationX, y: 0) } - self.replyButton.alpha = 1 - } + resetReply() } default: break } @@ -424,13 +421,17 @@ final class VisibleMessageCell : MessageCell, UITextViewDelegate, BodyTextViewDe return false } - private func reply() { - guard let viewItem = viewItem else { return } + private func resetReply() { let viewsToMove = [ bubbleView, profilePictureView, replyButton ] UIView.animate(withDuration: 0.25) { viewsToMove.forEach { $0.transform = .identity } self.replyButton.alpha = 0 } + } + + private func reply() { + guard let viewItem = viewItem else { return } + resetReply() delegate?.handleReplyButtonTapped(for: viewItem) }