Show custom emoji in profile field names

This commit is contained in:
Shadowfacts 2020-08-16 15:05:58 -04:00
parent 722b81dad9
commit 1cd3e6adf9
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 4 additions and 1 deletions

View File

@ -24,6 +24,8 @@ class EmojiLabel: UILabel {
emojiRequests = [] emojiRequests = []
let matches = emojiRegex.matches(in: attributedText.string, options: [], range: attributedText.fullRange) let matches = emojiRegex.matches(in: attributedText.string, options: [], range: attributedText.fullRange)
guard !matches.isEmpty else { return }
let emojiImages = CachedDictionary<UIImage>(name: "EmojiLabel Emoji Images") let emojiImages = CachedDictionary<UIImage>(name: "EmojiLabel Emoji Images")
let group = DispatchGroup() let group = DispatchGroup()

View File

@ -133,13 +133,14 @@ class ProfileHeaderView: UIView {
fieldNamesStackView.arrangedSubviews.forEach { $0.removeFromSuperview() } fieldNamesStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
fieldValuesStackView.arrangedSubviews.forEach { $0.removeFromSuperview() } fieldValuesStackView.arrangedSubviews.forEach { $0.removeFromSuperview() }
for field in account.fields { for field in account.fields {
let nameLabel = UILabel() let nameLabel = EmojiLabel()
nameLabel.text = field.name nameLabel.text = field.name
nameLabel.font = .boldSystemFont(ofSize: 17) nameLabel.font = .boldSystemFont(ofSize: 17)
nameLabel.textAlignment = .right nameLabel.textAlignment = .right
nameLabel.numberOfLines = 0 nameLabel.numberOfLines = 0
nameLabel.lineBreakMode = .byWordWrapping nameLabel.lineBreakMode = .byWordWrapping
nameLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal) nameLabel.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
nameLabel.setEmojis(account.emojis, identifier: "")
fieldNamesStackView.addArrangedSubview(nameLabel) fieldNamesStackView.addArrangedSubview(nameLabel)
let valueTextView = ContentTextView() let valueTextView = ContentTextView()