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 @@ -1362,18 +1362,25 @@ public final class CourseContainerViewModel: BaseCourseViewModel {
.first { $0.type == assignmentType }?
.type
}

func assignmentTypeColor(for assignmentType: String) -> String? {
guard let progressDetails = courseProgressDetails else { return nil }

if let index = progressDetails.gradingPolicy.assignmentPolicies
.firstIndex(where: { $0.type == assignmentType }) {
let colors = progressDetails.gradingPolicy.assignmentColors
return index < colors.count ? colors[index] : nil

guard let index = progressDetails.gradingPolicy.assignmentPolicies
.firstIndex(where: { $0.type == assignmentType }) else {
return nil
}
return nil

let colors = progressDetails.gradingPolicy.assignmentColors

guard !colors.isEmpty else { return nil }

let colorIndex = index % colors.count
let hexColor = colors[colorIndex]

return hexColor
}

func getSequentialShortLabel(for blockKey: String) -> String? {
guard let courseStructure = courseAssignmentsStructure ?? courseStructure else { return nil }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ struct AllContentView: View {
// MARK: Course Progress
if let progress = viewModel.courseProgress(),
let total = progress.totalAssignmentsCount, total > 0 {
CourseProgressView(progress: progress)
CourseProgressView(
progress: progress,
fromAllContentTab: true
)
.padding(.horizontal, 24)
.accessibilityElement(children: .combine)
.accessibilityLabel(CourseLocalization.Accessibility.courseProgressSection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ struct AssignmentsContentView: View {
)

Spacer()

let weightColor = Color(
hex: assignmentContentData.assignmentTypeColors[section.key]
?? "#666666"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct CourseGradeCarouselSlideView: View {

return LazyVGrid(columns: columns, spacing: 16) {
ForEach(
Array(viewModelProgress.assignmentPolicies.prefix(4).enumerated()),
Array(viewModelProgress.assignmentPolicies.enumerated()),
id: \.element.type
) { index, policy in
let progressData = viewModelProgress.getAssignmentProgress(
Expand Down
24 changes: 20 additions & 4 deletions Course/Course/Presentation/Subviews/CourseProgressView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ public struct CourseProgressView: View {
private var onShowCompletedAnalytics: (() -> Void)?
private var showCompletedText = true
private var progressPercentageCount = 0
private var fromAllContentTab = false

public init(
progress: CourseProgress,
showCompletedToggle: Bool = false,
isShowingCompleted: Bool = true,
onToggleCompleted: (() -> Void)? = nil,
onShowCompletedAnalytics: (() -> Void)? = nil,
showCompletedText: Bool = true
showCompletedText: Bool = true,
fromAllContentTab: Bool = false
) {
self.progress = progress
self.showCompletedToggle = showCompletedToggle
self.isShowingCompleted = isShowingCompleted
self.onToggleCompleted = onToggleCompleted
self.onShowCompletedAnalytics = onShowCompletedAnalytics
self.showCompletedText = showCompletedText
self.fromAllContentTab = fromAllContentTab
}

public var body: some View {
Expand Down Expand Up @@ -71,9 +74,22 @@ public struct CourseProgressView: View {
if showCompletedText {
if let total = progress.totalAssignmentsCount,
let completed = progress.assignmentsCompleted {
Text(showCompletedToggle
? CourseLocalization.Course.progressVideosCompleted(completed, total)
: CourseLocalization.Course.progressCompleted(completed, total)
Text(
showCompletedToggle
? CourseLocalization.Course
.progressVideosCompleted(
completed,
total
)
: (
!fromAllContentTab ? CourseLocalization.Course.progressCompleted(
completed,
total
) : CourseLocalization.Course.progressSectionsCompleted(
completed,
total
)
)
)
.foregroundColor(Theme.Colors.textPrimary)
.font(Theme.Fonts.labelMedium)
Expand Down
4 changes: 4 additions & 0 deletions Course/Course/SwiftGen/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ public enum CourseLocalization {
}
/// Hide Completed
public static let progressHideCompleted = CourseLocalization.tr("Localizable", "COURSE.PROGRESS_HIDE_COMPLETED", fallback: "Hide Completed")
/// %@/%@ Sections Completed
public static func progressSectionsCompleted(_ p1: Any, _ p2: Any) -> String {
return CourseLocalization.tr("Localizable", "COURSE.PROGRESS_SECTIONS_COMPLETED", String(describing: p1), String(describing: p2), fallback: "%@/%@ Sections Completed")
}
/// %@/%@ Completed
public static func progressVideosCompleted(_ p1: Any, _ p2: Any) -> String {
return CourseLocalization.tr("Localizable", "COURSE.PROGRESS_VIDEOS_COMPLETED", String(describing: p1), String(describing: p2), fallback: "%@/%@ Completed")
Expand Down
1 change: 1 addition & 0 deletions Course/Course/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
"COURSE.DUE_TOMORROW" = "Due Tomorrow";

"COURSE.PROGRESS_COMPLETED" = "%@/%@ Completed";
"COURSE.PROGRESS_SECTIONS_COMPLETED" = "%@/%@ Sections Completed";
"COURSE.PROGRESS_VIDEOS_COMPLETED" = "%@/%@ Completed";
"COURSE.PROGRESS_WATCHED" = "%@/%@ Watched";
"COURSE.PROGRESS_VIEW_COMPLETED" = "View Completed";
Expand Down
Loading