Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Accessibility #693

Merged
merged 11 commits into from
Apr 13, 2023
28 changes: 16 additions & 12 deletions Mail/Components/AvatarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import InfomaniakCore
import MailCore
import MailResources
import NukeUI
import SwiftUI

Expand All @@ -26,20 +27,23 @@ struct AvatarView: View {
var size: CGFloat = 28

var body: some View {
if let avatarImageRequest = avatarDisplayable.avatarImageRequest {
LazyImage(request: avatarImageRequest) { state in
if let image = state.image {
ContactImage(image: image, size: size)
} else {
InitialsView(
initials: avatarDisplayable.initials,
color: avatarDisplayable.initialsBackgroundColor,
size: size
)
Group {
if let avatarImageRequest = avatarDisplayable.avatarImageRequest {
LazyImage(request: avatarImageRequest) { state in
if let image = state.image {
ContactImage(image: image, size: size)
} else {
InitialsView(
initials: avatarDisplayable.initials,
color: avatarDisplayable.initialsBackgroundColor,
size: size
)
}
}
} else {
InitialsView(initials: avatarDisplayable.initials, color: avatarDisplayable.initialsBackgroundColor, size: size)
}
} else {
InitialsView(initials: avatarDisplayable.initials, color: avatarDisplayable.initialsBackgroundColor, size: size)
}
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionUserAvatar)
}
}
3 changes: 3 additions & 0 deletions Mail/Components/RecipientAutocompletionCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct RecipientAutocompletionCell: View {
var body: some View {
HStack {
AvatarView(avatarDisplayable: recipient, size: 40)
.accessibilityHidden(true)

if recipient.name.isEmpty {
Text(recipient.email)
Expand All @@ -40,6 +41,8 @@ struct RecipientAutocompletionCell: View {
Spacer()
}
.lineLimit(1)
.accessibilityElement(children: .combine)
.accessibilityAddTraits(.isButton)
}
}

Expand Down
15 changes: 15 additions & 0 deletions Mail/Components/ThreadCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ struct ThreadCell: View {
density == .large ? UIConstants.checkboxLargeSize : UIConstants.checkboxSize
}

private var additionalAccessibilityLabel: String {
var label = ""
if isSelected {
label.append("\(MailResourcesStrings.Localizable.contentDescriptionSelectedItem). ")
}
if thread.hasUnseenMessages {
label.append(MailResourcesStrings.Localizable.actionShortMarkAsUnread)
}
return label
}

init(
thread: Thread,
mailboxManager: MailboxManager,
Expand All @@ -119,6 +130,8 @@ struct ThreadCell: View {
.threadListSlide(density: density, isMultipleSelectionEnabled: isMultipleSelectionEnabled),
value: isMultipleSelectionEnabled
)
.accessibilityLabel(additionalAccessibilityLabel)
.accessibilityHidden(additionalAccessibilityLabel.isEmpty)

Group {
if density == .large, let recipient = dataHolder.recipientToDisplay {
Expand All @@ -127,6 +140,7 @@ struct ThreadCell: View {
CheckboxView(isSelected: isSelected, density: density)
.opacity(isSelected ? 1 : 0)
}
.accessibility(hidden: true)
} else if isMultipleSelectionEnabled {
CheckboxView(isSelected: isSelected, density: density)
.animation(
Expand Down Expand Up @@ -155,6 +169,7 @@ struct ThreadCell: View {
.padding(.trailing, 16)
.padding(.vertical, density.cellVerticalPadding)
.clipped()
.accessibilityElement(children: .combine)
}
}

Expand Down
2 changes: 2 additions & 0 deletions Mail/Components/ThreadCellHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ struct ThreadCellHeaderView: View {

if thread.messages.count > 1 {
ThreadCountIndicatorView(messagesCount: thread.messages.count, hasUnseenMessages: thread.hasUnseenMessages)
.accessibilityHidden(true)
}

Spacer()

Text(dataHolder.date)
.textStyle(.bodySmallSecondary)
.lineLimit(1)
.accessibilityHidden(true)
}
}
}
1 change: 1 addition & 0 deletions Mail/Utils/FloatingActionButtonModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ struct FloatingActionButtonModifier: ViewModifier {
MailButton(icon: icon, label: title, action: action)
.padding(.trailing, 24)
.padding(.bottom, UIConstants.floatingButtonBottomPadding)
.accessibilityLabel(title)
}
}
.ignoresSafeArea(.keyboard)
Expand Down
2 changes: 2 additions & 0 deletions Mail/Views/Bottom sheets/ContactActionsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct ContactActionsView: View {
VStack(alignment: .leading, spacing: 16) {
HStack {
AvatarView(avatarDisplayable: recipient, size: 32)
.accessibilityHidden(true)
VStack(alignment: .leading) {
Text(recipient.contact?.name ?? recipient.formattedName)
.textStyle(.bodyMedium)
Expand All @@ -73,6 +74,7 @@ struct ContactActionsView: View {
}
}
.padding(.bottom, 8)
.accessibilityElement(children: .combine)

ForEach(actions, id: \.self) { action in
Button {
Expand Down
42 changes: 24 additions & 18 deletions Mail/Views/Menu Drawer/Folders/UserFoldersListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,32 @@ struct UserFoldersListView: View {

var body: some View {
VStack(spacing: 0) {
Button {
withAnimation {
isExpanded.toggle()
matomo.track(eventWithCategory: .menuDrawer, name: "customFolders", value: isExpanded)
}
} label: {
HStack(spacing: 12) {
ChevronIcon(style: isExpanded ? .up : .down, color: .secondary)
Text(MailResourcesStrings.Localizable.buttonFolders)
.textStyle(.bodySmallSecondary)
Spacer()
Button {
matomo.track(eventWithCategory: .createFolder, name: "fromMenuDrawer")
globalAlert.state = .createNewFolder(mode: .create)
} label: {
MailResourcesAsset.addCircle.swiftUIImage
.resizable()
.frame(width: 16, height: 16)
HStack(spacing: 12) {
Button {
withAnimation {
isExpanded.toggle()
matomo.track(eventWithCategory: .menuDrawer, name: "customFolders", value: isExpanded)
}
} label: {
HStack(spacing: 12) {
ChevronIcon(style: isExpanded ? .up : .down, color: .secondary)
Text(MailResourcesStrings.Localizable.buttonFolders)
.textStyle(.bodySmallSecondary)
Spacer()
}
}
.frame(maxWidth: .infinity)
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionButtonExpandCustomFolders)

Button {
matomo.track(eventWithCategory: .createFolder, name: "fromMenuDrawer")
globalAlert.state = .createNewFolder(mode: .create)
} label: {
MailResourcesAsset.addCircle.swiftUIImage
.resizable()
.frame(width: 16, height: 16)
}
.accessibilityLabel(MailResourcesStrings.Localizable.newFolderDialogTitle)
}
.padding(.horizontal, UIConstants.menuDrawerHorizontalPadding)
.padding(.vertical, UIConstants.menuDrawerVerticalPadding)
Expand Down
4 changes: 4 additions & 0 deletions Mail/Views/Menu Drawer/MenuDrawerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ struct NavigationDrawer: View {
}
}
}
.accessibilityAction(.escape) {
matomo.track(eventWithCategory: .menuDrawer, name: "closeByAccessibility")
navigationDrawerState.close()
}
.gesture(dragGesture)
.statusBarHidden(navigationDrawerState.isOpen)
.onChange(of: navigationDrawerState.isOpen) { isOpen in
Expand Down
1 change: 1 addition & 0 deletions Mail/Views/Menu Drawer/MenuHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ struct MenuHeaderView: View {
.frame(width: 24)
}
.buttonStyle(.borderless)
.accessibilityLabel(MailResourcesStrings.Localizable.settingsTitle)
}
.padding(.top, 12)
.padding(.bottom, 15)
Expand Down
1 change: 1 addition & 0 deletions Mail/Views/Search/SearchHistorySectionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct SearchHistorySectionView: View {
.frame(width: 16, height: 16)
}
.buttonStyle(BorderlessButtonStyle())
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionButtonDeleteHistory)
}
.contentShape(Rectangle())
.onTapGesture {
Expand Down
4 changes: 4 additions & 0 deletions Mail/Views/Search/SearchView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,15 @@ struct SearchView: View {
ForEach(viewModel.filters) { filter in
if filter == .folder {
SearchFilterFolderCell(selection: $viewModel.selectedSearchFolderId, folders: viewModel.folderList)
.accessibilityHint(MailResourcesStrings.Localizable.contentDescriptionButtonFilterSearch)
.padding(.horizontal, 12)
} else {
SearchFilterCell(
title: filter.title,
isSelected: viewModel.selectedFilters.contains(filter)
)
.accessibilityHint(MailResourcesStrings.Localizable.contentDescriptionButtonFilterSearch)
.accessibilityAddTraits(viewModel.selectedFilters.contains(filter) ? [.isSelected] : [])
.padding(.vertical, 2)
.padding(.trailing, 0)
.padding(.leading, 12)
Expand Down Expand Up @@ -120,6 +123,7 @@ struct SearchView: View {
} label: {
Image(isCompact ? MailResourcesAsset.arrowLeft.name : MailResourcesAsset.closeBig.name)
}
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionButtonBack)
}

ToolbarItem(placement: .navigation) {
Expand Down
1 change: 1 addition & 0 deletions Mail/Views/SplitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct SplitView: View {
mailboxManager: mailboxManager,
isCompact: isCompact
)
.accessibilityHidden(navigationDrawerController.isOpen)
}
.navigationViewStyle(.stack)

Expand Down
2 changes: 2 additions & 0 deletions Mail/Views/Thread List/ThreadListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ private struct ThreadListToolbar: ViewModifier {
.scaledToFit()
.frame(width: UIConstants.navbarIconSize, height: UIConstants.navbarIconSize)
}
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionButtonMenu)
}
}
}
Expand Down Expand Up @@ -357,6 +358,7 @@ private struct ThreadListToolbar: ViewModifier {
} label: {
AvatarView(avatarDisplayable: AccountManager.instance.currentAccount.user)
}
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionUserAvatar)
}
}

Expand Down
1 change: 1 addition & 0 deletions Mail/Views/Thread/MessageHeaderSummaryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ struct MessageHeaderSummaryView: View {
.lineLimit(1)
.textStyle(.bodySmallSecondary)
ChevronButton(isExpanded: $isHeaderExpanded)
.accessibilityLabel(MailResourcesStrings.Localizable.contentDescriptionButtonExpandRecipients)
.onChange(of: isHeaderExpanded) { isExpanded in
matomo.track(eventWithCategory: .message, name: "openDetails", value: isExpanded)
}
Expand Down
Binary file modified MailResources/Localizable/de.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/en.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/es.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/fr.lproj/Localizable.strings
Binary file not shown.
Binary file modified MailResources/Localizable/it.lproj/Localizable.strings
Binary file not shown.