Browse Source

Add Friend Request Done

alqindiirsyam 4 months ago
parent
commit
0538fb181c

+ 6 - 0
NexilisLite/NexilisLite/Resource/id.lproj/Localizable.strings

@@ -396,3 +396,9 @@
 "Go to Settings" = "Buka Pengaturan";
 "Go to Settings" = "Buka Pengaturan";
 "To stay updated, please enable notification in the Settings." = "Untuk tetap mendapatkan informasi terbaru, harap aktifkan notifikasi di Pengaturan.";
 "To stay updated, please enable notification in the Settings." = "Untuk tetap mendapatkan informasi terbaru, harap aktifkan notifikasi di Pengaturan.";
 "Chat Font Size" = "Ukuran Font Chat";
 "Chat Font Size" = "Ukuran Font Chat";
+"Accept" = "Terima";
+"Decline" = "Tolak";
+"Friend request has been sent" = "Permintaan pertemanan telah dikirim";
+"has requested to be your friend" = "telah meminta untuk menjadi teman kamu";
+"Friend request has been accepted" = "Permintaan pertemanan telah diterima";
+"Friend request has been rejected" = "Permintaan pertemanan telah ditolak";

+ 14 - 2
NexilisLite/NexilisLite/Source/Extension.swift

@@ -334,6 +334,20 @@ extension UIImage {
         }
         }
         return nil
         return nil
     }
     }
+    
+    convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) {
+        UIGraphicsBeginImageContext(size)
+        guard let context = UIGraphicsGetCurrentContext() else { return nil }
+
+        context.setFillColor(color.cgColor)
+        context.fill(CGRect(origin: .zero, size: size))
+
+        let image = UIGraphicsGetImageFromCurrentImageContext()
+        UIGraphicsEndImageContext()
+
+        guard let cgImage = image?.cgImage else { return nil }
+        self.init(cgImage: cgImage)
+    }
 
 
 }
 }
 
 
@@ -442,9 +456,7 @@ extension NSObject {
                 
                 
                 DispatchQueue.main.async {
                 DispatchQueue.main.async {
                     if tableView != nil {
                     if tableView != nil {
-                        tableView!.beginUpdates()
                         tableView!.reloadRows(at: [indexPath!], with: .none)
                         tableView!.reloadRows(at: [indexPath!], with: .none)
-                        tableView!.endUpdates()
                     }
                     }
                 }
                 }
             }
             }

+ 15 - 0
NexilisLite/NexilisLite/Source/Nexilis.swift

@@ -1348,6 +1348,21 @@ public class Nexilis: NSObject {
         }
         }
         let message_id = message.getBody(key : CoreMessage_TMessageKey.MESSAGE_ID, default_value : "")
         let message_id = message.getBody(key : CoreMessage_TMessageKey.MESSAGE_ID, default_value : "")
         guard !message_id.isEmpty else {
         guard !message_id.isEmpty else {
+            if message.getBody(key: CoreMessage_TMessageKey.ATTACHMENT_FLAG) == "61" {
+                let nameReq = message.getBody(key: CoreMessage_TMessageKey.MESSAGE_TEXT)
+                let nameFpin = message.getBody(key: CoreMessage_TMessageKey.F_PIN)
+                var messageExist = false
+                Database.shared.database?.inTransaction({ (fmdb, rollback) in
+                    if let cursor = Database.shared.getRecords(fmdb: fmdb, query: "select message_id from MESSAGE where attachment_flag = '61' and blog_id = '\(nameFpin)'"), cursor.next() {
+                        messageExist = true
+                        cursor.close()
+                    }
+                })
+                if !messageExist {
+                    Nexilis.saveMessageBot(textMessage: "*\(nameReq.trimmingCharacters(in: .whitespaces))*" + " " + "has requested to be your friend", blog_id: nameFpin, attachment_type: "61")
+                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                }
+            }
             return
             return
         }
         }
         let f_pin = message.getBody(key : CoreMessage_TMessageKey.F_PIN, default_value : "")
         let f_pin = message.getBody(key : CoreMessage_TMessageKey.F_PIN, default_value : "")

