|
@@ -98,7 +98,7 @@ public class EditorPersonal: UIViewController, ImageVideoPickerDelegate, UIGestu
|
|
|
var timerLongPressLink: Timer?
|
|
|
var timerFakeProgress: Timer?
|
|
|
var lastTouchPoint: CGPoint = .zero
|
|
|
- var isLinkCopied = false
|
|
|
+ var showMenuContext = false
|
|
|
var touchedSubview = UIView()
|
|
|
var listViewOnSection: [UIView] = []
|
|
|
var fromVCAC = false
|
|
@@ -3392,8 +3392,8 @@ extension EditorPersonal: UITextViewDelegate {
|
|
|
//EUC
|
|
|
extension EditorPersonal: UIContextMenuInteractionDelegate {
|
|
|
public func contextMenuInteraction(_ interaction: UIContextMenuInteraction, willEndFor configuration: UIContextMenuConfiguration, animator: UIContextMenuInteractionAnimating?) {
|
|
|
- if isLinkCopied {
|
|
|
- isLinkCopied = false
|
|
|
+ if showMenuContext {
|
|
|
+ showMenuContext = false
|
|
|
interaction.view!.removeInteraction(interaction)
|
|
|
}
|
|
|
}
|
|
@@ -4898,18 +4898,19 @@ 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 attributedString = textChat.richText()
|
|
|
+ let rangeTapLink = (attributedString.string as NSString).range(of: String(listText[i]))
|
|
|
+ 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)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -4980,7 +4981,16 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
|
let paths = NSSearchPathForDirectoriesInDomains(nsDocumentDirectory, nsUserDomainMask, true)
|
|
|
if let dirPath = paths.first {
|
|
|
let thumbURL = URL(fileURLWithPath: dirPath).appendingPathComponent(listImages[i].thumbId)
|
|
|
- let image = UIImage(contentsOfFile: thumbURL.path)?.resize(target: CGSize(width: 500, height: 500))
|
|
|
+ let image : UIImage? = {
|
|
|
+ if let img = DigiX.imageCache.object(forKey: listImages[i].thumbId as NSString) {
|
|
|
+ return img
|
|
|
+ }
|
|
|
+ else if let img = UIImage(contentsOfFile: thumbURL.path)?.resize(target: CGSize(width: 500, height: 500)) {
|
|
|
+ DigiX.imageCache.setObject(img, forKey: listImages[i].thumbId as NSString)
|
|
|
+ return img
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+ }()
|
|
|
// let image = UIGraphicsRenderer.renderImageAt(url: thumbURL as NSURL, size: CGSize(width: 250, height: 250))
|
|
|
listImageThumb[i].image = image
|
|
|
|
|
@@ -5305,7 +5315,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
|
let imageUrl = data["imageUrl"] as? String
|
|
|
let link = data["link"] as! String
|
|
|
|
|
|
- topMarginText.constant = topMarginText.constant + 80
|
|
|
+ topMarginText.constant = topMarginText.constant + 85
|
|
|
|
|
|
containerMessage.addSubview(containerLinkMessage)
|
|
|
containerLinkMessage.translatesAutoresizingMaskIntoConstraints = false
|
|
@@ -5332,7 +5342,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
|
} else {
|
|
|
imagePreview.loadImageAsync(with: imageUrl)
|
|
|
}
|
|
|
- imagePreview.contentMode = .scaleAspectFit
|
|
|
+ imagePreview.contentMode = .scaleToFill
|
|
|
}
|
|
|
|
|
|
let titlePreview = UILabel()
|
|
@@ -6048,7 +6058,7 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
|
let impactHeavy = UIImpactFeedbackGenerator(style: .heavy)
|
|
|
impactHeavy.impactOccurred()
|
|
|
interaction.perform(selector, with: self.view)
|
|
|
- self.isLinkCopied = true
|
|
|
+ self.showMenuContext = true
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -6065,9 +6075,9 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
|
if let text = label.text, let range = getWordRange(at: touchPointLabel, in: label) {
|
|
|
let word = String(text[range])
|
|
|
if word.starts(with: "www.") || word.starts(with: "https://") || word.starts(with: "http://") {
|
|
|
- if gestureRecognizer.state == .cancelled || gestureRecognizer.state == .ended{
|
|
|
+ if gestureRecognizer.state == .cancelled || gestureRecognizer.state == .ended {
|
|
|
timerCheckLink?.invalidate()
|
|
|
- if !isLinkCopied {
|
|
|
+ if label.isHighlighted {
|
|
|
var stringURl = word
|
|
|
if stringURl.starts(with: "www.") {
|
|
|
stringURl = "https://" + stringURl.replacingOccurrences(of: "www.", with: "")
|
|
@@ -6076,11 +6086,9 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
|
UIApplication.shared.open(url)
|
|
|
label.attributedText = removeHighlightedText(for: text, in: range, label: label)
|
|
|
}
|
|
|
- isLinkCopied = false
|
|
|
} else if gestureRecognizer.state == .began {
|
|
|
label.attributedText = highlightedText(for: text, in: range, label: label)
|
|
|
timerCheckLink = Timer.scheduledTimer(withTimeInterval: 0.5, repeats: false, block: {_ in
|
|
|
- self.isLinkCopied = true
|
|
|
UIPasteboard.general.string = word
|
|
|
self.showToast(message: "Link Copied".localized(), font: UIFont.systemFont(ofSize: 12, weight: .medium), controller: self)
|
|
|
label.attributedText = self.removeHighlightedText(for: text, in: range, label: label)
|
|
@@ -6128,12 +6136,14 @@ extension EditorPersonal: UITableViewDelegate, UITableViewDataSource {
|
|
|
func highlightedText(for text: String, in range: Range<String.Index>, label: UILabel) -> NSAttributedString {
|
|
|
let mutableAttributedString = label.attributedText!.mutableCopy() as! NSMutableAttributedString
|
|
|
mutableAttributedString.addAttribute(.backgroundColor, value: UIColor.lightGray.withAlphaComponent(0.5), range: NSRange(range, in: text))
|
|
|
+ label.isHighlighted = true
|
|
|
return mutableAttributedString
|
|
|
}
|
|
|
|
|
|
func removeHighlightedText(for text: String, in range: Range<String.Index>, label: UILabel) -> NSAttributedString {
|
|
|
let mutableAttributedString = label.attributedText!.mutableCopy() as! NSMutableAttributedString
|
|
|
mutableAttributedString.removeAttribute(.backgroundColor, range: NSRange(range, in: text))
|
|
|
+ label.isHighlighted = false
|
|
|
return mutableAttributedString
|
|
|
}
|
|
|
|
|
@@ -6540,3 +6550,4 @@ public class ImageGrouping {
|
|
|
self.dataTopic = dataTopic
|
|
|
}
|
|
|
}
|
|
|
+
|