Hook up delegate

This commit is contained in:
Justin Mazzocchi 2020-09-25 17:57:35 -07:00
parent 5777120f35
commit 745a420c19
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
2 changed files with 26 additions and 0 deletions

View File

@ -27,4 +27,12 @@ public extension AccountViewModel {
var note: NSAttributedString { accountService.account.note.attributed }
var emoji: [Emoji] { accountService.account.emojis }
func urlSelected(_ url: URL) {
eventsSubject.send(
accountService.navigationService.item(url: url)
.map { CollectionItemEvent.navigation($0) }
.setFailureType(to: Error.self)
.eraseToAnyPublisher())
}
}

View File

@ -39,6 +39,23 @@ extension AccountView: UIContentView {
}
}
extension AccountView: UITextViewDelegate {
func textView(
_ textView: UITextView,
shouldInteractWith URL: URL,
in characterRange: NSRange,
interaction: UITextItemInteraction) -> Bool {
switch interaction {
case .invokeDefaultAction:
accountConfiguration.viewModel.urlSelected(URL)
return false
case .preview: return false
case .presentActions: return false
@unknown default: return false
}
}
}
private extension AccountView {
static let spacing: CGFloat = 8
static let stackViewSpacing: CGFloat = 4
@ -67,6 +84,7 @@ private extension AccountView {
accountLabel.textColor = .secondaryLabel
noteTextView.isScrollEnabled = false
noteTextView.backgroundColor = .clear
noteTextView.delegate = self
NSLayoutConstraint.activate([
avatarImageView.widthAnchor.constraint(equalToConstant: Self.avatarDimension),