Add custom #nostr and #coffeechain hashtags

Changelog-Added: Custom hashtags for #nostr and #coffeechain
This commit is contained in:
William Casarin
2023-04-06 17:09:50 -07:00
parent e9be227009
commit 3d27e49e70
13 changed files with 286 additions and 64 deletions

View File

@@ -218,27 +218,6 @@ func attributed_string_attach_icon(_ astr: inout AttributedString, img: UIImage)
astr.append(wrapped)
}
func hashtag_str(_ htag: String) -> CompatibleText {
var attributedString = AttributedString(stringLiteral: "#\(htag)")
attributedString.link = URL(string: "damus:t:\(htag)")
var text = Text(attributedString)
if htag.lowercased() == "bitcoin" {
attributedString.foregroundColor = Color.orange
if let img = UIImage(named: "bitcoin-hashtag") {
attributedString = attributedString + " "
attributed_string_attach_icon(&attributedString, img: img)
}
let img = Image("bitcoin-hashtag")
text = text.foregroundColor(.orange) + Text(" \(img)")
} else {
attributedString.foregroundColor = DamusColors.purple
}
return CompatibleText(text: text, attributed: attributedString)
}
func url_str(_ url: URL) -> CompatibleText {
var attributedString = AttributedString(stringLiteral: url.absoluteString)
attributedString.link = url