Skip to content

Commit

Permalink
Do not use deprecated channel color
Browse files Browse the repository at this point in the history
Remove code for determining suitable channel color
  • Loading branch information
mathebox committed Feb 20, 2024
1 parent e6763de commit c456b35
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 61 deletions.
3 changes: 1 addition & 2 deletions Common/Data/Model/Channel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public final class Channel: NSManagedObject {
@NSManaged public var id: String
@NSManaged public var title: String?
@NSManaged public var channelDescription: String?
@NSManaged public var colorString: String?
@available(*, deprecated, message: "Deprecated in API") @NSManaged public var colorString: String?
@NSManaged public var position: Int16
@NSManaged public var imageURL: URL?
@NSManaged public var stageStream: VideoStream?
Expand All @@ -35,7 +35,6 @@ extension Channel: JSONAPIPullable {
let attributes = try object.value(for: "attributes") as JSON
self.title = try attributes.value(for: "title")
self.channelDescription = try attributes.value(for: "description")
self.colorString = try attributes.value(for: "color")
self.position = try attributes.value(for: "position")
self.imageURL = try attributes.failsafeURL(for: "mobile_image_url")
self.stageStream = try attributes.value(for: "stage_stream") ?? self.stageStream
Expand Down
27 changes: 0 additions & 27 deletions iOS/Data/Model/Channel+Color.swift

This file was deleted.

8 changes: 0 additions & 8 deletions iOS/Helpers/CourseListConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,4 @@ enum CourseListConfiguration {
}
}

func colorWithFallback(to fallbackColor: UIColor) -> UIColor {
if case let .coursesInChannel(channel) = self {
return channel.colorWithFallback(to: fallbackColor)
}

return fallbackColor
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ class CoursePreviewViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()

let accentColor = self.listConfiguration.colorWithFallback(to: Brand.default.colors.secondary)
self.courseImageView.backgroundColor = accentColor
self.teacherLabel.textColor = accentColor
self.courseImageView.backgroundColor = Brand.default.colors.secondary
self.teacherLabel.textColor = Brand.default.colors.secondary

self.courseImageView.sd_imageTransition = .fade
self.courseImageView.sd_setImage(with: self.course.imageURL)
Expand Down
2 changes: 1 addition & 1 deletion iOS/Views/ChannelCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ChannelCell: UICollectionViewCell {
self.channelImage.sd_setImage(with: channel.imageURL, placeholderImage: nil)

self.titleLabel.text = channel.title
self.titleLabel.textColor = channel.colorWithFallback(to: ColorCompatibility.label)
self.titleLabel.textColor = Brand.default.colors.primary

let markDown = MarkdownHelper.string(for: channel.channelDescription ?? "")
self.descriptionLabel.text = markDown.replacingOccurrences(of: "\n", with: " ")
Expand Down
2 changes: 1 addition & 1 deletion iOS/Views/ChannelHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChannelHeaderView: UICollectionReusableView {
}

func configure(for channel: Channel) {
self.imageView.backgroundColor = channel.colorWithFallback(to: Brand.default.colors.window)
self.imageView.backgroundColor = Brand.default.colors.window
self.imageView.sd_setImage(with: channel.imageURL, placeholderImage: nil)
self.descriptionLabel.text = MarkdownHelper.string(for: channel.channelDescription ?? "").trimmingCharacters(in: .whitespacesAndNewlines)

Expand Down
18 changes: 4 additions & 14 deletions iOS/Views/CourseCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ class CourseCell: UICollectionViewCell {
}
}

func colorWithFallback(to fallbackColor: UIColor) -> UIColor {
if case let .courseList(configuration) = self {
return configuration.colorWithFallback(to: fallbackColor)
}

return fallbackColor
}

}

@IBOutlet private weak var shadowView: UIView!
Expand Down Expand Up @@ -106,12 +98,10 @@ class CourseCell: UICollectionViewCell {
}

func configure(_ course: Course, for configuration: Configuration) {
let accentColor = configuration.colorWithFallback(to: Brand.default.colors.secondary)

self.courseImage.backgroundColor = accentColor
self.statusView.backgroundColor = accentColor
self.statusLabel.backgroundColor = accentColor
self.teacherLabel.textColor = accentColor
self.courseImage.backgroundColor = Brand.default.colors.secondary
self.statusView.backgroundColor = Brand.default.colors.secondary
self.statusLabel.backgroundColor = Brand.default.colors.secondary
self.teacherLabel.textColor = Brand.default.colors.secondary

self.courseImage.image = nil // Avoid old images on cell reuse when new image can not be loaded
self.courseImage.sd_setImage(with: course.imageURL, placeholderImage: nil)
Expand Down
2 changes: 1 addition & 1 deletion iOS/Views/CourseHeaderView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CourseHeaderView: UICollectionReusableView {

func configure(_ section: NSFetchedResultsSectionInfo, for configuration: CourseListConfiguration) {
self.titleView.text = section.name
self.titleView.textColor = configuration.colorWithFallback(to: Brand.default.colors.secondary)
self.titleView.textColor = Brand.default.colors.secondary
}

func configure(withText headerText: String) {
Expand Down
4 changes: 0 additions & 4 deletions xikolo-ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
50092A8C237D889700A1503F /* ChannelListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50092A8B237D889700A1503F /* ChannelListViewController.swift */; };
50092A90237D89BD00A1503F /* ChannelCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50092A8F237D89BD00A1503F /* ChannelCell.swift */; };
50092A92237D8E3C00A1503F /* ChannelCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 50092A91237D8E3B00A1503F /* ChannelCell.xib */; };
50092A94237DC20C00A1503F /* Channel+Color.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50092A93237DC20C00A1503F /* Channel+Color.swift */; };
500B907F2254B854000B0D05 /* DownloadedContentHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 500B907E2254B854000B0D05 /* DownloadedContentHelper.swift */; };
500C4D48278D73BE00C91295 /* (null) in Sources */ = {isa = PBXBuildFile; };
5011D6AF24EEADA5004961A0 /* CourseOverview.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 5011D6B124EEADA5004961A0 /* CourseOverview.storyboard */; };
Expand Down Expand Up @@ -712,7 +711,6 @@
50092A8B237D889700A1503F /* ChannelListViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelListViewController.swift; sourceTree = "<group>"; };
50092A8F237D89BD00A1503F /* ChannelCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelCell.swift; sourceTree = "<group>"; };
50092A91237D8E3B00A1503F /* ChannelCell.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ChannelCell.xib; sourceTree = "<group>"; };
50092A93237DC20C00A1503F /* Channel+Color.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Channel+Color.swift"; sourceTree = "<group>"; };
500B907E2254B854000B0D05 /* DownloadedContentHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadedContentHelper.swift; sourceTree = "<group>"; };
500C361724B61BFB004DD157 /* xikolo 12.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "xikolo 12.xcdatamodel"; sourceTree = "<group>"; };
500C4D49278D8E6C00C91295 /* xikolo 14.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = "xikolo 14.xcdatamodel"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1600,7 +1598,6 @@
50F3DD47245859520008CE27 /* Persistence */,
5019A7671F20AD4F008C8138 /* RichText+Preloading.swift */,
5019A7621F20ACE6008C8138 /* Video+Preloading.swift */,
50092A93237DC20C00A1503F /* Channel+Color.swift */,
503988782167A04200F9043B /* CourseItem+DetailedContent.swift */,
503CEE932174EEE200F34694 /* CourseItem+AvailableContent.swift */,
502F3DDC209C35ED006B3DAC /* CourseContent+image.swift */,
Expand Down Expand Up @@ -3429,7 +3426,6 @@
50CF1FA820DCDBFC0011BFE9 /* CourseAreaListViewController.swift in Sources */,
507CC05B21788487008819FE /* PillView.swift in Sources */,
50B1CC51256CF48800D651C6 /* PersistenceManager+BrightFutures.swift in Sources */,
50092A94237DC20C00A1503F /* Channel+Color.swift in Sources */,
70893B5621C3D1F600AF22E3 /* LTIExerciseHintViewController.swift in Sources */,
50CF1FB120DCDBFC0011BFE9 /* UITableViewCell+enable.swift in Sources */,
50CF1FB320DCDBFC0011BFE9 /* DetailedCourseItemContent.swift in Sources */,
Expand Down

0 comments on commit c456b35

Please sign in to comment.