mirror of
https://github.com/mastodon/mastodon-ios.git
synced 2025-02-02 18:36:44 +01:00
Fix large content viewer for DoubleTitleLabelNavigationBarTitleView
This commit is contained in:
parent
2b2a879905
commit
eef98ea70b
@ -53,18 +53,22 @@ extension DoubleTitleLabelNavigationBarTitleView {
|
||||
containerView.addArrangedSubview(subtitleLabel)
|
||||
|
||||
isAccessibilityElement = true
|
||||
showsLargeContentViewer = true
|
||||
addInteraction(UILargeContentViewerInteraction())
|
||||
}
|
||||
|
||||
func update(title: String, subtitle: String?) {
|
||||
titleLabel.configure(content: PlaintextMetaContent(string: title))
|
||||
update(subtitle: subtitle)
|
||||
accessibilityLabel = subtitle.map { "\(title), \($0)" } ?? title
|
||||
largeContentTitle = accessibilityLabel
|
||||
}
|
||||
|
||||
func update(titleMetaContent: MetaContent, subtitle: String?) {
|
||||
titleLabel.configure(content: titleMetaContent)
|
||||
update(subtitle: subtitle)
|
||||
accessibilityLabel = subtitle.map { "\(titleMetaContent.string), \($0)" } ?? titleMetaContent.string
|
||||
accessibilityLabel = subtitle.map { "\(titleLabel.backedString), \($0)" } ?? titleLabel.backedString
|
||||
largeContentTitle = accessibilityLabel
|
||||
}
|
||||
|
||||
func update(subtitle: String?) {
|
||||
|
@ -152,4 +152,18 @@ extension MetaLabel {
|
||||
]
|
||||
}
|
||||
|
||||
public var backedString: String {
|
||||
let string = textStorage.string
|
||||
let nsString = NSMutableString(string: string)
|
||||
textStorage.enumerateAttribute(
|
||||
.attachment,
|
||||
in: NSRange(location: 0, length: textStorage.length),
|
||||
options: [.reverse])
|
||||
{ value, range, _ in
|
||||
guard let attachment = value as? MetaAttachment else { return }
|
||||
nsString.replaceCharacters(in: range, with: attachment.string)
|
||||
}
|
||||
return nsString as String
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user