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

Add accessibility #133

Merged
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
2 changes: 1 addition & 1 deletion Core/Core/Extensions/UIApplicationExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension UINavigationController {

let image = CoreAssets.arrowLeft.image
navigationBar.backIndicatorImage = image.withTintColor(CoreAssets.accentColor.color)
navigationBar.tintColor = .clear
navigationBar.backItem?.backButtonTitle = " "
navigationBar.backIndicatorTransitionMaskImage = image.withTintColor(CoreAssets.accentColor.color)
navigationBar.titleTextAttributes = [.foregroundColor: CoreAssets.textPrimary.color]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public extension UINavigationController {
duration: CFTimeInterval = 0.3
) {
addTransition(transitionType: type, duration: duration)
pushViewController(vc, animated: false)
pushViewController(vc, animated: UIAccessibility.isVoiceOverRunning)
}

private func addTransition(
Expand Down
2 changes: 1 addition & 1 deletion Core/Core/Extensions/ViewExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ public extension Image {
.scaledToFit()
.frame(height: 24)
.padding(.horizontal, 8)
.padding(.top, topPadding)
.offset(y: topPadding)
.foregroundColor(color)
}
}
Expand Down
4 changes: 4 additions & 0 deletions Core/Core/View/Base/CourseCellView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public struct CourseCellView: View {
.cornerRadius(8)
.clipShape(RoundedRectangle(cornerRadius: Theme.Shapes.cardImageRadius))
.padding(.leading, 3)
.accessibilityElement(children: .ignore)

VStack(alignment: .leading) {
Text(courseOrg)
Expand Down Expand Up @@ -90,6 +91,8 @@ public struct CourseCellView: View {
.background(Theme.Colors.background)
.opacity(showView ? 1 : 0)
.offset(y: showView ? 0 : 20)
.accessibilityElement(children: .ignore)
.accessibilityLabel(courseName + " " + (type == .dashboard ? (courseEnd == "" ? courseStart : courseEnd) : ""))
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now()) {
withAnimation(.easeInOut(duration: (index <= 5 ? 0.3 : 0.1))
Expand All @@ -98,6 +101,7 @@ public struct CourseCellView: View {
}
}
}

VStack {
if Int(index) != cellsCount {
Divider()
Expand Down
2 changes: 2 additions & 0 deletions Core/Core/View/Base/NavigationBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,14 @@ public struct NavigationBar: View {
}, label: {
CoreAssets.arrowLeft.swiftUIImage
.backButtonStyle(color: leftButtonColor)
.padding(8)
})
.foregroundColor(Theme.Colors.styledButtonText)

}.frame(minWidth: 0,
maxWidth: .infinity,
alignment: .topLeading)

}
if rightButtonType != nil {
VStack {
Expand Down
2 changes: 2 additions & 0 deletions Core/Core/View/Base/StyledButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public struct StyledButton: View {
.stroke(style: .init(lineWidth: 1, lineCap: .round, lineJoin: .round, miterLimit: 1))
.foregroundColor(isTransparent ? .white : .clear)
)
.accessibilityElement(children: .ignore)
.accessibilityLabel(title)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct CourseContainerView: View {
title: title,
courseID: courseID,
isVideo: false
)
).accessibilityAction {}
.tabItem {
CoreAssets.bookCircle.swiftUIImage.renderingMode(.template)
Text(CourseLocalization.CourseContainer.course)
Expand All @@ -68,7 +68,7 @@ public struct CourseContainerView: View {
title: title,
courseID: courseID,
isVideo: true
)
).accessibilityAction {}
.tabItem {
CoreAssets.videoCircle.swiftUIImage.renderingMode(.template)
Text(CourseLocalization.CourseContainer.videos)
Expand Down
158 changes: 85 additions & 73 deletions Course/Course/Presentation/Outline/CourseOutlineView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,13 @@ public struct CourseOutlineView: View {
}
Spacer(minLength: 84)
}
}.frameLimit()
}
.frameLimit()
.onRightSwipeGesture {
viewModel.router.back()
}
}.padding(.top, 8)
.accessibilityAction {}

