diff --git a/iOS/AppAssets.swift b/iOS/AppAssets.swift index 514602341..459c97cd3 100644 --- a/iOS/AppAssets.swift +++ b/iOS/AppAssets.swift @@ -18,6 +18,20 @@ struct AppAssets { return RSImage(named: "circleOpenImage")! }() + static var chevronDisclosureColor: UIColor = { + return UIColor(named: "chevronDisclosureColor")! + }() + + static var chevronDownImage: RSImage = { + let image = RSImage(named: "chevronDownImage")! + return image.maskWithColor(color: AppAssets.chevronDisclosureColor)! + }() + + static var chevronRightImage: RSImage = { + let image = RSImage(named: "chevronRightImage")! + return image.maskWithColor(color: AppAssets.chevronDisclosureColor)! + }() + static var cogImage: RSImage = { return RSImage(named: "cogImage")! }() @@ -34,8 +48,8 @@ struct AppAssets { return UIColor(named: "masterFolderColor")! }() - static var masterFolderImage: UIImage = { - let image = UIImage(named: "folderImage")! + static var masterFolderImage: RSImage = { + let image = RSImage(named: "folderImage")! return image.maskWithColor(color: AppAssets.masterFolderColor)! }() diff --git a/iOS/Master/Cell/MasterTableViewCell.swift b/iOS/Master/Cell/MasterTableViewCell.swift index b2bc682eb..f83ae2d93 100644 --- a/iOS/Master/Cell/MasterTableViewCell.swift +++ b/iOS/Master/Cell/MasterTableViewCell.swift @@ -13,6 +13,8 @@ import RSTree class MasterTableViewCell : UITableViewCell { + private var accessoryButton: UIButton? + override var accessibilityLabel: String? { set {} get { @@ -102,15 +104,36 @@ class MasterTableViewCell : UITableViewCell { layoutWith(layout) } + @objc func buttonPressed(_ sender: UIButton) { + + if sender.imageView?.image == AppAssets.chevronRightImage { + sender.setImage(AppAssets.chevronDownImage, for: .normal) + } else { + sender.setImage(AppAssets.chevronRightImage, for: .normal) + } + + + } } private extension MasterTableViewCell { func commonInit() { + addAccessoryView() addSubviewAtInit(unreadCountView) addSubviewAtInit(faviconImageView) addSubviewAtInit(titleView) } + + func addAccessoryView() { + let button = UIButton(type: .roundedRect) + button.frame = CGRect(x: 0, y: 0, width: 15.0, height: 15.0) + button.setImage(AppAssets.chevronRightImage, for: .normal) + button.tintColor = AppAssets.chevronDisclosureColor + button.addTarget(self, action: #selector(buttonPressed(_:)), for: UIControl.Event.touchUpInside) + accessoryButton = button + accessoryView = button + } func addSubviewAtInit(_ view: UIView) { addSubview(view) diff --git a/iOS/Master/Cell/MasterTableViewCellLayout.swift b/iOS/Master/Cell/MasterTableViewCellLayout.swift index 908283847..b1e15aed8 100644 --- a/iOS/Master/Cell/MasterTableViewCellLayout.swift +++ b/iOS/Master/Cell/MasterTableViewCellLayout.swift @@ -17,13 +17,23 @@ struct MasterTableViewCellLayout { private static let unreadCountMarginLeft = CGFloat(integerLiteral: 8) private static let unreadCountMarginRight = CGFloat(integerLiteral: 8) + private static let chevronWidth = CGFloat(integerLiteral: 40) + let faviconRect: CGRect let titleRect: CGRect let unreadCountRect: CGRect init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool) { - let bounds = CGRect(x: 0.0, y: 0.0, width: floor(cellSize.width), height: floor(cellSize.height)) + let adjustedWidth: CGFloat = { + if showingEditingControl { + return floor(cellSize.width) + } else { + return floor(cellSize.width) - MasterTableViewCellLayout.chevronWidth + } + }() + + let bounds = CGRect(x: 0.0, y: 0.0, width: adjustedWidth, height: floor(cellSize.height)) var rFavicon = CGRect.zero if shouldShowImage { diff --git a/iOS/Resources/Assets.xcassets/chevronDisclosureColor.colorset/Contents.json b/iOS/Resources/Assets.xcassets/chevronDisclosureColor.colorset/Contents.json new file mode 100644 index 000000000..faf582c66 --- /dev/null +++ b/iOS/Resources/Assets.xcassets/chevronDisclosureColor.colorset/Contents.json @@ -0,0 +1,20 @@ +{ + "info" : { + "version" : 1, + "author" : "xcode" + }, + "colors" : [ + { + "idiom" : "universal", + "color" : { + "color-space" : "srgb", + "components" : { + "red" : "200", + "alpha" : "1.000", + "blue" : "200", + "green" : "200" + } + } + } + ] +} \ No newline at end of file diff --git a/iOS/Resources/Assets.xcassets/chevronDownImage.imageset/Contents.json b/iOS/Resources/Assets.xcassets/chevronDownImage.imageset/Contents.json new file mode 100644 index 000000000..4e4464069 --- /dev/null +++ b/iOS/Resources/Assets.xcassets/chevronDownImage.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "chevronDown.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS/Resources/Assets.xcassets/chevronDownImage.imageset/chevronDown.pdf b/iOS/Resources/Assets.xcassets/chevronDownImage.imageset/chevronDown.pdf new file mode 100644 index 000000000..60ce49f76 Binary files /dev/null and b/iOS/Resources/Assets.xcassets/chevronDownImage.imageset/chevronDown.pdf differ diff --git a/iOS/Resources/Assets.xcassets/chevronRightImage.imageset/Contents.json b/iOS/Resources/Assets.xcassets/chevronRightImage.imageset/Contents.json new file mode 100644 index 000000000..9e7a503f0 --- /dev/null +++ b/iOS/Resources/Assets.xcassets/chevronRightImage.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "chevronRight.pdf" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/iOS/Resources/Assets.xcassets/chevronRightImage.imageset/chevronRight.pdf b/iOS/Resources/Assets.xcassets/chevronRightImage.imageset/chevronRight.pdf new file mode 100644 index 000000000..34cdd6e57 Binary files /dev/null and b/iOS/Resources/Assets.xcassets/chevronRightImage.imageset/chevronRight.pdf differ diff --git a/iOS/Timeline/Cell/MasterTimelineCellLayout.swift b/iOS/Timeline/Cell/MasterTimelineCellLayout.swift index 280b824cc..8d0feabd2 100644 --- a/iOS/Timeline/Cell/MasterTimelineCellLayout.swift +++ b/iOS/Timeline/Cell/MasterTimelineCellLayout.swift @@ -39,6 +39,8 @@ struct MasterTimelineCellLayout { static let avatarMarginLeft = CGFloat(integerLiteral: 8) static let avatarCornerRadius = CGFloat(integerLiteral: 4) + static let chevronWidth = CGFloat(integerLiteral: 28) + let width: CGFloat let height: CGFloat let feedNameRect: CGRect @@ -54,7 +56,7 @@ struct MasterTimelineCellLayout { init(width: CGFloat, height: CGFloat, feedNameRect: CGRect, dateRect: CGRect, titleRect: CGRect, numberOfLinesForTitle: Int, summaryRect: CGRect, textRect: CGRect, unreadIndicatorRect: CGRect, starRect: CGRect, avatarImageRect: CGRect, paddingBottom: CGFloat) { - self.width = width + self.width = width - MasterTimelineCellLayout.chevronWidth self.feedNameRect = feedNameRect self.dateRect = dateRect self.titleRect = titleRect @@ -76,6 +78,8 @@ struct MasterTimelineCellLayout { init(width: CGFloat, height: CGFloat, cellData: MasterTimelineCellData, hasAvatar: Bool) { + let width = width - MasterTimelineCellLayout.chevronWidth + // If height == 0.0, then height is calculated. let showAvatar = hasAvatar && cellData.showAvatar diff --git a/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift b/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift index 44357c1a8..41cc9631f 100644 --- a/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift +++ b/iOS/Timeline/Cell/MasterTimelineTableViewCell.swift @@ -107,6 +107,7 @@ private extension MasterTimelineTableViewCell { func commonInit() { + addAccessoryView() addSubviewAtInit(titleView, hidden: false) addSubviewAtInit(summaryView, hidden: true) addSubviewAtInit(textView, hidden: true) @@ -117,7 +118,11 @@ private extension MasterTimelineTableViewCell { addSubviewAtInit(starView, hidden: true) } - + + func addAccessoryView() { + accessoryView = UIImageView(image: AppAssets.chevronRightImage) + } + func updatedLayoutRects() -> MasterTimelineCellLayout { return MasterTimelineCellLayout(width: bounds.width, height: bounds.height, cellData: cellData, hasAvatar: avatarImageView.image != nil)