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

chore: set accessibility identifiers to elements #293

Merged
merged 5 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ public struct SignInView: View {
VStack {
Spacer()
SnackBarView(message: viewModel.errorMessage)
.accessibilityLabel("error_snackbar")
}.transition(.move(edge: .bottom))
.onAppear {
doAfter(Theme.Timeout.snackbarMessageLongTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public struct SignUpView: View {
VStack {
Spacer()
SnackBarView(message: viewModel.errorMessage)
.accessibilityLabel("error_snackbar")
}.transition(.move(edge: .bottom))
.onAppear {
doAfter(Theme.Timeout.snackbarMessageLongTimeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ public struct ResetPasswordView: View {
VStack {
Spacer()
SnackBarView(message: viewModel.errorMessage)
.accessibilityIdentifier("show_error_snackbar")
rnr marked this conversation as resolved.
Show resolved Hide resolved
}.transition(.move(edge: .bottom))
.onAppear {
doAfter(Theme.Timeout.snackbarMessageLongTimeout) {
Expand Down
7 changes: 7 additions & 0 deletions Core/Core/View/Base/CourseCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,37 +50,43 @@ public struct CourseCellView: View {
.clipShape(RoundedRectangle(cornerRadius: Theme.Shapes.cardImageRadius))
.padding(.leading, 3)
.accessibilityElement(children: .ignore)
.accessibilityIdentifier("course_image")

VStack(alignment: .leading) {
Text(courseOrg)
.font(Theme.Fonts.labelMedium)
.foregroundColor(Theme.Colors.textSecondary)
.multilineTextAlignment(.leading)
.accessibilityIdentifier("org_text")

Text(courseName)
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.textPrimary)
.lineLimit(type == .discovery ? 3 : 2)
.multilineTextAlignment(.leading)
.padding(.top, 1)
.accessibilityIdentifier("course_name_text")
Spacer()
if type == .dashboard {
HStack {
if courseEnd != "" {
Text(courseEnd)
.font(Theme.Fonts.labelMedium)
.foregroundColor(Theme.Colors.textSecondary)
.accessibilityIdentifier("course_end_text")
} else {
Text(courseStart)
.font(Theme.Fonts.labelMedium)
.foregroundColor(Theme.Colors.textSecondary)
.accessibilityIdentifier("course_start_text")
}
Spacer()
CoreAssets.arrowRight16.swiftUIImage.renderingMode(.template)
.resizable()
.frame(width: 16, height: 16)
.offset(x: 15)
.foregroundColor(Theme.Colors.accentColor)
.accessibilityIdentifier("arrow_image")
}
}
}.padding(.horizontal, 10)
Expand Down Expand Up @@ -110,6 +116,7 @@ public struct CourseCellView: View {
.overlay(Theme.Colors.cardViewStroke)
.padding(.vertical, 18)
.padding(.horizontal, 3)
.accessibilityIdentifier("devider")
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions Core/Core/View/Base/OfflineSnackBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ public struct OfflineSnackBarView: View {
Spacer()
HStack(spacing: 12) {
Text(CoreLocalization.NoInternet.offline)
.accessibilityIdentifier("no_internet_text")
Spacer()
Button(CoreLocalization.NoInternet.dismiss,
action: {
withAnimation {
dismiss = true
}
})
.accessibilityIdentifier("no_internet_dismiss_button")
Button(CoreLocalization.NoInternet.reload,
action: {
Task {
Expand All @@ -44,6 +46,7 @@ public struct OfflineSnackBarView: View {
dismiss = true
}
})
.accessibilityIdentifier("no_internet_reload_button")
}.padding(.horizontal, 16)
.font(Theme.Fonts.titleSmall)
.frame(maxWidth: .infinity, maxHeight: OfflineSnackBarView.height)
Expand Down
2 changes: 2 additions & 0 deletions Core/Core/View/Base/SnackBarView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ public struct SnackBarView: View {
Text(message)
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.snackbarTextColor)
.accessibilityIdentifier("snackbar_text")
Spacer()

if let action = action {
Button(CoreLocalization.View.Snackbar.tryAgainBtn) {
action()
}
.font(Theme.Fonts.titleSmall)
.accessibilityIdentifier("snackbar_button")
}

}.shadowCardStyle(bgColor: Theme.Colors.snackbarErrorColor,
Expand Down
12 changes: 7 additions & 5 deletions Core/Core/View/Base/VideoDownloadQualityView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public struct VideoDownloadQualityView: View {
ScrollView {
VStack(alignment: .leading, spacing: 24) {
ForEach(viewModel.downloadQuality, id: \.self) { quality in
Button {
Button(action: {
rnr marked this conversation as resolved.
Show resolved Hide resolved
viewModel.selectedDownloadQuality = quality
} label: {
}, label: {
rnr marked this conversation as resolved.
Show resolved Hide resolved
HStack {
SettingsCell(
title: quality.title,
Expand All @@ -67,11 +67,11 @@ public struct VideoDownloadQualityView: View {
.foregroundColor(Theme.Colors.accentXColor)
.opacity(quality == viewModel.selectedDownloadQuality ? 1 : 0)
.accessibilityIdentifier("checkmark_image")

}
.foregroundColor(Theme.Colors.textPrimary)
}
.accessibilityIdentifier("quality_button_cell")
})
.accessibilityIdentifier("select_quality_button")
Divider()
}
}
Expand Down Expand Up @@ -109,10 +109,12 @@ public struct SettingsCell: View {
VStack(alignment: .leading) {
Text(title)
.font(Theme.Fonts.titleMedium)
.accessibilityIdentifier("video_quality_title_text")
if let description {
Text(description)
.font(Theme.Fonts.labelMedium)
.foregroundColor(Theme.Colors.textSecondary)
.accessibilityIdentifier("video_quality_des_text")
}
}.foregroundColor(Theme.Colors.textPrimary)
.frame(maxWidth: .infinity, alignment: .leading)
Expand Down
2 changes: 2 additions & 0 deletions Core/Core/View/Base/WebBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public struct WebBrowser: View {
lineWidth: 8
)
.padding(20)
.accessibilityIdentifier("progress_bar")
}
.frame(maxWidth: .infinity)
}
Expand All @@ -57,6 +58,7 @@ public struct WebBrowser: View {
isLoading: $isLoading,
refreshCookies: {}
)
.accessibilityIdentifier("web_browser")
}
.padding(.top, proxy.safeAreaInsets.top)
.padding(.bottom, proxy.safeAreaInsets.bottom)
Expand Down
6 changes: 6 additions & 0 deletions Dashboard/Dashboard/Presentation/DashboardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public struct DashboardView: View {
Text(DashboardLocalization.Header.courses)
.font(Theme.Fonts.displaySmall)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("courses_header_text")
Text(DashboardLocalization.Header.welcomeBack)
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("courses_welcomeback_text")
}.listRowBackground(Color.clear)
.padding(.top, 24)
.accessibilityElement(children: .ignore)
Expand Down Expand Up @@ -81,6 +83,7 @@ public struct DashboardView: View {
title: course.name
)
}
.accessibilityIdentifier("course_item")
}
// MARK: - ProgressBar
if viewModel.nextPage <= viewModel.totalPages {
Expand Down Expand Up @@ -158,13 +161,16 @@ struct EmptyPageIcon: View {
VStack(alignment: .center, spacing: 0) {
CoreAssets.dashboardEmptyPage.swiftUIImage
.padding(.bottom, 16)
.accessibilityIdentifier("empty_page_image")
Text(DashboardLocalization.Empty.title)
.font(Theme.Fonts.titleMedium)
.foregroundColor(Theme.Colors.textPrimary)
.padding(.bottom, 8)
.accessibilityIdentifier("empty_page_title_text")
Text(DashboardLocalization.Empty.subtitle)
.font(Theme.Fonts.bodySmall)
.foregroundColor(Theme.Colors.textSecondary)
.accessibilityIdentifier("empty_page_subtitle_text")
}
.padding(.top, 200)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public struct CourseDetailsView: View {
ProgressBar(size: 40, lineWidth: 8)
.padding(.top, 200)
.padding(.horizontal)
.accessibilityIdentifier("progressbar")
}.frame(width: proxy.size.width)
} else {
RefreshableScrollViewCompat(action: {
Expand Down Expand Up @@ -131,6 +132,7 @@ public struct CourseDetailsView: View {
ProgressBar(size: 40, lineWidth: 8)
.padding(.top, 20)
.frame(maxWidth: .infinity)
.accessibilityIdentifier("progressbar")
}
}
}
Expand Down Expand Up @@ -233,12 +235,14 @@ private struct CourseStateView: View {
}
})
.padding(16)
.accessibilityIdentifier("enroll_button")
case .enrollClose:
Text(DiscoveryLocalization.Details.enrollmentDateIsOver)
.multilineTextAlignment(.center)
.font(Theme.Fonts.titleSmall)
.cardStyle()
.padding(.vertical, 24)
.accessibilityIdentifier("date_over_text")
case .alreadyEnrolled:
StyledButton(DiscoveryLocalization.Details.viewCourse, action: {
if !viewModel.userloggedIn {
Expand All @@ -264,6 +268,7 @@ private struct CourseStateView: View {
}
})
.padding(16)
.accessibilityIdentifier("view_course_button")
}
}
}
Expand All @@ -277,6 +282,7 @@ private struct PlayButton: View {
.resizable()
.frame(width: 40, height: 40)
})
.accessibilityIdentifier("play_button")
}
}

Expand All @@ -288,16 +294,19 @@ private struct CourseTitleView: View {
Text(courseDetails.courseDescription ?? "")
.font(Theme.Fonts.labelSmall)
.padding(.horizontal, 26)
.accessibilityIdentifier("description_text")

Text(courseDetails.courseTitle)
.font(Theme.Fonts.titleLarge)
.padding(.horizontal, 26)
.accessibilityIdentifier("title_text")

Text(courseDetails.org)
.font(Theme.Fonts.labelMedium)
.foregroundColor(Theme.Colors.accentColor)
.padding(.horizontal, 26)
.padding(.top, 10)
.accessibilityIdentifier("org_text")
}
}
}
Expand Down Expand Up @@ -335,6 +344,7 @@ private struct CourseBannerView: View {
animate = true
}
}
.accessibilityIdentifier("course_image")
if courseDetails.courseVideoURL != nil {
PlayButton(action: onPlayButtonTap)
}
Expand All @@ -350,6 +360,7 @@ private struct CourseBannerView: View {
animate = true
}
}
.accessibilityIdentifier("course_image")
if courseDetails.courseVideoURL != nil {
PlayButton(action: onPlayButtonTap)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public struct DiscoveryView: View {
Text(DiscoveryLocalization.Header.title1)
.font(Theme.Fonts.displaySmall)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("title_text")
Text(DiscoveryLocalization.Header.title2)
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("subtitle_text")
}.listRowBackground(Color.clear)
.accessibilityElement(children: .ignore)
.accessibilityLabel(DiscoveryLocalization.Header.title1 + DiscoveryLocalization.Header.title2)
Expand Down Expand Up @@ -56,8 +58,10 @@ public struct DiscoveryView: View {
Image(systemName: "magnifyingglass")
.padding(.leading, 16)
.padding(.top, 1)
.accessibilityIdentifier("search_image")
Text(DiscoveryLocalization.search)
.foregroundColor(Theme.Colors.textSecondary)
.accessibilityIdentifier("search_text")
Spacer()
}
.onTapGesture {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public struct SearchView: View {
: Theme.Colors.textPrimary
)
.accessibilityHidden(true)
.accessibilityIdentifier("search_image")

TextField(
!viewModel.isSearchActive
Expand All @@ -58,6 +59,7 @@ public struct SearchView: View {
self.focused = true
}
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("search_textfields")
Spacer()
if !viewModel.searchText.trimmingCharacters(in: .whitespaces).isEmpty {
Button(action: { viewModel.searchText.removeAll() }, label: {
Expand All @@ -68,6 +70,7 @@ public struct SearchView: View {
.padding(.horizontal)
})
.foregroundColor(Theme.Colors.styledButtonText)
.accessibilityIdentifier("search_button")
}
}
.frame(minHeight: 48)
Expand Down Expand Up @@ -172,9 +175,11 @@ public struct SearchView: View {
Text(DiscoveryLocalization.Search.title)
.font(Theme.Fonts.displaySmall)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("title_text")
Text(searchDescription(viewModel: viewModel))
.font(Theme.Fonts.titleSmall)
.foregroundColor(Theme.Colors.textPrimary)
.accessibilityIdentifier("description_text")
}.listRowBackground(Color.clear)
.accessibilityElement(children: .ignore)
.accessibilityLabel(DiscoveryLocalization.Search.title + searchDescription(viewModel: viewModel))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public struct DiscoveryWebview: View {
refreshCookies: {},
navigationDelegate: viewModel
)
.accessibilityIdentifier("discovery_webview")

if isLoading || viewModel.showProgress {
HStack(alignment: .center) {
Expand All @@ -101,6 +102,7 @@ public struct DiscoveryWebview: View {
lineWidth: 8
)
.padding(.vertical, proxy.size.height / 2)
.accessibilityIdentifier("progressbar")
}
.frame(width: proxy.size.width, height: proxy.size.height)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public struct ProgramWebviewView: View {
},
navigationDelegate: viewModel
)
.accessibilityIdentifier("program_webview")

if isLoading || viewModel.showProgress || viewModel.updatingCookies {
HStack(alignment: .center) {
Expand All @@ -76,6 +77,7 @@ public struct ProgramWebviewView: View {
lineWidth: 8
)
.padding(.vertical, proxy.size.height / 2)
.accessibilityIdentifier("progressbar")
}
.frame(width: proxy.size.width, height: proxy.size.height)
}
Expand Down
Loading
Loading