Skip to content

Commit

Permalink
Correct handling of empty teacher labels
Browse files Browse the repository at this point in the history
  • Loading branch information
mathebox committed Jan 27, 2022
1 parent d0dc4d8 commit 030dd58
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion iOS/Views/CourseCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ class CourseCell: UICollectionViewCell {
}
}

var forceEmptyTeachersLabel: Bool {
switch self {
case .courseList:
return false
case .courseOverview:
return true
}
}

func colorWithFallback(to fallbackColor: UIColor) -> UIColor {
if case let .courseList(configuration) = self {
return configuration.colorWithFallback(to: fallbackColor)
Expand Down Expand Up @@ -111,7 +120,11 @@ class CourseCell: UICollectionViewCell {
self.teacherLabel.numberOfLines = configuration.showMultilineLabels ? 0 : 1

self.titleLabel.text = course.title
self.teacherLabel.text = Brand.default.features.showCourseTeachers ? course.teachers : nil
self.teacherLabel.text = {
guard Brand.default.features.showCourseTeachers else { return nil }
if course.teachers?.isEmpty ?? true, configuration.forceEmptyTeachersLabel { return " " }
return course.teachers
}()
self.teacherLabel.isHidden = !Brand.default.features.showCourseTeachers
self.languageLabel.text = course.language.flatMap(LanguageLocalizer.nativeDisplayName(for:))
self.dateLabel.text = CoursePeriodFormatter.string(from: course)
Expand Down

0 comments on commit 030dd58

Please sign in to comment.