+ 7 - 3
NexilisLite/NexilisLite/Source/Utils.swift

@@ -415,6 +415,10 @@ public final class Utils {
             return showNSMutableAttributedString("Confidential Message".localized())
             return showNSMutableAttributedString("Confidential Message".localized())
         } else if chat.attachmentFlag == "27" {
         } else if chat.attachmentFlag == "27" {
             return showNSMutableAttributedString(("📄 " + "Live Streaming".localized()))
             return showNSMutableAttributedString(("📄 " + "Live Streaming".localized()))
+        } else if chat.attachmentFlag == "61" {
+            let textName = chat.messageText.components(separatedBy: " ")[0]
+            let textAfterName = chat.messageText.components(separatedBy: "* ")[1]
+            return (textName + " " + textAfterName.localized()).richText(group_id: chat.pin)
         } else if chat.attachmentFlag == "26" {
         } else if chat.attachmentFlag == "26" {
             return showNSMutableAttributedString(("📄 " + "Seminar".localized()))
             return showNSMutableAttributedString(("📄 " + "Seminar".localized()))
         } else if chat.attachmentFlag == "25" {
         } else if chat.attachmentFlag == "25" {
@@ -422,21 +426,21 @@ public final class Utils {
         } else if !chat.audio.isEmpty {
         } else if !chat.audio.isEmpty {
             return showNSMutableAttributedString(("♫ " + "Audio".localized()))
             return showNSMutableAttributedString(("♫ " + "Audio".localized()))
         } else if !chat.image.isEmpty {
         } else if !chat.image.isEmpty {
-            if !chat.messageText.isEmpty {
+            if !chat.messageText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
                 return "📷 \(chat.messageText)".richText(group_id: chat.pin)
                 return "📷 \(chat.messageText)".richText(group_id: chat.pin)
             } else {
             } else {
                 return showNSMutableAttributedString(("📷 " + "Photo".localized()))
                 return showNSMutableAttributedString(("📷 " + "Photo".localized()))
             }
             }
         }
         }
         else if !chat.gif.isEmpty {
         else if !chat.gif.isEmpty {
-            if !chat.messageText.isEmpty {
+            if !chat.messageText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
                 return "🎬 \(chat.messageText)".richText(group_id: chat.pin)
                 return "🎬 \(chat.messageText)".richText(group_id: chat.pin)
             } else {
             } else {
                 return showNSMutableAttributedString("🎬 GIF")
                 return showNSMutableAttributedString("🎬 GIF")
             }
             }
         }
         }
         else if !chat.video.isEmpty {
         else if !chat.video.isEmpty {
-            if !chat.messageText.isEmpty {
+            if !chat.messageText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
                 return "📹 \(chat.messageText)".richText(group_id: chat.pin)
                 return "📹 \(chat.messageText)".richText(group_id: chat.pin)
             } else {
             } else {
                 return showNSMutableAttributedString(("📹 " + "Video".localized()))
                 return showNSMutableAttributedString(("📹 " + "Video".localized()))

+ 4 - 4
NexilisLite/NexilisLite/Source/View/Chat/EditorGroup.swift

@@ -4230,12 +4230,12 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource, AVAudioPlayer
         containerView.addSubview(dateView)
         containerView.addSubview(dateView)
         dateView.translatesAutoresizingMaskIntoConstraints = false
         dateView.translatesAutoresizingMaskIntoConstraints = false
         var topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor)
         var topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor)
-        topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 20.0)
+        topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 10.0)
         NSLayoutConstraint.activate([
         NSLayoutConstraint.activate([
             topAnchor,
             topAnchor,
-            dateView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -20.0),
+            dateView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -10.0),
             dateView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
             dateView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
-            dateView.heightAnchor.constraint(equalToConstant: 30),
+//            dateView.heightAnchor.constraint(equalToConstant: 30),
             dateView.widthAnchor.constraint(greaterThanOrEqualToConstant: 60)
             dateView.widthAnchor.constraint(greaterThanOrEqualToConstant: 60)
         ])
         ])
         dateView.backgroundColor = .orangeColor
         dateView.backgroundColor = .orangeColor
