From b4c21417d43bf66e6db301d6359e81022e4c00c1 Mon Sep 17 00:00:00 2001 From: ned Date: Mon, 18 Nov 2019 18:23:16 +0100 Subject: [PATCH] fix link not clickable in news (drop support for tags for now) see https://github.com/psharanda/Atributika/issues/54 --- appdb/Tabs/Settings/News/News+Detail.swift | 24 +++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/appdb/Tabs/Settings/News/News+Detail.swift b/appdb/Tabs/Settings/News/News+Detail.swift index fea8da85..686f1fcd 100644 --- a/appdb/Tabs/Settings/News/News+Detail.swift +++ b/appdb/Tabs/Settings/News/News+Detail.swift @@ -167,27 +167,31 @@ extension AttributedLabel { let link = Style("a").foregroundColor(UIColor(rgba: "#446CB3"), .normal).foregroundColor(UIColor(rgba: "#486A92"), .highlighted) .underlineStyle(.single) + // TODO: add support for showing images in tags. Currently there's a way but it screws up detections + // See https://github.com/psharanda/Atributika/issues/54 + // Supports - let img = Style("img") + //let img = Style("img") // Close tag manually (otherwise it's not detected) - var newText = text - if text.contains("")[0] - newText = text.replacingOccurrences(of: tmp + ">", with: tmp + ">") - } + //var newText = text + //if text.contains("")[0] + // newText = text.replacingOccurrences(of: tmp + ">", with: tmp + ">") + //} // Apply styles - let str = newText.style(tags: [b, i, strong, u, img, link], transformers: transformers) + let str = text.style(tags: [b, i, strong, u,/* img,*/ link], transformers: transformers).styleLinks(link) // Create NSMutableAttributedString - let mutableAttrStr = NSMutableAttributedString(attributedString: str.attributedString) + //let mutableAttrStr = NSMutableAttributedString(attributedString: str.attributedString) // Insert image if tag is found - addImageSupport(mutableAttrStr: mutableAttrStr, detections: str.detections) + //addImageSupport(mutableAttrStr: mutableAttrStr, detections: str.detections) // Update text - attributedText = mutableAttrStr.styleLinks(link) + //attributedText = mutableAttrStr.styleLinks(link) + attributedText = str // Click on url detection onClick = { label, detection in