diff --git a/Mastodon/Scene/Discovery/ForYou/ProfileCardView+ViewModel.swift b/Mastodon/Scene/Discovery/ForYou/ProfileCardView+ViewModel.swift index b9ce95d35..8f830b47a 100644 --- a/Mastodon/Scene/Discovery/ForYou/ProfileCardView+ViewModel.swift +++ b/Mastodon/Scene/Discovery/ForYou/ProfileCardView+ViewModel.swift @@ -54,7 +54,7 @@ extension ProfileCardView.ViewModel { bindRelationship(view: view) bindDashboard(view: view) bindFamiliarFollowers(view: view) -// bindAccessibility(view: view) + bindAccessibility(view: view) } private func bindHeader(view: ProfileCardView) { @@ -177,73 +177,69 @@ extension ProfileCardView.ViewModel { view.familiarFollowersDashboardView.configure(familiarFollowers: familiarFollowers) } .store(in: &disposeBag) -// $backgroundColor -// .assign(to: \.backgroundColor, on: view.familiarFollowersDashboardView.viewModel) -// .store(in: &disposeBag) } - -// private func bindAccessibility(view: ProfileCardView) { -// let authorAccessibilityLabel = Publishers.CombineLatest( -// $authorName, -// $bioContent -// ) -// .map { authorName, bioContent -> String? in -// var strings: [String?] = [] -// strings.append(authorName?.string) -// strings.append(bioContent?.string) -// return strings.compactMap { $0 }.joined(separator: ", ") -// } -// -// authorAccessibilityLabel -// .map { $0 ?? "" } -// .assign(to: &$groupedAccessibilityLabel) -// -// $groupedAccessibilityLabel -// .sink { accessibilityLabel in -// view.accessibilityLabel = accessibilityLabel -// } -// .store(in: &disposeBag) -// -// let statusesContent = $statusesCount -// .removeDuplicates() -// .map { -// AXCustomContent( -// label: L10n.Scene.Profile.Dashboard.otherPosts, -// value: "\($0.)" -// ) -// } -// let followingContent = $followingCount -// .removeDuplicates() -// .map { -// AXCustomContent( -// label: L10n.Scene.Profile.Dashboard.otherFollowing, -// value: $0 -// ) -// } -// let followersContent = $followersCount -// .removeDuplicates() -// .map { -// AXCustomContent( -// label: L10n.Scene.Profile.Dashboard.otherFollowers, -// value: $0 -// ) -// } -// let familiarContent = view.familiarFollowersDashboardView.viewModel.$label -// .map { $0?.accessibilityLabel } -// .removeDuplicates() -// .map { -// AXCustomContent( -// label: L10n.Scene.Profile.Dashboard.familiarFollowers, -// value: $0 -// ) -// } -// Publishers.CombineLatest4( -// statusesContent, -// followingContent, -// followersContent, -// familiarContent -// ).sink { statuses, following, followers, familiar in -// view.accessibilityCustomContent = [statuses, following, followers, familiar].compactMap { $0 } -// }.store(in: &disposeBag) -// } + private func bindAccessibility(view: ProfileCardView) { + let authorAccessibilityLabel = Publishers.CombineLatest( + $authorName, + $bioContent + ) + .map { authorName, bioContent -> String? in + var strings: [String?] = [] + strings.append(authorName?.string) + strings.append(bioContent?.string) + return strings.compactMap { $0 }.joined(separator: ", ") + } + + authorAccessibilityLabel + .map { $0 ?? "" } + .assign(to: &$groupedAccessibilityLabel) + + $groupedAccessibilityLabel + .sink { accessibilityLabel in + view.accessibilityLabel = accessibilityLabel + } + .store(in: &disposeBag) + + let statusesContent = $statusesCount + .removeDuplicates() + .map { + AXCustomContent( + label: L10n.Scene.Profile.Dashboard.otherPosts, + value: String(describing: $0) + ) + } + let followingContent = $followingCount + .removeDuplicates() + .map { + AXCustomContent( + label: L10n.Scene.Profile.Dashboard.otherFollowing, + value: String(describing: $0) + ) + } + let followersContent = $followersCount + .removeDuplicates() + .map { + AXCustomContent( + label: L10n.Scene.Profile.Dashboard.otherFollowers, + value: String(describing: $0) + ) + } + let familiarContent = view.familiarFollowersDashboardView.viewModel.$label + .map { $0?.accessibilityLabel ?? ""} + .removeDuplicates() + .map { + AXCustomContent( + label: L10n.Scene.Profile.Dashboard.familiarFollowers, + value: $0 + ) + } + Publishers.CombineLatest4( + statusesContent, + followingContent, + followersContent, + familiarContent + ).sink { statuses, following, followers, familiar in + view.accessibilityCustomContent = [statuses, following, followers, familiar].compactMap { $0 } + }.store(in: &disposeBag) + } } diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift b/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift index cd4871414..2db0a5966 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView+ViewModel.swift @@ -22,7 +22,7 @@ extension FamiliarFollowersDashboardView { @Published var emojis: MastodonContent.Emojis = [:] @Published var backgroundColor: UIColor? - @Published var label: MetaContent? + @Published public var label: MetaContent? } }