@@ -4262,7 +4262,7 @@ extension EditorGroup: UITableViewDelegate, UITableViewDataSource, AVAudioPlayer
         if tableView == tableMention {
         if tableView == tableMention {
             return 0
             return 0
         }
         }
-        return 80
+        return 50
     }
     }
     
     
     public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
     public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

+ 120 - 6
NexilisLite/NexilisLite/Source/View/Chat/EditorPersonal.swift

@@ -15,6 +15,7 @@ import nuSDKService
 import SwiftLinkPreview
 import SwiftLinkPreview
 import SDWebImage
 import SDWebImage
 import PhotosUI
 import PhotosUI
+import ObjectiveC
 
 
 public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestureRecognizerDelegate, CLLocationManagerDelegate {
 public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestureRecognizerDelegate, CLLocationManagerDelegate {
     @IBOutlet var wallpaperView: UIImageView!
     @IBOutlet var wallpaperView: UIImageView!
@@ -2763,6 +2764,65 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
 //        }
 //        }
     }
     }
     
     
+    @objc func addFriendReqAction(sender: UIButton) {
+        if !CheckConnection.isConnectedToNetwork()  || API.nGetCLXConnState() == 0 {
+            let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+            imageView.tintColor = .white
+            let banner = FloatingNotificationBanner(title: "Check your connection".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+            banner.show()
+            return
+        }
+        Nexilis.showLoader()
+        let lPin = sender.restorationIdentifier?.components(separatedBy: ",")[0]
+        let messageId = sender.restorationIdentifier?.components(separatedBy: ",")[1]
+        let isAccept = (sender.tag == 0)
+        DispatchQueue.global().async {
+            if let response = Nexilis.writeSync(message: CoreMessage_TMessageBank.getAddFriendApproval(lPin: lPin ?? "", isAccept: isAccept), timeout: 5 * 1000) {
+                if response.isOk() {
+                    self.deleteMessage(l_pin: User.getMyPin() ?? "", message_id: messageId ?? "", scope: "3", type: "1", chat: "")
+                    let idx = self.dataMessages.firstIndex(where: { $0["message_id"] as? String == messageId})
+                    if idx != nil {
+                        self.dataMessages.remove(at: idx!)
+                        if (idx == self.dataMessages.count - 1) {
+                            NotificationCenter.default.post(name: NSNotification.Name(rawValue: "reloadTabChats"), object: nil, userInfo: nil)
+                        }
+                        for i in 0..<self.dataDates.count {
+                            if self.dataMessages.filter({ $0["chat_date"]  as? String ?? "" == self.dataDates[i] }).count == 0 {
+                                self.dataDates.remove(at: i)
+                            }
+                        }
+                    }
+                    DispatchQueue.main.async {
+                        Nexilis.hideLoader {
+                            if self.dataMessages.count == 0 {
+                                if self.fromNotification {
+                                    self.didTapExit()
+                                } else {
+                                    self.navigationController?.popViewController(animated: true)
+                                }
+                                UIApplication.shared.visibleViewController?.view.makeToast(sender.tag == 0 ? "Friend request has been accepted".localized() : "Friend request has been rejected".localized(), duration: 3)
+                            }
+                        }
+                    }
+                } else {
+                    Nexilis.hideLoader {
+                        let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                        imageView.tintColor = .white
+                        let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                        banner.show()
+                    }
+                }
+            } else {
+                Nexilis.hideLoader {
+                    let imageView = UIImageView(image: UIImage(systemName: "xmark.circle.fill"))
+                    imageView.tintColor = .white
+                    let banner = FloatingNotificationBanner(title: "Unable to access servers. Try again later".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .danger, colors: nil, iconPosition: .center)
+                    banner.show()
+                }
+            }
+        }
+    }
+    
     @objc func ccAction(sender: UIButton) {
     @objc func ccAction(sender: UIButton) {
         if self.nowSelectedCategoryCC == "CantReturn" {
         if self.nowSelectedCategoryCC == "CantReturn" {
             if sender.tag == 503 {
             if sender.tag == 503 {
@@ -5407,12 +5467,12 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource, AVAudioPla
         containerView.addSubview(dateView)
         containerView.addSubview(dateView)
         dateView.translatesAutoresizingMaskIntoConstraints = false
         dateView.translatesAutoresizingMaskIntoConstraints = false
         var topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor)
         var topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor)
-        topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 20.0)
+        topAnchor = dateView.topAnchor.constraint(equalTo: containerView.topAnchor, constant: 10.0)
         NSLayoutConstraint.activate([
         NSLayoutConstraint.activate([
             topAnchor,
             topAnchor,
-            dateView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -20.0),
+            dateView.bottomAnchor.constraint(equalTo: containerView.bottomAnchor, constant: -10.0),
             dateView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
             dateView.centerXAnchor.constraint(equalTo: containerView.centerXAnchor),
-            dateView.heightAnchor.constraint(equalToConstant: 30),
+//            dateView.heightAnchor.constraint(equalToConstant: 30),
             dateView.widthAnchor.constraint(greaterThanOrEqualToConstant: 60)
             dateView.widthAnchor.constraint(greaterThanOrEqualToConstant: 60)
         ])
         ])
         dateView.backgroundColor = .orangeColor
         dateView.backgroundColor = .orangeColor
@@ -5442,7 +5502,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource, AVAudioPla
     }
     }
     
     
     public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
     public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
-        return 80
+        return 50
     }
     }
     
     
     public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
