mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-05-07 05:53:06 +00:00
Add loader when upload files
This commit is contained in:
parent
6275697028
commit
15a7a3b298
3 changed files with 120 additions and 50 deletions
|
|
@ -106,6 +106,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
var imagesGridURLCollection : [URL?] = []
|
||||
var imagesGridContentCollection : [Content] = []
|
||||
var downloadContentCollection: [DownloadMessageCell?] = []
|
||||
var uploadContentCollection: [UploadMessageCell?] = []
|
||||
|
||||
let imageViewBubble = UIImageView(image: UIImage(named: "chat_error"))
|
||||
let imageVideoViewBubble = UIImageView(image: UIImage(named: "file_video_default"))
|
||||
|
|
@ -121,6 +122,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
var chatMessageDelegate: ChatMessageDelegate? = nil
|
||||
|
||||
var indexTransferProgress: Int = -1
|
||||
var indexUploadTransferProgress: Int = -1
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
|
@ -1032,7 +1034,7 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
}
|
||||
downloadView.downloadButtonLabel.isUserInteractionEnabled = true
|
||||
|
||||
if(linphone_core_get_max_size_for_auto_download_incoming_files(LinphoneManager.getLc()) > -1 && self.chatMessage!.isFileTransferInProgress){
|
||||
if((linphone_core_get_max_size_for_auto_download_incoming_files(LinphoneManager.getLc()) > -1 && self.chatMessage!.isFileTransferInProgress) || self.chatMessage!.isOutgoing){
|
||||
downloadView.downloadButtonLabel.isHidden = true
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1046,16 +1048,10 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
myImageView.image = self.getImageFrom(self.imagesGridContentCollection[indexPath.row].getCobject, filePath: imageURL?.absoluteString, forReplyBubble: true)!
|
||||
})
|
||||
}else{
|
||||
//let fileNameText = imagesGridURLCollection[indexPath.row]!.lastPathComponent
|
||||
//print("ChatConversationTableViewSwift collectionview \(imagesGridURLCollection[indexPath.row]!.lastPathComponent)")
|
||||
//let fileName = SwiftUtil.textToImage(drawText:fileNameText, inImage:imageCell!, forReplyBubble:true)
|
||||
|
||||
imagesGridURLCollection[indexPath.row] = URL(string: imagesGridContentCollection[indexPath.row].filePath)
|
||||
imagesGridCollectionView[indexPath.row] = getImageFrom(imagesGridContentCollection[indexPath.row].getCobject, filePath: imagesGridURLCollection[indexPath.row]?.absoluteString, forReplyBubble: false)
|
||||
|
||||
myImageView.image = imagesGridCollectionView[indexPath.row]
|
||||
//print("ChatConversationTableViewSwift collectionview \(imagesGridURLCollection[indexPath.row]!.absoluteString)")
|
||||
//myImageView.image = getImageFrom(imagesGridContentCollection[indexPath.row].getCobject, filePath: imagesGridURLCollection[indexPath.row]?.absoluteString, forReplyBubble: true)
|
||||
}
|
||||
|
||||
myImageView.size(w: (viewCell.frame.width), h: (viewCell.frame.height)).done()
|
||||
|
|
@ -1075,6 +1071,13 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
}
|
||||
myImageView.contentMode = .scaleAspectFill
|
||||
myImageView.clipsToBounds = true
|
||||
|
||||
|
||||
let uploadView = UploadMessageCell()
|
||||
uploadContentCollection.append(uploadView)
|
||||
uploadView.content = imagesGridContentCollection[indexPath.row]
|
||||
uploadView.size(w: 138, h: 138).done()
|
||||
viewCell.addSubview(uploadView)
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1214,52 +1217,74 @@ class MultilineMessageCell: UICollectionViewCell, UICollectionViewDataSource, UI
|
|||
func file_transfer_progress_indication_recv(message: ChatMessage, content: Content, offset: Int, total: Int) {
|
||||
let p = Float(offset) / Float(total)
|
||||
|
||||
if indexTransferProgress == -1 {
|
||||
for indexItem in 0...imagesGridContentCollection.count - 1 {
|
||||
if imagesGridContentCollection[indexItem].name == content.name {
|
||||
indexTransferProgress = indexItem
|
||||
break
|
||||
if (imagesGridContentCollection.count > 0){
|
||||
if !message.isOutgoing {
|
||||
if (indexTransferProgress == -1) {
|
||||
for indexItem in 0...imagesGridContentCollection.count - 1 {
|
||||
if imagesGridContentCollection[indexItem].name == content.name {
|
||||
indexTransferProgress = indexItem
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if downloadContentCollection[indexTransferProgress] != nil {
|
||||
downloadContentCollection[indexTransferProgress]!.downloadButtonLabel.isHidden = true
|
||||
downloadContentCollection[indexTransferProgress]!.circularProgressBarView.isHidden = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if downloadContentCollection[indexTransferProgress] != nil {
|
||||
downloadContentCollection[indexTransferProgress]!.downloadButtonLabel.isHidden = true
|
||||
downloadContentCollection[indexTransferProgress]!.circularProgressBarView.isHidden = false
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async(execute: { [self] in
|
||||
if (offset == total) {
|
||||
downloadContentCollection[indexTransferProgress] = nil
|
||||
imagesGridContentCollection[indexTransferProgress] = content
|
||||
imagesGridURLCollection[indexTransferProgress] = (URL(string: content.filePath)!)
|
||||
imagesGridCollectionView[indexTransferProgress] = getImageFrom(content.getCobject, filePath: content.filePath, forReplyBubble: true)!
|
||||
|
||||
|
||||
if (imagesGridCollectionView.count <= 1){
|
||||
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: content.filePath){
|
||||
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||
if (imageVideoViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||
}
|
||||
} else if let imageMessage = UIImage(named: content.filePath){
|
||||
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||
if (imageViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
|
||||
}
|
||||
} else {
|
||||
collectionViewImagesGrid.reloadItems(at: [IndexPath(row: indexTransferProgress, section: 0)])
|
||||
indexTransferProgress = -1
|
||||
}
|
||||
}else{
|
||||
collectionViewImagesGrid.reloadItems(at: [IndexPath(row: indexTransferProgress, section: 0)])
|
||||
indexTransferProgress = -1
|
||||
}
|
||||
DispatchQueue.main.async(execute: { [self] in
|
||||
if (offset == total) {
|
||||
downloadContentCollection[indexTransferProgress] = nil
|
||||
imagesGridContentCollection[indexTransferProgress] = content
|
||||
imagesGridURLCollection[indexTransferProgress] = (URL(string: content.filePath)!)
|
||||
imagesGridCollectionView[indexTransferProgress] = getImageFrom(content.getCobject, filePath: content.filePath, forReplyBubble: true)!
|
||||
|
||||
|
||||
if (imagesGridCollectionView.count <= 1){
|
||||
if let imageMessage = createThumbnailOfVideoFromFileURL(videoURL: content.filePath){
|
||||
imageVideoViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||
if (imageVideoViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
|
||||
}
|
||||
} else if let imageMessage = UIImage(named: content.filePath){
|
||||
imageViewBubble.image = resizeImage(image: imageMessage, targetSize: CGSizeMake(UIScreen.main.bounds.size.width*3/4, 300.0))
|
||||
if (imageViewBubble.image != nil && imagesGridCollectionView.count <= 1){
|
||||
ChatConversationTableViewModel.sharedModel.reloadCollectionViewCell()
|
||||
}
|
||||
} else {
|
||||
collectionViewImagesGrid.reloadItems(at: [IndexPath(row: indexTransferProgress, section: 0)])
|
||||
indexTransferProgress = -1
|
||||
}
|
||||
}else{
|
||||
collectionViewImagesGrid.reloadItems(at: [IndexPath(row: indexTransferProgress, section: 0)])
|
||||
indexTransferProgress = -1
|
||||
}
|
||||
} else {
|
||||
if downloadContentCollection[indexTransferProgress] != nil {
|
||||
downloadContentCollection[indexTransferProgress]!.setUpCircularProgressBarView(toValue: p)
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if downloadContentCollection[indexTransferProgress] != nil {
|
||||
downloadContentCollection[indexTransferProgress]!.setUpCircularProgressBarView(toValue: p)
|
||||
}
|
||||
if (indexUploadTransferProgress == -1) {
|
||||
for indexItem in 0...imagesGridContentCollection.count - 1 {
|
||||
if imagesGridContentCollection[indexItem].name == content.name {
|
||||
indexUploadTransferProgress = indexItem
|
||||
break
|
||||
}
|
||||
}
|
||||
uploadContentCollection[indexUploadTransferProgress]!.circularProgressBarView.isHidden = false
|
||||
}
|
||||
DispatchQueue.main.async(execute: { [self] in
|
||||
if (offset == total) {
|
||||
uploadContentCollection[indexUploadTransferProgress]!.circularProgressBarView.isHidden = true
|
||||
indexUploadTransferProgress = -1
|
||||
} else {
|
||||
uploadContentCollection[indexUploadTransferProgress]!.setUpCircularProgressBarView(toValue: p)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func displayImdnStatus(message: ChatMessage, state: ChatMessage.State) {
|
||||
|
|
|
|||
41
Classes/Swift/Chat/Views/UploadMessageCell.swift
Normal file
41
Classes/Swift/Chat/Views/UploadMessageCell.swift
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
//
|
||||
// UploadMessageCell.swift
|
||||
// linphone
|
||||
//
|
||||
// Created by Benoît Martins on 24/03/2023.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import linphonesw
|
||||
|
||||
class UploadMessageCell: UIView {
|
||||
var circularProgressBarView = CircularProgressBarView()
|
||||
let circularProgressBarLabel = StyledLabel(VoipTheme.chat_conversation_download_progress_text)
|
||||
|
||||
var content: Content? = nil
|
||||
var fromValue : Float = 0.0
|
||||
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
addSubview(circularProgressBarView)
|
||||
circularProgressBarView.isHidden = true
|
||||
circularProgressBarLabel.text = "0%"
|
||||
circularProgressBarLabel.size(w: 30, h: 30).done()
|
||||
circularProgressBarView.addSubview(circularProgressBarLabel)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
func setUpCircularProgressBarView(toValue: Float) {
|
||||
|
||||
circularProgressBarLabel.text = "\(Int(toValue*100))%"
|
||||
circularProgressBarLabel.center = CGPoint(x: 69, y: 69)
|
||||
|
||||
|
||||
circularProgressBarView.progressAnimation(fromValue: fromValue, toValue: toValue)
|
||||
fromValue = toValue
|
||||
}
|
||||
}
|
||||
|
|
@ -950,6 +950,7 @@
|
|||
D71418E529C9E2CD002EEF75 /* CircularProgressBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D71418E429C9E2CD002EEF75 /* CircularProgressBarView.swift */; };
|
||||
D7421D9E29228A5200290CAB /* ChatConversationViewSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7421D9D29228A5200290CAB /* ChatConversationViewSwift.swift */; };
|
||||
D74A44912923BAF90017D063 /* BackActionsNavigationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D74A44902923BAF90017D063 /* BackActionsNavigationView.swift */; };
|
||||
D768763529CDA88200570747 /* UploadMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D768763429CDA88200570747 /* UploadMessageCell.swift */; };
|
||||
D77057F1292E4A340031A970 /* ChatConversationViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D77057F0292E4A340031A970 /* ChatConversationViewModel.swift */; };
|
||||
D779D39829A3C933007B8087 /* ChatConversationTableViewSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = D779D39729A3C933007B8087 /* ChatConversationTableViewSwift.swift */; };
|
||||
D779D39A29A4C285007B8087 /* MultilineMessageCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D779D39929A4C285007B8087 /* MultilineMessageCell.swift */; };
|
||||
|
|
@ -2213,6 +2214,7 @@
|
|||
D71418E429C9E2CD002EEF75 /* CircularProgressBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBarView.swift; sourceTree = "<group>"; };
|
||||
D7421D9D29228A5200290CAB /* ChatConversationViewSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatConversationViewSwift.swift; sourceTree = "<group>"; };
|
||||
D74A44902923BAF90017D063 /* BackActionsNavigationView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BackActionsNavigationView.swift; sourceTree = "<group>"; };
|
||||
D768763429CDA88200570747 /* UploadMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UploadMessageCell.swift; sourceTree = "<group>"; };
|
||||
D77057F0292E4A340031A970 /* ChatConversationViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatConversationViewModel.swift; sourceTree = "<group>"; };
|
||||
D779D39729A3C933007B8087 /* ChatConversationTableViewSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatConversationTableViewSwift.swift; sourceTree = "<group>"; };
|
||||
D779D39929A4C285007B8087 /* MultilineMessageCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MultilineMessageCell.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -3895,6 +3897,7 @@
|
|||
D7C6DE822948CF3100756E03 /* DropDownCell.xib */,
|
||||
D71418E229C9B4E0002EEF75 /* DownloadMessageCell.swift */,
|
||||
D71418E429C9E2CD002EEF75 /* CircularProgressBarView.swift */,
|
||||
D768763429CDA88200570747 /* UploadMessageCell.swift */,
|
||||
);
|
||||
path = Views;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -5213,6 +5216,7 @@
|
|||
617C242A263022690042FB4A /* UIChatContentView.m in Sources */,
|
||||
C63F7261285A24B10066163B /* CallControlButton.swift in Sources */,
|
||||
D3ED3EA71587334E006C0DE4 /* HistoryListTableView.m in Sources */,
|
||||
D768763529CDA88200570747 /* UploadMessageCell.swift in Sources */,
|
||||
C63F7220285A24B10066163B /* TimestampUtils.swift in Sources */,
|
||||
61AEBEBD2191990A00F35E7F /* DevicesListView.m in Sources */,
|
||||
D3ED3EB81587392C006C0DE4 /* HistoryListView.m in Sources */,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue