diff --git a/Session/Conversations/Message Cells/VisibleMessageCell.swift b/Session/Conversations/Message Cells/VisibleMessageCell.swift index bbcd2679a..114bf34b0 100644 --- a/Session/Conversations/Message Cells/VisibleMessageCell.swift +++ b/Session/Conversations/Message Cells/VisibleMessageCell.swift @@ -254,8 +254,9 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { let authorLabelSize = authorLabel.sizeThatFits(authorLabelAvailableSpace) authorLabelHeightConstraint.constant = (viewItem.senderName != nil) ? authorLabelSize.height : 0 // Message status image view - let (image, backgroundColor) = getMessageStatusImage(for: message) + let (image, tintColor, backgroundColor) = getMessageStatusImage(for: message) messageStatusImageView.image = image + messageStatusImageView.tintColor = tintColor messageStatusImageView.backgroundColor = backgroundColor if let message = message as? TSOutgoingMessage { messageStatusImageView.isHidden = (message.messageState == .sent && thread?.lastInteraction != message) @@ -612,20 +613,33 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate { } } - private func getMessageStatusImage(for message: TSMessage) -> (image: UIImage?, backgroundColor: UIColor?) { - guard let message = message as? TSOutgoingMessage else { return (nil, nil) } + private func getMessageStatusImage(for message: TSMessage) -> (image: UIImage?, tintColor: UIColor?, backgroundColor: UIColor?) { + guard let message = message as? TSOutgoingMessage else { return (nil, nil, nil) } + let image: UIImage + var tintColor: UIColor? = nil var backgroundColor: UIColor? = nil let status = MessageRecipientStatusUtils.recipientStatus(outgoingMessage: message) + switch status { - case .uploading, .sending: image = #imageLiteral(resourceName: "CircleDotDotDot").asTintedImage(color: Colors.text)! - case .sent, .skipped, .delivered: image = #imageLiteral(resourceName: "CircleCheck").asTintedImage(color: Colors.text)! - case .read: - backgroundColor = isLightMode ? .black : .white - image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode") - case .failed: image = #imageLiteral(resourceName: "message_status_failed").asTintedImage(color: Colors.destructive)! + case .uploading, .sending: + image = #imageLiteral(resourceName: "CircleDotDotDot").withRenderingMode(.alwaysTemplate) + tintColor = Colors.text + + case .sent, .skipped, .delivered: + image = #imageLiteral(resourceName: "CircleCheck").withRenderingMode(.alwaysTemplate) + tintColor = Colors.text + + case .read: + image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode") + backgroundColor = isLightMode ? .black : .white + + case .failed: + image = #imageLiteral(resourceName: "message_status_failed").withRenderingMode(.alwaysTemplate) + tintColor = Colors.destructive } - return (image, backgroundColor) + + return (image, tintColor, backgroundColor) } private func getSize(for viewItem: ConversationViewItem) -> CGSize { diff --git a/Session/Shared/ConversationCell.swift b/Session/Shared/ConversationCell.swift index 760b2326f..152a442c3 100644 --- a/Session/Shared/ConversationCell.swift +++ b/Session/Shared/ConversationCell.swift @@ -321,19 +321,30 @@ final class ConversationCell : UITableViewCell { statusIndicatorView.backgroundColor = nil let lastMessage = threadViewModel.lastMessageForInbox if let lastMessage = lastMessage as? TSOutgoingMessage { - let image: UIImage let status = MessageRecipientStatusUtils.recipientStatus(outgoingMessage: lastMessage) + switch status { - case .uploading, .sending: image = #imageLiteral(resourceName: "CircleDotDotDot").asTintedImage(color: Colors.text)! - case .sent, .skipped, .delivered: image = #imageLiteral(resourceName: "CircleCheck").asTintedImage(color: Colors.text)! - case .read: - statusIndicatorView.backgroundColor = isLightMode ? .black : .white - image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode") - case .failed: image = #imageLiteral(resourceName: "message_status_failed").asTintedImage(color: Colors.text)! + case .uploading, .sending: + statusIndicatorView.image = #imageLiteral(resourceName: "CircleDotDotDot").withRenderingMode(.alwaysTemplate) + statusIndicatorView.tintColor = Colors.text + + case .sent, .skipped, .delivered: + statusIndicatorView.image = #imageLiteral(resourceName: "CircleCheck").withRenderingMode(.alwaysTemplate) + statusIndicatorView.tintColor = Colors.text + + case .read: + statusIndicatorView.image = isLightMode ? #imageLiteral(resourceName: "FilledCircleCheckLightMode") : #imageLiteral(resourceName: "FilledCircleCheckDarkMode") + statusIndicatorView.tintColor = nil + statusIndicatorView.backgroundColor = (isLightMode ? .black : .white) + + case .failed: + statusIndicatorView.image = #imageLiteral(resourceName: "message_status_failed").withRenderingMode(.alwaysTemplate) + statusIndicatorView.tintColor = Colors.destructive } - statusIndicatorView.image = image + statusIndicatorView.isHidden = false - } else { + } + else { statusIndicatorView.isHidden = true } } diff --git a/Session/Shared/UserCell.swift b/Session/Shared/UserCell.swift index fb493fc5d..8fd199a28 100644 --- a/Session/Shared/UserCell.swift +++ b/Session/Shared/UserCell.swift @@ -83,16 +83,22 @@ final class UserCell : UITableViewCell { profilePictureView.publicKey = publicKey profilePictureView.update() displayNameLabel.text = Storage.shared.getContact(with: publicKey)?.displayName(for: .regular) ?? publicKey + switch accessory { - case .none: accessoryImageView.isHidden = true - case .lock: - accessoryImageView.isHidden = false - accessoryImageView.image = #imageLiteral(resourceName: "ic_lock_outline").asTintedImage(color: Colors.text.withAlphaComponent(Values.mediumOpacity))! - case .tick(let isSelected): - accessoryImageView.isHidden = false - let icon = isSelected ? #imageLiteral(resourceName: "CircleCheck") : #imageLiteral(resourceName: "Circle") - accessoryImageView.image = isDarkMode ? icon : icon.asTintedImage(color: Colors.text)! + case .none: accessoryImageView.isHidden = true + + case .lock: + accessoryImageView.isHidden = false + accessoryImageView.image = #imageLiteral(resourceName: "ic_lock_outline").withRenderingMode(.alwaysTemplate) + accessoryImageView.tintColor = Colors.text.withAlphaComponent(Values.mediumOpacity) + + case .tick(let isSelected): + let icon: UIImage = (isSelected ? #imageLiteral(resourceName: "CircleCheck") : #imageLiteral(resourceName: "Circle")) + accessoryImageView.isHidden = false + accessoryImageView.image = icon.withRenderingMode(.alwaysTemplate) + accessoryImageView.tintColor = Colors.text } + let alpha: CGFloat = isZombie ? 0.5 : 1 [ profilePictureView, displayNameLabel, accessoryImageView ].forEach { $0.alpha = alpha } }