Move over a11y-actions for notifications (IOS-192)

This commit is contained in:
Nathan Mattes 2024-01-24 14:16:04 +01:00
parent 96c4fbfbdb
commit f363316662
2 changed files with 44 additions and 48 deletions

View File

@ -139,8 +139,52 @@ extension NotificationView {
case ._other:
notificationIndicatorText = nil
}
var actions = [UIAccessibilityCustomAction]()
// these notifications can be directly actioned to view the profile
if type != .follow, type != .followRequest {
actions.append(
UIAccessibilityCustomAction(
name: L10n.Common.Controls.Status.showUserProfile,
image: nil
) { [weak self] _ in
guard let self, let delegate = self.delegate else { return false }
delegate.notificationView(self, authorAvatarButtonDidPressed: self.avatarButton)
return true
}
)
}
if type == .followRequest {
actions.append(
UIAccessibilityCustomAction(
name: L10n.Common.Controls.Actions.confirm,
image: Asset.Editing.checkmark20.image
) { [weak self] _ in
guard let self, let delegate = self.delegate else { return false }
delegate.notificationView(self, acceptFollowRequestButtonDidPressed: self.acceptFollowRequestButton)
return true
}
)
actions.append(
UIAccessibilityCustomAction(
name: L10n.Common.Controls.Actions.delete,
image: Asset.Circles.forbidden20.image
) { [weak self] _ in
guard let self, let delegate = self.delegate else { return false }
delegate.notificationView(self, rejectFollowRequestButtonDidPressed: self.rejectFollowRequestButton)
return true
}
)
}
notificationActions = actions
} else {
notificationIndicatorText = nil
notificationActions = []
}
if let notificationIndicatorText {

View File

@ -45,54 +45,6 @@ extension NotificationView.ViewModel {
.assign(to: \.authContext, on: notificationView.quoteStatusView.viewModel)
.store(in: &disposeBag)
}
private func bindAuthor(notificationView: NotificationView) {
$type
.sink { type in
var actions = [UIAccessibilityCustomAction]()
// these notifications can be directly actioned to view the profile
if type != .follow, type != .followRequest {
actions.append(
UIAccessibilityCustomAction(
name: L10n.Common.Controls.Status.showUserProfile,
image: nil
) { [weak notificationView] _ in
guard let notificationView = notificationView, let delegate = notificationView.delegate else { return false }
delegate.notificationView(notificationView, authorAvatarButtonDidPressed: notificationView.avatarButton)
return true
}
)
}
if type == .followRequest {
actions.append(
UIAccessibilityCustomAction(
name: L10n.Common.Controls.Actions.confirm,
image: Asset.Editing.checkmark20.image
) { [weak notificationView] _ in
guard let notificationView = notificationView, let delegate = notificationView.delegate else { return false }
delegate.notificationView(notificationView, acceptFollowRequestButtonDidPressed: notificationView.acceptFollowRequestButton)
return true
}
)
actions.append(
UIAccessibilityCustomAction(
name: L10n.Common.Controls.Actions.delete,
image: Asset.Circles.forbidden20.image
) { [weak notificationView] _ in
guard let notificationView = notificationView, let delegate = notificationView.delegate else { return false }
delegate.notificationView(notificationView, rejectFollowRequestButtonDidPressed: notificationView.rejectFollowRequestButton)
return true
}
)
}
notificationView.notificationActions = actions
}
.store(in: &disposeBag)
}
private func bindFollowRequest(notificationView: NotificationView) {
Publishers.CombineLatest(