@@ -5967,6 +6027,8 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource, AVAudioPla
         let topMarginText = messageText.topAnchor.constraint(equalTo: containerMessage.topAnchor, constant: 15)
         let topMarginText = messageText.topAnchor.constraint(equalTo: containerMessage.topAnchor, constant: 15)
         messageText.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
         messageText.textColor = self.traitCollection.userInterfaceStyle == .dark ? .white : .black
         messageText.font = .systemFont(ofSize: 12 + offset())
         messageText.font = .systemFont(ofSize: 12 + offset())
+        var textChat = (dataMessages[indexPath.row]["message_text"] as? String) ?? ""
+        var messageRequestFriend: String!
         if dataMessages[indexPath.row]["attachment_flag"] as? String == "27" || dataMessages[indexPath.row]["attachment_flag"] as? String == "26" ||
         if dataMessages[indexPath.row]["attachment_flag"] as? String == "27" || dataMessages[indexPath.row]["attachment_flag"] as? String == "26" ||
             dataMessages[indexPath.row]["attachment_flag"] as? String == "25" || dataMessages[indexPath.row]["message_scope_id"] as? String == "18" {
             dataMessages[indexPath.row]["attachment_flag"] as? String == "25" || dataMessages[indexPath.row]["message_scope_id"] as? String == "18" {
             messageText.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 85).isActive = true
             messageText.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 85).isActive = true
@@ -6006,11 +6068,59 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource, AVAudioPla
                 imageQR.heightAnchor.constraint(equalToConstant: 100.0)
                 imageQR.heightAnchor.constraint(equalToConstant: 100.0)
             ])
             ])
             imageQR.image = generateQRCode(from: dataMessages[indexPath.row]["blog_id"]  as? String ?? "")
             imageQR.image = generateQRCode(from: dataMessages[indexPath.row]["blog_id"]  as? String ?? "")
