Added disclosure indicators.

This commit is contained in:
Maurice Parker
2019-04-17 10:15:44 -05:00
parent 50822700c0
commit bb20e4d2a2
10 changed files with 105 additions and 5 deletions

View File

@@ -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)

View File

@@ -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 {