Added disclosure indicators.
This commit is contained in:
parent
50822700c0
commit
bb20e4d2a2
|
@ -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)!
|
||||
}()
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ import RSTree
|
|||
|
||||
class MasterTableViewCell : UITableViewCell {
|
||||
|
||||
private var accessoryButton: UIButton?
|
||||
|
||||
override var accessibilityLabel: String? {
|
||||
set {}
|
||||
get {
|
||||
|
@ -102,16 +104,37 @@ 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)
|
||||
view.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "chevronDown.pdf"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "universal",
|
||||
"filename" : "chevronRight.pdf"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -107,6 +107,7 @@ private extension MasterTimelineTableViewCell {
|
|||
|
||||
func commonInit() {
|
||||
|
||||
addAccessoryView()
|
||||
addSubviewAtInit(titleView, hidden: false)
|
||||
addSubviewAtInit(summaryView, hidden: true)
|
||||
addSubviewAtInit(textView, hidden: true)
|
||||
|
@ -118,6 +119,10 @@ private extension MasterTimelineTableViewCell {
|
|||
|
||||
}
|
||||
|
||||
func addAccessoryView() {
|
||||
accessoryView = UIImageView(image: AppAssets.chevronRightImage)
|
||||
}
|
||||
|
||||
func updatedLayoutRects() -> MasterTimelineCellLayout {
|
||||
|
||||
return MasterTimelineCellLayout(width: bounds.width, height: bounds.height, cellData: cellData, hasAvatar: avatarImageView.image != nil)
|
||||
|
|
Loading…
Reference in New Issue