// MARK: - Offline mode SnackBar
OfflineSnackBarView(
Expand Down Expand Up @@ -208,81 +210,91 @@ struct CourseStructureView: View {
ForEach(chapter.childs, id: \.id) { child in
let sequentialIndex = chapter.childs.firstIndex(where: { $0.id == child.id })
VStack(alignment: .leading) {
Button(
action: {
if let chapterIndex, let sequentialIndex {
viewModel.trackSequentialClicked(child)
viewModel.router.showCourseVerticalView(
courseID: viewModel.courseStructure?.id ?? "",
courseName: viewModel.courseStructure?.displayName ?? "",
title: child.displayName,
chapters: chapters,
chapterIndex: chapterIndex,
sequentialIndex: sequentialIndex
)
}
},
label: {
Group {
if child.completion == 1 {
CoreAssets.finished.swiftUIImage
.renderingMode(.template)
.foregroundColor(.accentColor)
} else {
child.type.image
}
Text(child.displayName)
.font(Theme.Fonts.titleMedium)
.multilineTextAlignment(.leading)
.lineLimit(1)
.frame(
maxWidth: idiom == .pad
? proxy.size.width * 0.5
: proxy.size.width * 0.6,
alignment: .leading
HStack {
Button(
action: {
if let chapterIndex, let sequentialIndex {
viewModel.trackSequentialClicked(child)
viewModel.router.showCourseVerticalView(
courseID: viewModel.courseStructure?.id ?? "",
courseName: viewModel.courseStructure?.displayName ?? "",
title: child.displayName,
chapters: chapters,
chapterIndex: chapterIndex,
sequentialIndex: sequentialIndex
)
}.foregroundColor(Theme.Colors.textPrimary)
Spacer()
if let state = viewModel.downloadState[child.id] {
switch state {
case .available:
DownloadAvailableView()
.onTapGesture {
viewModel.onDownloadViewTap(
chapter: chapter,
blockId: child.id,
state: state
)
}
.onForeground {
viewModel.onForeground()
}
case .downloading:
DownloadProgressView()
.onTapGesture {
viewModel.onDownloadViewTap(
chapter: chapter,
blockId: child.id,
state: state
)
}
.onBackground {
viewModel.onBackground()
}
case .finished:
DownloadFinishedView()
.onTapGesture {
viewModel.onDownloadViewTap(
chapter: chapter,
blockId: child.id,
state: state
)
}
}
},
label: {
Group {
if child.completion == 1 {
CoreAssets.finished.swiftUIImage
.renderingMode(.template)
.foregroundColor(.accentColor)
} else {
child.type.image
}
Text(child.displayName)
.font(Theme.Fonts.titleMedium)
.multilineTextAlignment(.leading)
.lineLimit(1)
.frame(
maxWidth: idiom == .pad
? proxy.size.width * 0.5
: proxy.size.width * 0.6,
alignment: .leading
)
}.foregroundColor(Theme.Colors.textPrimary)
}) .accessibilityElement(children: .ignore)
.accessibilityLabel(child.displayName)
Spacer()
if let state = viewModel.downloadState[child.id] {
switch state {
case .available:
DownloadAvailableView()
.accessibilityElement(children: .ignore)
.accessibilityLabel(CourseLocalization.Accessibility.download)
.onTapGesture {
viewModel.onDownloadViewTap(
chapter: chapter,
blockId: child.id,
state: state
)
}
.onForeground {
viewModel.onForeground()
}
case .downloading:
DownloadProgressView()
.accessibilityElement(children: .ignore)
.accessibilityLabel(CourseLocalization.Accessibility.cancelDownload)
.onTapGesture {
viewModel.onDownloadViewTap(
chapter: chapter,
blockId: child.id,
state: state
)
}
.onBackground {
viewModel.onBackground()
}
case .finished:
DownloadFinishedView()
.accessibilityElement(children: .ignore)
.accessibilityLabel(CourseLocalization.Accessibility.deleteDownload)
.onTapGesture {
viewModel.onDownloadViewTap(
chapter: chapter,
blockId: child.id,
state: state
)
}
}
Image(systemName: "chevron.right")
.foregroundColor(Theme.Colors.accentColor)
}).padding(.horizontal, 36)
}
Image(systemName: "chevron.right")
.foregroundColor(Theme.Colors.accentColor)
}
.padding(.horizontal, 36)
.padding(.vertical, 20)
if chapterIndex != chapters.count - 1 {
Divider()
Expand Down
15 changes: 12 additions & 3 deletions Course/Course/Presentation/Outline/CourseVerticalView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public struct CourseVerticalView: View {
// MARK: - Lessons list
ForEach(viewModel.verticals, id: \.id) { vertical in
if let index = viewModel.verticals.firstIndex(where: {$0.id == vertical.id}) {
HStack {
Button(action: {
let vertical = viewModel.verticals[index]
if let block = vertical.childs.first {
Expand All @@ -74,7 +75,6 @@ public struct CourseVerticalView: View {
)
}
}, label: {
HStack {
Group {
if vertical.completion == 1 {
CoreAssets.finished.swiftUIImage
Expand All @@ -93,11 +93,15 @@ public struct CourseVerticalView: View {
.multilineTextAlignment(.leading)
.frame(maxWidth: .infinity, alignment: .leading)
}.foregroundColor(Theme.Colors.textPrimary)
}).accessibilityElement(children: .ignore)
.accessibilityLabel(vertical.displayName)
Spacer()
if let state = viewModel.downloadState[vertical.id] {
switch state {
case .available:
DownloadAvailableView()
.accessibilityElement(children: .ignore)
.accessibilityLabel(CourseLocalization.Accessibility.download)
.onTapGesture {
viewModel.onDownloadViewTap(
blockId: vertical.id,
Expand All @@ -109,6 +113,8 @@ public struct CourseVerticalView: View {
}
case .downloading:
DownloadProgressView()
.accessibilityElement(children: .ignore)
.accessibilityLabel(CourseLocalization.Accessibility.cancelDownload)
.onTapGesture {
viewModel.onDownloadViewTap(
blockId: vertical.id,
Expand All @@ -120,6 +126,8 @@ public struct CourseVerticalView: View {
}
case .finished:
DownloadFinishedView()
.accessibilityElement(children: .ignore)
.accessibilityLabel(CourseLocalization.Accessibility.deleteDownload)
.onTapGesture {
viewModel.onDownloadViewTap(
blockId: vertical.id,
Expand All @@ -131,7 +139,7 @@ public struct CourseVerticalView: View {
Image(systemName: "chevron.right")
.padding(.vertical, 8)
}
}).padding(.horizontal, 36)
.padding(.horizontal, 36)
.padding(.vertical, 14)
if index != viewModel.verticals.count - 1 {
Divider()
Expand All @@ -143,7 +151,8 @@ public struct CourseVerticalView: View {
}
}
Spacer(minLength: 84)
}.frameLimit()
}.accessibilityAction {}
.frameLimit()
.onRightSwipeGesture {
viewModel.router.back()
}
Expand Down
8 changes: 8 additions & 0 deletions Course/Course/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import Foundation
// swiftlint:disable explicit_type_interface function_parameter_count identifier_name line_length
// swiftlint:disable nesting type_body_length type_name vertical_whitespace_opening_braces
public enum CourseLocalization {
public enum Accessibility {
/// Cancel download
public static let cancelDownload = CourseLocalization.tr("Localizable", "ACCESSIBILITY.CANCEL_DOWNLOAD", fallback: "Cancel download")
/// Delete download
public static let deleteDownload = CourseLocalization.tr("Localizable", "ACCESSIBILITY.DELETE_DOWNLOAD", fallback: "Delete download")
/// Download
public static let download = CourseLocalization.tr("Localizable", "ACCESSIBILITY.DOWNLOAD", fallback: "Download")
}
public enum Alert {
/// Rotate your device to view this video in full screen.
public static let rotateDevice = CourseLocalization.tr("Localizable", "ALERT.ROTATE_DEVICE", fallback: "Rotate your device to view this video in full screen.")
Expand Down
4 changes: 4 additions & 0 deletions Course/Course/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
"NOT_AVALIABLE.BUTTON" = "Open in browser";

"SUBTITLES.TITLE" = "Subtitles";

"ACCESSIBILITY.DOWNLOAD" = "Download";
"ACCESSIBILITY.CANCEL_DOWNLOAD" = "Cancel download";
"ACCESSIBILITY.DELETE_DOWNLOAD" = "Delete download";
Loading