marinofaggiana 3 years ago
parent
commit
6b07c60d3a

+ 2 - 2
iOSClient/Networking/NCNetworkingChunkedUpload.swift

@@ -60,8 +60,8 @@ extension NCNetworking {
             NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["serverUrl":metadata.serverUrl])
         }
 
-        NCContentPresenter.shared.messageNotification("_info_", description: "_upload_chunk_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode:0, forced: false)
-        
+        NCContentPresenter.shared.noteTop(text: NSLocalizedString("_upload_chunk_", comment: ""), image: nil, color: .lightGray, type: NCContentPresenter.messageType.info, delay: NCGlobal.shared.dismissAfterSecond, name: nil)
+                
         createChunkedFolder(chunkFolderPath: chunkFolderPath, account: metadata.account) { (errorCode, errorDescription) in
             
             completion(errorCode, errorDescription)

+ 1 - 1
iOSClient/Networking/NCNetworkingE2EE.swift

@@ -261,7 +261,7 @@ import Alamofire
         
         NotificationCenter.default.postOnMainThread(name: NCGlobal.shared.notificationCenterReloadDataSource, userInfo: ["ocId":metadata.ocId, "serverUrl":metadata.serverUrl])
         
-        NCContentPresenter.shared.messageNotification("_info_", description: "_upload_e2ee_", delay: NCGlobal.shared.dismissAfterSecond, type: NCContentPresenter.messageType.info, errorCode:0, forced: false)
+        NCContentPresenter.shared.noteTop(text: NSLocalizedString("_upload_e2ee_", comment: ""), image: nil, color: .lightGray, type: NCContentPresenter.messageType.info, delay: NCGlobal.shared.dismissAfterSecond, name: nil)
         
         NCNetworkingE2EE.shared.sendE2EMetadata(account: metadata.account, serverUrl: serverUrl, fileNameRename: nil, fileNameNewRename: nil, deleteE2eEncryption: nil, urlBase: account.urlBase, upload: true) { (e2eToken, errorCode, errorDescription) in
             

+ 35 - 3
iOSClient/Utility/NCContentPresenter.swift

@@ -89,7 +89,7 @@ class NCContentPresenter: NSObject {
             switch errorCode {
             case Int(CFNetworkErrors.cfurlErrorNotConnectedToInternet.rawValue):
                 let image = UIImage(named: "networkInProgress")!.image(color: .white, size: 20)
-                self.noteTop(text:  NSLocalizedString(title, comment: ""), image: image, color: .lightGray, delay: delay, name: "\(errorCode)")
+                self.noteTop(text: NSLocalizedString(title, comment: ""), image: image, color: .lightGray, delay: delay, name: "\(errorCode)")
             //case Int(kOCErrorServerUnauthorized), Int(kOCErrorServerForbidden):
             //    break
             default:
@@ -166,14 +166,46 @@ class NCContentPresenter: NSObject {
     
     //MARK: - Note Message
     
-    @objc func noteTop(text: String, image: UIImage?, color: UIColor, delay: TimeInterval, name: String?) {
+    func noteTop(text: String, image: UIImage?, color: UIColor? = nil, type: messageType? = nil, delay: TimeInterval, name: String?) {
         
         var attributes = EKAttributes.topNote
         
         attributes.windowLevel = .normal
         attributes.displayDuration = delay
         attributes.name = name
-        attributes.entryBackground = .color(color: EKColor(color))
+        if let color = color {
+            attributes.entryBackground = .color(color: EKColor(color))
+        }
+        if let type = type {
+            attributes.entryBackground = .color(color: EKColor(getBackgroundColorFromType(type)))
+        }
+        
+        let style = EKProperty.LabelStyle(font: MainFont.light.with(size: 14), color: .white, alignment: .center)
+        let labelContent = EKProperty.LabelContent(text: text, style: style)
+        
+        if let image = image {
+            let imageContent = EKProperty.ImageContent(image: image, size: CGSize(width: 17, height: 17))
+            let contentView = EKImageNoteMessageView(with: labelContent, imageContent: imageContent)
+            DispatchQueue.main.async { SwiftEntryKit.display(entry: contentView, using: attributes) }
+        } else {
+            let contentView = EKNoteMessageView(with: labelContent)
+            DispatchQueue.main.async { SwiftEntryKit.display(entry: contentView, using: attributes) }
+        }
+    }
+    
+    func noteBottom(text: String, image: UIImage?, color: UIColor? = nil, type: messageType? = nil, delay: TimeInterval, name: String?) {
+        
+        var attributes = EKAttributes.bottomNote
+        
+        attributes.windowLevel = .normal
+        attributes.displayDuration = delay
+        attributes.name = name
+        if let color = color {
+            attributes.entryBackground = .color(color: EKColor(color))
+        }
+        if let type = type {
+            attributes.entryBackground = .color(color: EKColor(getBackgroundColorFromType(type)))
+        }
         
         let style = EKProperty.LabelStyle(font: MainFont.light.with(size: 14), color: .white, alignment: .center)
         let labelContent = EKProperty.LabelContent(text: text, style: style)