From 21aaf71cbf8066886e70be6769bd519331f32b0b Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Fri, 25 Oct 2019 15:52:32 -0500 Subject: [PATCH] Update timeline theme. Issue #1169 --- iOS/AppAssets.swift | 4 +++ ...asterTimelineAccessibilityCellLayout.swift | 2 +- .../MasterTimelineDefaultCellLayout.swift | 2 +- .../Cell/MasterTimelineTableViewCell.swift | 15 ++++++++- .../Contents.json | 33 +++++++++++++++++++ 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 iOS/Resources/Assets.xcassets/timelineBackgroundColor.colorset/Contents.json diff --git a/iOS/AppAssets.swift b/iOS/AppAssets.swift index e054ec245..77219db2c 100644 --- a/iOS/AppAssets.swift +++ b/iOS/AppAssets.swift @@ -157,6 +157,10 @@ struct AppAssets { return UIImage(systemName: "star.fill")! }() + static var timelineBackgroundColor: UIColor = { + return UIColor(named: "timelineBackgroundColor")! + }() + static var timelineStarImage: UIImage = { let image = UIImage(systemName: "star.fill")! return image.withTintColor(AppAssets.starColor, renderingMode: .alwaysOriginal) diff --git a/iOS/MasterTimeline/Cell/MasterTimelineAccessibilityCellLayout.swift b/iOS/MasterTimeline/Cell/MasterTimelineAccessibilityCellLayout.swift index 31e8c5bc6..9640660ae 100644 --- a/iOS/MasterTimeline/Cell/MasterTimelineAccessibilityCellLayout.swift +++ b/iOS/MasterTimeline/Cell/MasterTimelineAccessibilityCellLayout.swift @@ -35,7 +35,7 @@ struct MasterTimelineAccessibilityCellLayout: MasterTimelineCellLayout { currentPoint.x += MasterTimelineDefaultCellLayout.unreadCircleDimension + MasterTimelineDefaultCellLayout.unreadCircleMarginRight // Separator Insets - self.separatorInsets = UIEdgeInsets(top: 0, left: currentPoint.x, bottom: 0, right: 0) + self.separatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) // Avatar if cellData.showAvatar { diff --git a/iOS/MasterTimeline/Cell/MasterTimelineDefaultCellLayout.swift b/iOS/MasterTimeline/Cell/MasterTimelineDefaultCellLayout.swift index f7ca315c5..6e9d82a4a 100644 --- a/iOS/MasterTimeline/Cell/MasterTimelineDefaultCellLayout.swift +++ b/iOS/MasterTimeline/Cell/MasterTimelineDefaultCellLayout.swift @@ -68,7 +68,7 @@ struct MasterTimelineDefaultCellLayout: MasterTimelineCellLayout { currentPoint.x += MasterTimelineDefaultCellLayout.unreadCircleDimension + MasterTimelineDefaultCellLayout.unreadCircleMarginRight // Separator Insets - self.separatorInsets = UIEdgeInsets(top: 0, left: currentPoint.x, bottom: 0, right: 0) + self.separatorInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) // Avatar if cellData.showAvatar { diff --git a/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift b/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift index 0a240370e..63249d581 100644 --- a/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift +++ b/iOS/MasterTimeline/Cell/MasterTimelineTableViewCell.swift @@ -23,6 +23,12 @@ class MasterTimelineTableViewCell: VibrantTableViewCell { return NonIntrinsicImageView(image: AppAssets.timelineStarImage) }() + private let separatorAccent: UIView = { + let view = UIView() + view.backgroundColor = UIColor.white + return view + }() + var cellData: MasterTimelineCellData! { didSet { updateSubviews() @@ -43,6 +49,8 @@ class MasterTimelineTableViewCell: VibrantTableViewCell { summaryView.highlightedTextColor = highlightedTextColor dateView.highlightedTextColor = highlightedTextColor feedNameView.highlightedTextColor = highlightedTextColor + + backgroundColor = AppAssets.timelineBackgroundColor } override var frame: CGRect { @@ -82,6 +90,10 @@ class MasterTimelineTableViewCell: VibrantTableViewCell { separatorInset = layout.separatorInsets + if traitCollection.userInterfaceStyle == .light { + let separatorAccentRect = CGRect(x: safeAreaInsets.left, y: frame.height - 2, width: frame.width - safeAreaInsets.right - safeAreaInsets.left, height: 1) + separatorAccent.setFrameIfNotEqual(separatorAccentRect) + } } func setAvatarImage(_ image: UIImage) { @@ -137,7 +149,8 @@ private extension MasterTimelineTableViewCell { addSubviewAtInit(feedNameView, hidden: true) addSubviewAtInit(avatarView, hidden: true) addSubviewAtInit(starView, hidden: true) - + addSubviewAtInit(separatorAccent, hidden: false) + } func updatedLayout(width: CGFloat) -> MasterTimelineCellLayout { diff --git a/iOS/Resources/Assets.xcassets/timelineBackgroundColor.colorset/Contents.json b/iOS/Resources/Assets.xcassets/timelineBackgroundColor.colorset/Contents.json new file mode 100644 index 000000000..2cc5212b8 --- /dev/null +++ b/iOS/Resources/Assets.xcassets/timelineBackgroundColor.colorset/Contents.json @@ -0,0 +1,33 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "247", + "alpha" : "1.000", + "blue" : "247", + "green" : "247" + } + } + }, + { + "idiom" : "universal", + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "platform" : "ios", + "reference" : "systemBackgroundColor" + } + } + ] +} \ No newline at end of file