Skip to content
Open
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/View/Base/AppReview/AppReviewView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public struct AppReviewView: View {
if viewModel.feedback.isEmpty {
Text(CoreLocalization.Review.better)
.font(Theme.Fonts.bodyMedium)
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.textInputPlaceholderColor)
.padding(16)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public struct FullScreenErrorView: View {
image
.resizable()
.renderingMode(.template)
.foregroundStyle(Theme.Colors.textSecondary)
.foregroundStyle(Theme.Colors.emptyStateIconColor)
.aspectRatio(contentMode: .fit)
.frame(maxWidth: 72, maxHeight: 80)

Expand All @@ -55,7 +55,7 @@ public struct FullScreenErrorView: View {
.noInternetWithReload:
CoreAssets.noWifi.swiftUIImage
.renderingMode(.template)
.foregroundStyle(Theme.Colors.textSecondary)
.foregroundStyle(Theme.Colors.emptyStateIconColor)
.scaledToFit()

Text(CoreLocalization.Error.Internet.noInternetTitle)
Expand All @@ -70,7 +70,7 @@ public struct FullScreenErrorView: View {
case .generic:
CoreAssets.notAvaliable.swiftUIImage
.renderingMode(.template)
.foregroundStyle(Theme.Colors.textSecondary)
.foregroundStyle(Theme.Colors.emptyStateIconColor)
.scaledToFit()

Text(CoreLocalization.View.Snackbar.tryAgainBtn)
Expand Down
12 changes: 1 addition & 11 deletions Course/Course/Data/Model/Data_CourseProgressResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -376,17 +376,7 @@ public extension DataLayer.GradingPolicy {
CourseProgressGradingPolicy(
assignmentPolicies: assignmentPolicies.map { $0.domain },
gradeRange: gradeRange,
assignmentColors: assignmentColors ?? [
"#D24242",
"#7B9645",
"#5A5AD8",
"#B0842C",
"#2E90C2",
"#D13F88",
"#36A17D",
"#AE5AD8",
"#3BA03B"
]
assignmentColors: CourseProgressGradingPolicy.normalizedAssignmentColors(assignmentColors)
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Course/Course/Domain/Model/AssignmentCardStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public enum AssignmentCardStatus: Sendable, Equatable {
case .pastDue:
return Theme.Colors.warning.opacity(0.1)
case .notAvailable:
return Theme.Colors.textSecondary.opacity(0.1)
return Theme.Colors.cardViewStroke.opacity(0.1)
}
}

Expand All @@ -37,7 +37,7 @@ public enum AssignmentCardStatus: Sendable, Equatable {
case .pastDue:
return Theme.Colors.warning
case .notAvailable:
return Theme.Colors.textSecondary
return Theme.Colors.cardViewStroke
}
}

Expand Down
31 changes: 30 additions & 1 deletion Course/Course/Domain/Model/CourseProgressDetails.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,18 @@ public struct CourseProgressGrade: Sendable {
}

public struct CourseProgressGradingPolicy: Sendable {
public static let defaultAssignmentColors = [
"#D24242",
"#7B9645",
"#5A5AD8",
"#B0842C",
"#2E90C2",
"#D13F88",
"#36A17D",
"#AE5AD8",
"#3BA03B"
]

public let assignmentPolicies: [CourseProgressAssignmentPolicy]
public let gradeRange: [String: Double]
public let assignmentColors: [String]
Expand All @@ -220,7 +232,24 @@ public struct CourseProgressGradingPolicy: Sendable {
) {
self.assignmentPolicies = assignmentPolicies
self.gradeRange = gradeRange
self.assignmentColors = assignmentColors
self.assignmentColors = Self.normalizedAssignmentColors(assignmentColors)
}

public static func normalizedAssignmentColors(_ assignmentColors: [String]?) -> [String] {
guard let assignmentColors, !assignmentColors.isEmpty else {
return defaultAssignmentColors
}
return assignmentColors
}

public static func assignmentColorHex(for index: Int, in assignmentColors: [String]) -> String {
let colors = assignmentColors.isEmpty ? defaultAssignmentColors : assignmentColors
let colorIndex = max(0, index) % colors.count
return colors[colorIndex]
}

public func assignmentColorHex(for index: Int) -> String {
Self.assignmentColorHex(for: index, in: assignmentColors)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct AssignmentDetailCardView: View {
case .pastDue:
return Theme.Colors.warning
case .notAvailable:
return Theme.Colors.textSecondary
return Theme.Colors.cardViewStroke
default:
return Theme.Colors.cardViewStroke
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public struct TotalDownloadedProgressView: View {
ZStack(alignment: .leading) {
GeometryReader { geometry in
RoundedRectangle(cornerRadius: 2.5)
.fill(Theme.Colors.textSecondary.opacity(0.5))
.fill(Theme.Colors.courseProgressBG)
.frame(width: geometry.size.width, height: 5)

RoundedCorners(tl: 2.5, tr: 0, bl: 2.5, br: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ struct CourseProgressScreenView: View {
VStack(spacing: 16) {
Image(systemName: "doc.text")
.font(.system(size: 48))
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.emptyStateIconColor)

Text(CourseLocalization.CourseContainer.Progress.noGradedAssignments)
.font(Theme.Fonts.titleMedium)
Expand Down
16 changes: 6 additions & 10 deletions Course/Course/Presentation/Progress/CourseProgressViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,14 @@ public class CourseProgressViewModel {
}

public func getAssignmentColor(for index: Int) -> Color {
guard let courseProgress = courseProgress else {
return Theme.Colors.textSecondary
}

if courseProgress.gradingPolicy.assignmentColors.isEmpty {
return Theme.Colors.accentColor
}
let hexColor = courseProgress?.gradingPolicy.assignmentColorHex(for: index)
?? CourseProgressGradingPolicy.assignmentColorHex(for: index, in: [])

let colorIndex = index % courseProgress.gradingPolicy.assignmentColors.count
let hexColor = courseProgress.gradingPolicy.assignmentColors[colorIndex]
let fallbackHexColor = CourseProgressGradingPolicy.assignmentColorHex(for: index, in: [])

return Color(hex: hexColor) ?? Theme.Colors.accentColor
return Color(hex: hexColor)
?? Color(hex: fallbackHexColor)
?? Theme.Colors.assignmentColor
}

public func getAllAssignmentProgressData() -> [String: AssignmentProgressData] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,11 @@ extension SegmentedProgressView {
percentGraded: 0.0
)

let color: Color
if !assignmentColors.isEmpty {
let colorIndex = index % assignmentColors.count
let hexColor = assignmentColors[colorIndex]
color = Color(hex: hexColor) ?? Theme.Colors.textSecondary
} else {
color = Theme.Colors.textSecondary
}
let hexColor = CourseProgressGradingPolicy.assignmentColorHex(for: index, in: assignmentColors)
let fallbackHexColor = CourseProgressGradingPolicy.assignmentColorHex(for: index, in: [])
let color = Color(hex: hexColor)
?? Color(hex: fallbackHexColor)
?? Theme.Colors.assignmentColor

let segment = ProgressSegment(
progress: progressData.pointsPercentage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct CourseUnitDropDownList<Content>: View where Content: View {
.background(Theme.Colors.background)
.clipShape(RoundedRectangle(cornerRadius: 10))
.frame(height: scrollViewHeight)
.shadow(color: Theme.Colors.textSecondary, radius: 4)
.shadow(color: Theme.Colors.shadowColor, radius: 4)

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct LessonProgressView: View {
.foregroundColor(
selected == viewModel.selectedLesson()
? .accentColor
: Theme.Colors.textSecondary
: Theme.Colors.progressSkip
)
}
Spacer()
Expand Down
2 changes: 1 addition & 1 deletion Course/Course/Presentation/Video/SubtitlesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public struct SubtitlesView: View {
.multilineTextAlignment(.leading)
.foregroundColor(subtitle.fromTo.contains(Date(milliseconds: currentTime))
? Theme.Colors.textPrimary
: Theme.Colors.textSecondary)
: Theme.Colors.textTertiary)

.onChange(of: currentTime, perform: { _ in
if subtitle.fromTo.contains(Date(milliseconds: currentTime)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,28 @@ final class CourseProgressViewModelTests: XCTestCase {
XCTAssertNotNil(allData["Exam"])
}

func testAssignmentColorsFallbackToDefaultPalette() {
XCTAssertEqual(
CourseProgressGradingPolicy.normalizedAssignmentColors(nil),
CourseProgressGradingPolicy.defaultAssignmentColors
)
XCTAssertEqual(
CourseProgressGradingPolicy.normalizedAssignmentColors([]),
CourseProgressGradingPolicy.defaultAssignmentColors
)
XCTAssertEqual(
CourseProgressGradingPolicy.assignmentColorHex(for: 9, in: []),
CourseProgressGradingPolicy.defaultAssignmentColors[0]
)

let gradingPolicy = CourseProgressGradingPolicy(
assignmentPolicies: [],
gradeRange: [:],
assignmentColors: []
)
XCTAssertEqual(gradingPolicy.assignmentColors, CourseProgressGradingPolicy.defaultAssignmentColors)
}

private func createMockCourseStructure(withDownloadableBlocks: Bool = false) -> CourseStructure {
let block = CourseBlock(
blockId: "block123",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct NoCoursesView: View {
CoreAssets.learnEmpty.swiftUIImage
.resizable()
.frame(width: 96, height: 96)
.foregroundStyle(Theme.Colors.textSecondaryLight)
.foregroundStyle(Theme.Colors.emptyStateIconColor)
Text(type.title)
.foregroundStyle(Theme.Colors.textPrimary)
.font(Theme.Fonts.titleMedium)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ public struct DiscoveryView: View {
// MARK: - Search fake field
HStack(spacing: 11) {
Image(systemName: "magnifyingglass")
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.textInputPlaceholderColor)
.padding(.leading, 16)
.padding(.top, 1)
.accessibilityIdentifier("search_image")
Text(DiscoveryLocalization.search)
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.textInputPlaceholderColor)
.accessibilityIdentifier("search_text")
Spacer()
}
Expand Down
2 changes: 1 addition & 1 deletion Downloads/Downloads/Presentation/AppDownloadsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public struct AppDownloadsView: View {
CoreAssets.learnEmpty.swiftUIImage
.resizable()
.frame(width: 96, height: 96)
.foregroundStyle(Theme.Colors.textSecondaryLight)
.foregroundStyle(Theme.Colors.emptyStateIconColor)
Text(DownloadsLocalization.Downloads.NoCoursesToDownload.title)
.foregroundStyle(Theme.Colors.textPrimary)
.font(Theme.Fonts.titleMedium)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,19 @@ struct DownloadCourseCell: View {

HStack {
CoreAssets.startDownloading.swiftUIImage
.foregroundStyle(Theme.Colors.textSecondary)
.foregroundStyle(Theme.Colors.secondaryContentColor)
Text(DownloadsLocalization.Downloads.Cell.available(availableFormatted))
.font(Theme.Fonts.labelLarge)
.foregroundStyle(Theme.Colors.textSecondary)
.foregroundStyle(Theme.Colors.secondaryContentColor)
}
}
case .notDownloaded, .loadingStructure:
HStack {
CoreAssets.startDownloading.swiftUIImage
.foregroundStyle(Theme.Colors.textSecondary)
.foregroundStyle(Theme.Colors.secondaryContentColor)
Text(DownloadsLocalization.Downloads.Cell.available(availableFormatted))
.font(Theme.Fonts.labelLarge)
.foregroundStyle(Theme.Colors.textSecondary)
.foregroundStyle(Theme.Colors.secondaryContentColor)
}
}
}
Expand All @@ -248,7 +248,7 @@ struct DownloadCourseCell: View {
ZStack(alignment: .leading) {
GeometryReader { geometry in
RoundedRectangle(cornerRadius: 4)
.fill(Theme.Colors.textSecondary.opacity(0.5))
.fill(Theme.Colors.courseProgressBG)
.frame(width: geometry.size.width, height: 8)

if progressPercentage > 0 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public struct CoursesToSyncView: View {
CoreAssets.learnEmpty.swiftUIImage
.resizable()
.frame(width: 96, height: 96)
.foregroundStyle(Theme.Colors.textSecondaryLight)
.foregroundStyle(Theme.Colors.emptyStateIconColor)
Text(ProfileLocalization.Sync.noSynced)
.foregroundStyle(Theme.Colors.textPrimary)
.font(Theme.Fonts.titleMedium)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct DeleteAccountView: View {
// MARK: Password
Group {
Text(ProfileLocalization.DeleteAccount.password)
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.textPrimary)
.font(Theme.Fonts.labelLarge)
.multilineTextAlignment(.leading)
.padding(.top, 16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct ProfileBottomSheet: View {
VStack(alignment: .center, spacing: 4) {
HStack(alignment: .center) {
RoundedRectangle(cornerRadius: 2, style: .circular)
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.secondaryContentColor)
.frame(width: 31, height: 4)
.padding(.top, 4)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ struct ProfileSupportInfoView: View {
.accessibilityLabel(viewModel.title)
Rectangle()
.frame(height: 1)
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.cardViewStroke)
}

@ViewBuilder
Expand Down Expand Up @@ -198,7 +198,7 @@ struct ProfileSupportInfoView: View {
.accessibilityIdentifier(identifier)
Rectangle()
.frame(height: 1)
.foregroundColor(Theme.Colors.textSecondary)
.foregroundColor(Theme.Colors.cardViewStroke)
}

@ViewBuilder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.392",
"green" : "0.286",
"red" : "0.239"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0.682",
"green" : "0.608",
"red" : "0.557"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Loading