Skip to content
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 @@ -76,35 +76,30 @@ public struct CourseDetailsView: View {
// MARK: - Course Banner
CourseBannerView(
courseDetails: courseDetails,
proxy: proxy,
isHorisontal: viewModel.isHorisontal,
onPlayButtonTap: { [weak viewModel] in
viewModel?.showCourseVideo()
}
)
}.aspectRatio(CGSize(width: 16, height: 8.5), contentMode: .fill)
.frame(maxHeight: 250)
.frame(width: 312, height: 312 * 8.5 / 16)
.cornerRadius(12)
.padding(.horizontal, 6)
.padding(.top, 7)

}
}
} else {
// MARK: - iPhone
VStack(alignment: .leading) {
// MARK: - Course Banner
CourseBannerView(
courseDetails: courseDetails,
proxy: proxy,
isHorisontal: viewModel.isHorisontal,
onPlayButtonTap: { [weak viewModel] in
viewModel?.showCourseVideo()
})
}.aspectRatio(CGSize(width: 16, height: 8.5), contentMode: .fill)
.aspectRatio(CGSize(width: 16, height: 8.5), contentMode: .fit)
.cornerRadius(12)
.padding(.horizontal, 6)
.padding(.top, 7)
.fixedSize(horizontal: false, vertical: true)
}

// MARK: - Course state button
CourseStateView(title: title,
Expand Down Expand Up @@ -376,58 +371,40 @@ private struct CourseTitleView: View {

private struct CourseBannerView: View {
@State private var animate = false
private var isHorisontal: Bool
private let courseDetails: CourseDetails
private let idiom: UIUserInterfaceIdiom
private let proxy: GeometryProxy
private let onPlayButtonTap: () -> Void

init(courseDetails: CourseDetails,
proxy: GeometryProxy,
isHorisontal: Bool,
onPlayButtonTap: @escaping () -> Void) {
self.courseDetails = courseDetails
self.isHorisontal = isHorisontal
self.idiom = UIDevice.current.userInterfaceIdiom
self.proxy = proxy
self.onPlayButtonTap = onPlayButtonTap
}

var body: some View {
ZStack(alignment: .center) {
if !isHorisontal {
KFImage(URL(string: courseDetails.courseBannerURL))
.onFailureImage(CoreAssets.noCourseImage.image)
.resizable()
.aspectRatio(16/9, contentMode: .fill)
.frame(width: idiom == .pad ? nil : proxy.size.width - 12)
.opacity(animate ? 1 : 0)
.onAppear {
withAnimation(.linear(duration: 0.5)) {
animate = true
}
}
.accessibilityIdentifier("course_image")
if courseDetails.courseVideoURL != nil {
PlayButton(action: onPlayButtonTap)
}
} else {
KFImage(URL(string: courseDetails.courseBannerURL))
.onFailureImage(CoreAssets.noCourseImage.image)
.resizable()
.aspectRatio(16/9, contentMode: .fill)
.frame(width: 312)
.opacity(animate ? 1 : 0)
.onAppear {
withAnimation(.linear(duration: 0.5)) {
animate = true
}
bannerImage
if courseDetails.courseVideoURL != nil {
PlayButton(action: onPlayButtonTap)
}
}
}

private var bannerImage: some View {
GeometryReader { proxy in
KFImage(URL(string: courseDetails.courseBannerURL))
.onFailureImage(CoreAssets.noCourseImage.image)
.resizable()
.scaledToFill()
.frame(width: proxy.size.width, height: proxy.size.height)
.clipped()
.opacity(animate ? 1 : 0)
.onAppear {
withAnimation(.linear(duration: 0.5)) {
animate = true
}
.accessibilityIdentifier("course_image")
if courseDetails.courseVideoURL != nil {
PlayButton(action: onPlayButtonTap)
}
}
.accessibilityIdentifier("course_image")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need also to add
.accessibilityLabel("Course banner")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Added .accessibilityLabel(DiscoveryLocalization.Details.courseBanner) and added a localized accessibility label for the course banner, and regenerated Strings.swift

.accessibilityLabel(DiscoveryLocalization.Details.courseBanner)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Discovery/Discovery/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ public enum DiscoveryLocalization {
public static let pleaseEnterTheSystem = DiscoveryLocalization.tr("Localizable", "ALERT.PLEASE_ENTER_THE_SYSTEM", fallback: "Please enter the system to continue with course enrollment.")
}
public enum Details {
/// Course banner
public static let courseBanner = DiscoveryLocalization.tr("Localizable", "DETAILS.COURSE_BANNER", fallback: "Course banner")
/// Enroll now
public static let enrollNow = DiscoveryLocalization.tr("Localizable", "DETAILS.ENROLL_NOW", fallback: "Enroll now")
/// You cannot enroll in this course because the enrollment date is over.
Expand Down
1 change: 1 addition & 0 deletions Discovery/Discovery/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"DETAILS.ENROLL_NOW" = "Enroll now";
"DETAILS.ENROLLMENT_DATE_IS_OVER" = "You cannot enroll in this course because the enrollment date is over.";
"DETAILS.ENROLLMENT_NO_INTERNET" = "To enroll in this course, please make sure you are connected to the internet.";
"DETAILS.COURSE_BANNER" = "Course banner";

"ALERT.AUTHORIZATION" = "Authorization";
"ALERT.PLEASE_ENTER_THE_SYSTEM" = "Please enter the system to continue with course enrollment.";
Loading