Explorar el Código

update preview chat

alqindiirsyam hace 2 años
padre
commit
b55f00c0bb

+ 15 - 6
appbuilder-ios/AppBuilder/AppBuilder/SecondTabViewController.swift

@@ -1009,11 +1009,14 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
             let text = Utils.previewMessageText(chat: data)
             let idMe = UserDefaults.standard.string(forKey: "me") as String?
             if let attributeText = text as? NSMutableAttributedString {
+                let stringMessage = NSMutableAttributedString(string: "")
                 if data.fpin == idMe {
                     if data.lock == "1" {
-                        messageView.attributedText = ("🚫 _"+"You were deleted this message".localized()+"_").richText()
+                        if data.messageScope == "4" {
+                            stringMessage.append(NSAttributedString(string: "You".localized() + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                        }
+                        stringMessage.append(("🚫 _"+"You were deleted this message".localized()+"_").richText())
                     } else {
-                        let stringMessage = NSMutableAttributedString(string: "")
                         let imageStatus = NSTextAttachment()
                         let status = getRealStatus(messageId: data.messageId)
                         if (status == "1" || status == "2" ) {
@@ -1025,20 +1028,26 @@ extension SecondTabViewController: UITableViewDelegate, UITableViewDataSource {
                         } else {
                             imageStatus.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.systemBlue)
                         }
-                        imageStatus.bounds = CGRect(x: 0, y: 0, width: 15, height: 15)
+                        imageStatus.bounds = CGRect(x: 0, y: -2, width: 15, height: 15)
                         let imageStatusString = NSAttributedString(attachment: imageStatus)
                         stringMessage.append(imageStatusString)
                         stringMessage.append(NSAttributedString(string: " "))
+                        if data.messageScope == "4" {
+                            stringMessage.append(NSAttributedString(string: "You".localized() + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                        }
                         stringMessage.append(attributeText)
-                        messageView.attributedText = stringMessage
                     }
                 } else {
+                    if data.messageScope == "4" {
+                        stringMessage.append(NSAttributedString(string: User.getData(pin: data.fpin)!.firstName + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                    }
                     if data.lock == "1" {
-                        messageView.attributedText = ("🚫 _"+"This message was deleted".localized()+"_").richText()
+                        stringMessage.append(("🚫 _"+"This message was deleted".localized()+"_").richText())
                     } else {
-                        messageView.attributedText = attributeText
+                        stringMessage.append(attributeText)
                     }
                 }
+                messageView.attributedText = stringMessage
             }
             messageView.numberOfLines = 2
             

BIN
appbuilder-ios/DigiXLite/DigiXLite.xcworkspace/xcuserdata/akhmadalqindiirsyam.xcuserdatad/UserInterfaceState.xcuserstate


+ 15 - 6
appbuilder-ios/DigiXLite/DigiXLite/Source/View/Control/ContactChatViewController.swift

@@ -982,11 +982,14 @@ extension ContactChatViewController {
                 let text = Utils.previewMessageText(chat: data)
                 let idMe = UserDefaults.standard.string(forKey: "me") as String?
                 if let attributeText = text as? NSMutableAttributedString {
+                    let stringMessage = NSMutableAttributedString(string: "")
                     if data.fpin == idMe {
                         if data.lock == "1" {
-                            messageView.attributedText = ("🚫 _"+"You were deleted this message".localized()+"_").richText()
+                            if data.messageScope == "4" {
+                                stringMessage.append(NSAttributedString(string: "You".localized() + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                            }
+                            stringMessage.append(("🚫 _"+"You were deleted this message".localized()+"_").richText())
                         } else {
-                            let stringMessage = NSMutableAttributedString(string: "")
                             let imageStatus = NSTextAttachment()
                             let status = getRealStatus(messageId: data.messageId)
                             if (status == "1" || status == "2" ) {
@@ -998,20 +1001,26 @@ extension ContactChatViewController {
                             } else {
                                 imageStatus.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: DigiX.self), with: nil)!.withTintColor(UIColor.systemBlue)
                             }
-                            imageStatus.bounds = CGRect(x: 0, y: 0, width: 15, height: 15)
+                            imageStatus.bounds = CGRect(x: 0, y: -2, width: 15, height: 15)
                             let imageStatusString = NSAttributedString(attachment: imageStatus)
                             stringMessage.append(imageStatusString)
                             stringMessage.append(NSAttributedString(string: " "))
+                            if data.messageScope == "4" {
+                                stringMessage.append(NSAttributedString(string: "You".localized() + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                            }
                             stringMessage.append(attributeText)
-                            messageView.attributedText = stringMessage
                         }
                     } else {
+                        if data.messageScope == "4" {
+                            stringMessage.append(NSAttributedString(string: User.getData(pin: data.fpin)!.firstName + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                        }
                         if data.lock == "1" {
-                            messageView.attributedText = ("🚫 _"+"This message was deleted".localized()+"_").richText()
+                            stringMessage.append(("🚫 _"+"This message was deleted".localized()+"_").richText())
                         } else {
-                            messageView.attributedText = attributeText
+                            stringMessage.append(attributeText)
                         }
                     }
+                    messageView.attributedText = stringMessage
                 }
                 messageView.numberOfLines = 2
                 

+ 14 - 12
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -3519,18 +3519,20 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource {
             let listTextEnter = textChat!.split(separator: "\n")
             for j in 0...listTextEnter.count - 1 {
                 let listText = listTextEnter[j].split(separator: " ")
-                for i in 0...listText.count - 1 {
-                    if listText[i].lowercased().checkStartWithLink() {
-                        let rangeTapLink = (textChat! as NSString).range(of: String(listText[i]))
-                        // Add tap gesture recognizer to the range of text
-                        let attributedString = textChat!.richText(group_id: self.dataGroup["group_id"] as! String)
-                        attributedString.addAttributes([.foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue], range: rangeTapLink)
-                        messageText.attributedText = attributedString
-                        if messageText.isUserInteractionEnabled == false && !copySession && !forwardSession && !deleteSession && !isHistoryCC && !removed {
-                            messageText.isUserInteractionEnabled = true
-                            let longPress = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressLink(_:)))
-                            longPress.minimumPressDuration = 0.1
-                            containerMessage.addGestureRecognizer(longPress)
+                if listText.count > 0 {
+                    for i in 0...listText.count - 1 {
+                        if listText[i].lowercased().checkStartWithLink() {
+                            let rangeTapLink = (textChat! as NSString).range(of: String(listText[i]))
+                            // Add tap gesture recognizer to the range of text
+                            let attributedString = textChat!.richText(group_id: self.dataGroup["group_id"] as! String)
+                            attributedString.addAttributes([.foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue], range: rangeTapLink)
+                            messageText.attributedText = attributedString
+                            if messageText.isUserInteractionEnabled == false && !copySession && !forwardSession && !deleteSession && !isHistoryCC && !removed {
+                                messageText.isUserInteractionEnabled = true
+                                let longPress = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressLink(_:)))
+                                longPress.minimumPressDuration = 0.1
+                                containerMessage.addGestureRecognizer(longPress)
+                            }
                         }
                     }
                 }

+ 14 - 12
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -4900,18 +4900,20 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
             let listTextEnter = textChat.split(separator: "\n")
             for j in 0...listTextEnter.count - 1 {
                 let listText = listTextEnter[j].split(separator: " ")
-                for i in 0...listText.count - 1 {
-                    if listText[i].lowercased().checkStartWithLink() {
-                        let rangeTapLink = (textChat as NSString).range(of: String(listText[i]))
-                        // Add tap gesture recognizer to the range of text
-                        let attributedString = textChat.richText()
-                        attributedString.addAttributes([.foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue], range: rangeTapLink)
-                        messageText.attributedText = attributedString
-                        if messageText.isUserInteractionEnabled == false && !copySession && !forwardSession && !deleteSession && !self.removed {
-                            messageText.isUserInteractionEnabled = true
-                            let longPress = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressLink(_:)))
-                            longPress.minimumPressDuration = 0.1
-                            containerMessage.addGestureRecognizer(longPress)
+                if listText.count > 0 {
+                    for i in 0...listText.count - 1 {
+                        if listText[i].lowercased().checkStartWithLink() {
+                            let rangeTapLink = (textChat as NSString).range(of: String(listText[i]))
+                            // Add tap gesture recognizer to the range of text
+                            let attributedString = textChat.richText()
+                            attributedString.addAttributes([.foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue], range: rangeTapLink)
+                            messageText.attributedText = attributedString
+                            if messageText.isUserInteractionEnabled == false && !copySession && !forwardSession && !deleteSession && !self.removed {
+                                messageText.isUserInteractionEnabled = true
+                                let longPress = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPressLink(_:)))
+                                longPress.minimumPressDuration = 0.1
+                                containerMessage.addGestureRecognizer(longPress)
+                            }
                         }
                     }
                 }

+ 15 - 6
appbuilder-ios/NexilisLite/NexilisLite/Source/View/Control/ContactChatViewController.swift

@@ -982,11 +982,14 @@ extension ContactChatViewController {
                 let text = Utils.previewMessageText(chat: data)
                 let idMe = UserDefaults.standard.string(forKey: "me") as String?
                 if let attributeText = text as? NSMutableAttributedString {
+                    let stringMessage = NSMutableAttributedString(string: "")
                     if data.fpin == idMe {
                         if data.lock == "1" {
-                            messageView.attributedText = ("🚫 _"+"You were deleted this message".localized()+"_").richText()
+                            if data.messageScope == "4" {
+                                stringMessage.append(NSAttributedString(string: "You".localized() + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                            }
+                            stringMessage.append(("🚫 _"+"You were deleted this message".localized()+"_").richText())
                         } else {
-                            let stringMessage = NSMutableAttributedString(string: "")
                             let imageStatus = NSTextAttachment()
                             let status = getRealStatus(messageId: data.messageId)
                             if (status == "1" || status == "2" ) {
@@ -998,20 +1001,26 @@ extension ContactChatViewController {
                             } else {
                                 imageStatus.image = UIImage(named: "double-checklist", in: Bundle.resourceBundle(for: Nexilis.self), with: nil)!.withTintColor(UIColor.systemBlue)
                             }
-                            imageStatus.bounds = CGRect(x: 0, y: 0, width: 15, height: 15)
+                            imageStatus.bounds = CGRect(x: 0, y: -2, width: 15, height: 15)
                             let imageStatusString = NSAttributedString(attachment: imageStatus)
                             stringMessage.append(imageStatusString)
                             stringMessage.append(NSAttributedString(string: " "))
+                            if data.messageScope == "4" {
+                                stringMessage.append(NSAttributedString(string: "You".localized() + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                            }
                             stringMessage.append(attributeText)
-                            messageView.attributedText = stringMessage
                         }
                     } else {
+                        if data.messageScope == "4" {
+                            stringMessage.append(NSAttributedString(string: User.getData(pin: data.fpin)!.firstName + ": ", attributes: [NSAttributedString.Key.font: UIFont.boldSystemFont(ofSize: 12)]))
+                        }
                         if data.lock == "1" {
-                            messageView.attributedText = ("🚫 _"+"This message was deleted".localized()+"_").richText()
+                            stringMessage.append(("🚫 _"+"This message was deleted".localized()+"_").richText())
                         } else {
-                            messageView.attributedText = attributeText
+                            stringMessage.append(attributeText)
                         }
                     }
+                    messageView.attributedText = stringMessage
                 }
                 messageView.numberOfLines = 2