diff --git a/iGap/Libraries/Chat Screen/Controller/IGMessageViewController.swift b/iGap/Libraries/Chat Screen/Controller/IGMessageViewController.swift index 7551fbf..5c6c837 100644 --- a/iGap/Libraries/Chat Screen/Controller/IGMessageViewController.swift +++ b/iGap/Libraries/Chat Screen/Controller/IGMessageViewController.swift @@ -1762,6 +1762,11 @@ extension IGMessageViewController: IGMessageGeneralCollectionViewCellDelegate { //TODO: check forwarded attachment let message = cellMessage if message.attachment == nil { + + if message.forwardedFrom?.attachment != nil { + didTapOnForwardedAttachment(cellMessage: cellMessage, cell: cell) + } + return } diff --git a/iGap/Libraries/Chat Screen/Model/IGMessageCollectionViewCellSizeCalculator.swift b/iGap/Libraries/Chat Screen/Model/IGMessageCollectionViewCellSizeCalculator.swift index d0331e4..2838a47 100644 --- a/iGap/Libraries/Chat Screen/Model/IGMessageCollectionViewCellSizeCalculator.swift +++ b/iGap/Libraries/Chat Screen/Model/IGMessageCollectionViewCellSizeCalculator.swift @@ -204,6 +204,10 @@ class IGMessageCollectionViewCellSizeCalculator: NSObject { if message.forwardedFrom != nil { if message.forwardedFrom?.type == .contact { finalSize.width = 200 + } else if message.forwardedFrom?.type == .audio || message.forwardedFrom?.type == .audioAndText { + finalSize.width = 220 + } else if message.forwardedFrom?.type == .voice { + finalSize.width = 250 } } diff --git a/iGap/Libraries/Chat Screen/View/IGMessageCollectionViewCell.swift b/iGap/Libraries/Chat Screen/View/IGMessageCollectionViewCell.swift index b6ad269..d442c30 100644 --- a/iGap/Libraries/Chat Screen/View/IGMessageCollectionViewCell.swift +++ b/iGap/Libraries/Chat Screen/View/IGMessageCollectionViewCell.swift @@ -580,7 +580,7 @@ class IGMessageCollectionViewCell: IGMessageGeneralCollectionViewCell { } } break - case .voice , .audio ,.audioAndText : + case .voice : self.forwardedMessageMediaContainerViewHeightConstraint.constant = 0 self.forwardedMessageAudioAndVoiceView.isHidden = false self.forwardedMessageAudioAndVoiceViewHeightConstraint.constant = messageSizes.forwardedMessageAttachmentHeight @@ -589,20 +589,71 @@ class IGMessageCollectionViewCell: IGMessageGeneralCollectionViewCell { self.forwardedMessageAudioAndVoiceView.addSubview(forwardMediaFileAttachment!) forwardMediaFileAttachment?.attachment = attachment break + + case .audio , .audioAndText : + + self.mediaContainerViewHeightConstraint.constant = 0 + self.attachmentViewHeightConstraint.constant = 91.0 + self.attachmentContainreView.isHidden = false + self.attachmentThumbnailImageView.isHidden = false + self.attachmentFileNameLabel.isHidden = false + self.attachmentFileArtistLabel.isHidden = false + self.attachmentProgressSlider.isHidden = false + self.attachmentTimeOrSizeLabel.isHidden = false + self.attachmentFileNameLabel.text = attachment.name + if isIncommingMessage { + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb"), for: .normal) + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb"), for: .focused) + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb"), for: .selected) + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb"), for: .highlighted) + } else { + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb_Outgoing"), for: .normal) + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb_Outgoing"), for: .focused) + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb_Outgoing"), for: .selected) + self.attachmentProgressSlider.setThumbImage(UIImage(named: "IG_Message_Cell_Player_Slider_Thumb_Outgoing"), for: .highlighted) + } + + self.attachmentProgressSlider.setValue(0.0, animated: false) + self.attachmentThumbnailImageView.setThumbnail(for: attachment) + self.attachmentProgressSliderLeadingConstraint.constant = 8.0 + self.attachmentThumbnailImageView.layer.cornerRadius = 16.0 + self.attachmentThumbnailImageView.layer.masksToBounds = true + if self.attachment?.status != .ready { + self.attachmentDownloadUploadIndicatorView.layer.cornerRadius = 16.0 + self.attachmentDownloadUploadIndicatorView.layer.masksToBounds = true + self.attachmentDownloadUploadIndicatorView.size = attachment.sizeToString() + self.attachmentDownloadUploadIndicatorView.delegate = self + } + let timeM = Int(attachment.duration / 60) + let timeS = Int(attachment.duration.truncatingRemainder(dividingBy: 60.0)) + self.attachmentTimeOrSizeLabel.text = "0:00 / \(timeM):\(timeS)" + + forwardedMessageBodyContainerView.isHidden = true + forwardedMessageBodyLabel.isHidden = true + contactsContainerView.isHidden = false + + self.forwardedMessageAudioAndVoiceViewHeightConstraint.constant = 0 + self.forwardedFromViewHeightConstraint.constant = 20 + contactsContainerViewHeightConstraint.constant = 100 + + timeLabel.backgroundColor = UIColor.clear default: break } } else { if originalMessage.type == .contact { + forwardedMessageBodyContainerView.isHidden = true forwardedMessageBodyLabel.isHidden = true - self.forwardedFromViewHeightConstraint.constant = 20 - timeLabel.backgroundColor = UIColor.clear contactsContainerView.isHidden = false + + self.forwardedMessageAudioAndVoiceViewHeightConstraint.constant = 0 + self.forwardedFromViewHeightConstraint.constant = 20 contactsContainerViewHeightConstraint.constant = 100 + + timeLabel.backgroundColor = UIColor.clear contactsContainerView.setContact((message.forwardedFrom?.contact!)!, isIncommingMessage: isIncommingMessage) - self.forwardedMessageAudioAndVoiceViewHeightConstraint.constant = 0 } else { self.forwardedMessageMediaContainerViewHeightConstraint.constant = 0 self.forwardedMessageAudioAndVoiceViewHeightConstraint.constant = 0 @@ -781,10 +832,22 @@ class IGMessageCollectionViewCell: IGMessageGeneralCollectionViewCell { break } } else { - mediaContainerView.isHidden = true - mediaContainerViewHeightConstraint.constant = 0 - attachmentContainreView.isHidden = true - attachmentViewHeightConstraint.constant = 0.0 + + if let forwardMessage = message.forwardedFrom { + if forwardMessage.type == .audio || forwardMessage.type == .audioAndText { + // do nothing + } else { + mediaContainerView.isHidden = true + mediaContainerViewHeightConstraint.constant = 0 + attachmentContainreView.isHidden = true + attachmentViewHeightConstraint.constant = 0.0 + } + } else { + mediaContainerView.isHidden = true + mediaContainerViewHeightConstraint.constant = 0 + attachmentContainreView.isHidden = true + attachmentViewHeightConstraint.constant = 0.0 + } } //MARK: Body Text (message) @@ -822,9 +885,9 @@ class IGMessageCollectionViewCell: IGMessageGeneralCollectionViewCell { timeLabel.text = time.convertToHumanReadable() timeLabel.isHidden = false timeLabel.textColor = UIColor.chatTimeTextColor(isIncommingMessage: isIncommingMessage) - if message.type == .voice || message.type == .file { - timeLabel.backgroundColor = UIColor.clear - } + //if message.type == .voice || message.type == .file { + timeLabel.backgroundColor = UIColor.clear + //} } //MARK: Edited