Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Debugging View - Forward Audio Item
Browse files Browse the repository at this point in the history
  • Loading branch information
saeedmozaffariGithub committed Jan 7, 2018
1 parent 730f84f commit 62d427b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand Down
85 changes: 74 additions & 11 deletions iGap/Libraries/Chat Screen/View/IGMessageCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 62d427b

Please sign in to comment.