+        } else if dataMessages[indexPath.row]["attachment_flag"] as? String == "61" {
+            messageText.bottomAnchor.constraint(equalTo: containerMessage.bottomAnchor, constant: -50).isActive = true
+            let fPinFriend = dataMessages[indexPath.row]["blog_id"]  as? String ?? ""
+            
+            let buttonAccept = UIButton(type: .custom)
+            buttonAccept.setTitle("Accept".localized(), for: .normal)
+            buttonAccept.setBackgroundImage(UIImage(color: UIColor.clear), for: .normal)
+            buttonAccept.setBackgroundImage(UIImage(color: UIColor.blueBubbleColor), for: .highlighted)
+            buttonAccept.setTitleColor(.black, for: .normal)
+            buttonAccept.titleLabel?.font = UIFont.systemFont(ofSize: 12)
+            buttonAccept.layer.borderWidth = 2.0
+            buttonAccept.layer.borderColor = UIColor.blueBubbleColor.cgColor
+            buttonAccept.layer.cornerRadius = 8.0
+            buttonAccept.tag = 0
+            buttonAccept.restorationIdentifier = "\(fPinFriend),\(messageIdChat)"
+            buttonAccept.clipsToBounds = true
+            containerMessage.addSubview(buttonAccept)
+            buttonAccept.translatesAutoresizingMaskIntoConstraints = false
+            
+            buttonAccept.leadingAnchor.constraint(equalTo: containerMessage.leadingAnchor, constant: 15).isActive = true
+            buttonAccept.topAnchor.constraint(equalTo: messageText.bottomAnchor, constant: 5).isActive = true
+            buttonAccept.widthAnchor.constraint(equalToConstant: self.view!.frame.size.width/5).isActive = true
+            buttonAccept.heightAnchor.constraint(equalToConstant: 30).isActive = true
+            buttonAccept.addTarget(self, action: #selector(addFriendReqAction), for: .touchUpInside)
+            
+            let buttonDecline = UIButton(type: .custom)
+            buttonDecline.setTitle("Decline".localized(), for: .normal)
+            buttonDecline.setBackgroundImage(UIImage(color: UIColor.clear), for: .normal)
+            buttonDecline.setBackgroundImage(UIImage(color: UIColor.blueBubbleColor), for: .highlighted)
+            buttonDecline.setTitleColor(.black, for: .normal)
+            buttonDecline.titleLabel?.font = UIFont.systemFont(ofSize: 12)
+            buttonDecline.layer.borderWidth = 2.0
+            buttonDecline.tag = 1
+            buttonDecline.restorationIdentifier = "\(fPinFriend),\(messageIdChat)"
+            buttonDecline.layer.borderColor = UIColor.blueBubbleColor.cgColor
+            buttonDecline.layer.cornerRadius = 8.0
+            buttonDecline.clipsToBounds = true
+            containerMessage.addSubview(buttonDecline)
+            buttonDecline.translatesAutoresizingMaskIntoConstraints = false
+            
+            buttonDecline.leadingAnchor.constraint(equalTo: buttonAccept.trailingAnchor, constant: 10).isActive = true
+            buttonDecline.topAnchor.constraint(equalTo: messageText.bottomAnchor, constant: 5).isActive = true
+            buttonDecline.widthAnchor.constraint(equalToConstant: self.view!.frame.size.width/5).isActive = true
+            buttonDecline.heightAnchor.constraint(equalToConstant: 30).isActive = true
+            buttonDecline.addTarget(self, action: #selector(addFriendReqAction), for: .touchUpInside)
+            
+            let textName = textChat.components(separatedBy: " ")[0]
+            let textAfterName = textChat.components(separatedBy: "* ")[1]
+            messageRequestFriend = textName + " " + textAfterName.localized()
         } else {
         } else {
             messageText.bottomAnchor.constraint(equalTo: containerMessage.bottomAnchor, constant: -15).isActive = true
             messageText.bottomAnchor.constraint(equalTo: containerMessage.bottomAnchor, constant: -15).isActive = true
         }
         }
         messageText.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
         messageText.trailingAnchor.constraint(equalTo: containerMessage.trailingAnchor, constant: -15).isActive = true
-        var textChat = (dataMessages[indexPath.row]["message_text"] as? String) ?? ""
         let originalMessageText = textChat
         let originalMessageText = textChat
         if (dataMessages[indexPath.row]["lock"] != nil && (dataMessages[indexPath.row]["lock"])! as? String == "1") {
         if (dataMessages[indexPath.row]["lock"] != nil && (dataMessages[indexPath.row]["lock"])! as? String == "1") {
             if (dataMessages[indexPath.row]["f_pin"] as? String == idMe) {
             if (dataMessages[indexPath.row]["f_pin"] as? String == idMe) {
@@ -6071,6 +6181,10 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource, AVAudioPla
                     messageText.isUserInteractionEnabled = false
                     messageText.isUserInteractionEnabled = false
                 }
                 }
             }
             }
+            else if attachmentFlag == "61" {
+                messageText.attributedText = messageRequestFriend.richText()
+                messageText.isUserInteractionEnabled = false
+            }
             else if attachmentFlag == "11" && dataMessages[indexPath.row]["lock"]  as? String ?? "" != "1" && dataMessages[indexPath.row]["lock"] as? String != "2" {
             else if attachmentFlag == "11" && dataMessages[indexPath.row]["lock"]  as? String ?? "" != "1" && dataMessages[indexPath.row]["lock"] as? String != "2" {
                 messageText.text = ""
                 messageText.text = ""
                 topMarginText.constant = topMarginText.constant + 100
                 topMarginText.constant = topMarginText.constant + 100
@@ -6149,7 +6263,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource, AVAudioPla
         }
         }
         
         
         if isSearching && textSearch.count > 1 {
         if isSearching && textSearch.count > 1 {
-            messageText.attributedText = stringLS.isEmpty ? textChat.richText(isSearching: true, textSearch: textSearch) : stringLS.richText(isSearching: true, textSearch: textSearch)
+            messageText.attributedText = messageRequestFriend != nil ? messageRequestFriend.richText(isSearching: true, textSearch: textSearch) : stringLS.isEmpty ? textChat.richText(isSearching: true, textSearch: textSearch) : stringLS.richText(isSearching: true, textSearch: textSearch)
         }
         }
         
         
         let stringDate = (dataMessages[indexPath.row]["server_date"] as? String) ?? ""
         let stringDate = (dataMessages[indexPath.row]["server_date"] as? String) ?? ""

+ 6 - 2
NexilisLite/NexilisLite/Source/View/Control/AddFriendTableViewController.swift

@@ -103,13 +103,17 @@ class AddFriendTableViewController: UITableViewController {
             
             
             
             
             DispatchQueue.main.async {
             DispatchQueue.main.async {
-                if let response = Nexilis.writeAndWait(message: CoreMessage_TMessageBank.getAddFriendQRCode(fpin: qrCode), timeout: 1000 * 30) {
+                var dataMessage = CoreMessage_TMessageBank.getAddFriendQRCode(fpin: qrCode)
+                if Nexilis.checkingAccess(key: "friend_request_approval"){
+                    dataMessage = CoreMessage_TMessageBank.getAddFriendRequest(fPin: qrCode)
+                }
+                if let response = Nexilis.writeAndWait(message: dataMessage, timeout: 1000 * 30) {
                     print(response.toLogString())
                     print(response.toLogString())
                     isQR = true
                     isQR = true
                 }
                 }
                 
                 
                 if isQR {
                 if isQR {
-                    let alert = UIAlertController(title: "Action Successful".localized(), message: "Successfully added a new friend".localized(), preferredStyle: .alert)
+                    let alert = UIAlertController(title: "Action Successful".localized(), message: Nexilis.checkingAccess(key: "friend_request_approval") ? "Friend request has been sent".localized() : "Successfully added a new friend".localized(), preferredStyle: .alert)
                     alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                     alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
                     self.present(alert, animated: true, completion: nil)
                     self.present(alert, animated: true, completion: nil)
                 }
                 }

+ 6 - 2
NexilisLite/NexilisLite/Source/View/Control/GroupDetailViewController.swift

@@ -688,7 +688,7 @@ class GroupDetailViewController: UITableViewController {
                     if result {
                     if result {
                         let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
                         let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
                         imageView.tintColor = .white
                         imageView.tintColor = .white
-                        let banner = FloatingNotificationBanner(title: "Successfully add friend".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
+                        let banner = FloatingNotificationBanner(title: Nexilis.checkingAccess(key: "friend_request_approval") ? "Friend request has been sent".localized() : "Successfully add friend".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
                         banner.show()
                         banner.show()
                         self.reload()
                         self.reload()
                     } else {
                     } else {
@@ -708,7 +708,11 @@ class GroupDetailViewController: UITableViewController {
                 completion(false)
                 completion(false)
                 return
                 return
             }
             }
-            if let response = Nexilis.writeAndWait(message: CoreMessage_TMessageBank.getAddFriendQRCode(fpin: pin)), response.isOk() {
+            var dataMessage = CoreMessage_TMessageBank.getAddFriendQRCode(fpin: pin)
+            if Nexilis.checkingAccess(key: "friend_request_approval"){
+                dataMessage = CoreMessage_TMessageBank.getAddFriendRequest(fPin: pin)
+            }
+            if let response = Nexilis.writeAndWait(message: dataMessage), response.isOk() {
                 completion(true)
                 completion(true)
             } else {
             } else {
                 completion(false)
                 completion(false)

+ 6 - 2
NexilisLite/NexilisLite/Source/View/Control/ProfileViewController.swift

@@ -575,7 +575,11 @@ public class ProfileViewController: UITableViewController, UITextFieldDelegate {
                 completion(false)
                 completion(false)
                 return
                 return
             }
             }
-            if let response = Nexilis.writeAndWait(message: CoreMessage_TMessageBank.getAddFriendQRCode(fpin: self.data)), response.isOk() {
+            var dataMessage = CoreMessage_TMessageBank.getAddFriendQRCode(fpin: self.data)
+            if Nexilis.checkingAccess(key: "friend_request_approval"){
+                dataMessage = CoreMessage_TMessageBank.getAddFriendRequest(fPin: self.data)
+            }
+            if let response = Nexilis.writeAndWait(message: dataMessage), response.isOk() {
                 completion(true)
                 completion(true)
             } else {
             } else {
                 completion(false)
                 completion(false)
@@ -705,7 +709,7 @@ public class ProfileViewController: UITableViewController, UITextFieldDelegate {
                         let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
                         let imageView = UIImageView(image: UIImage(systemName: "checkmark.circle.fill"))
                         imageView.tintColor = .white
                         imageView.tintColor = .white
                         publicBanner.dismiss()
                         publicBanner.dismiss()
-                        publicBanner = FloatingNotificationBanner(title: "Successfully add friend".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
+                        publicBanner = FloatingNotificationBanner(title: Nexilis.checkingAccess(key: "friend_request_approval") ? "Friend request has been sent".localized() : "Successfully add friend".localized(), subtitle: nil, titleFont: UIFont.systemFont(ofSize: 16), titleColor: nil, titleTextAlign: .left, subtitleFont: nil, subtitleColor: nil, subtitleTextAlign: nil, leftView: imageView, rightView: nil, style: .success, colors: nil, iconPosition: .center)
                         publicBanner.show()
                         publicBanner.show()
                         self.isDismiss?()
                         self.isDismiss?()
                         self.navigationController?.popViewController(animated: true)
                         self.navigationController?.popViewController(animated: true)