Added disclosure indicators.
This commit is contained in:
parent
50822700c0
commit
bb20e4d2a2
|
@ -18,6 +18,20 @@ struct AppAssets {
|
||||||
return RSImage(named: "circleOpenImage")!
|
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 = {
|
static var cogImage: RSImage = {
|
||||||
return RSImage(named: "cogImage")!
|
return RSImage(named: "cogImage")!
|
||||||
}()
|
}()
|
||||||
|
@ -34,8 +48,8 @@ struct AppAssets {
|
||||||
return UIColor(named: "masterFolderColor")!
|
return UIColor(named: "masterFolderColor")!
|
||||||
}()
|
}()
|
||||||
|
|
||||||
static var masterFolderImage: UIImage = {
|
static var masterFolderImage: RSImage = {
|
||||||
let image = UIImage(named: "folderImage")!
|
let image = RSImage(named: "folderImage")!
|
||||||
return image.maskWithColor(color: AppAssets.masterFolderColor)!
|
return image.maskWithColor(color: AppAssets.masterFolderColor)!
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,8 @@ import RSTree
|
||||||
|
|
||||||
class MasterTableViewCell : UITableViewCell {
|
class MasterTableViewCell : UITableViewCell {
|
||||||
|
|
||||||
|
private var accessoryButton: UIButton?
|
||||||
|
|
||||||
override var accessibilityLabel: String? {
|
override var accessibilityLabel: String? {
|
||||||
set {}
|
set {}
|
||||||
get {
|
get {
|
||||||
|
@ -102,16 +104,37 @@ class MasterTableViewCell : UITableViewCell {
|
||||||
layoutWith(layout)
|
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 {
|
private extension MasterTableViewCell {
|
||||||
|
|
||||||
func commonInit() {
|
func commonInit() {
|
||||||
|
addAccessoryView()
|
||||||
addSubviewAtInit(unreadCountView)
|
addSubviewAtInit(unreadCountView)
|
||||||
addSubviewAtInit(faviconImageView)
|
addSubviewAtInit(faviconImageView)
|
||||||
addSubviewAtInit(titleView)
|
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) {
|
func addSubviewAtInit(_ view: UIView) {
|
||||||
addSubview(view)
|
addSubview(view)
|
||||||
view.translatesAutoresizingMaskIntoConstraints = false
|
view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
|
|
@ -17,13 +17,23 @@ struct MasterTableViewCellLayout {
|
||||||
private static let unreadCountMarginLeft = CGFloat(integerLiteral: 8)
|
private static let unreadCountMarginLeft = CGFloat(integerLiteral: 8)
|
||||||
private static let unreadCountMarginRight = CGFloat(integerLiteral: 8)
|
private static let unreadCountMarginRight = CGFloat(integerLiteral: 8)
|
||||||
|
|
||||||
|
private static let chevronWidth = CGFloat(integerLiteral: 40)
|
||||||
|
|
||||||
let faviconRect: CGRect
|
let faviconRect: CGRect
|
||||||
let titleRect: CGRect
|
let titleRect: CGRect
|
||||||
let unreadCountRect: CGRect
|
let unreadCountRect: CGRect
|
||||||
|
|
||||||
init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool) {
|
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
|
var rFavicon = CGRect.zero
|
||||||
if shouldShowImage {
|
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 avatarMarginLeft = CGFloat(integerLiteral: 8)
|
||||||
static let avatarCornerRadius = CGFloat(integerLiteral: 4)
|
static let avatarCornerRadius = CGFloat(integerLiteral: 4)
|
||||||
|
|
||||||
|
static let chevronWidth = CGFloat(integerLiteral: 28)
|
||||||
|
|
||||||
let width: CGFloat
|
let width: CGFloat
|
||||||
let height: CGFloat
|
let height: CGFloat
|
||||||
let feedNameRect: CGRect
|
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) {
|
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.feedNameRect = feedNameRect
|
||||||
self.dateRect = dateRect
|
self.dateRect = dateRect
|
||||||
self.titleRect = titleRect
|
self.titleRect = titleRect
|
||||||
|
@ -76,6 +78,8 @@ struct MasterTimelineCellLayout {
|
||||||
|
|
||||||
init(width: CGFloat, height: CGFloat, cellData: MasterTimelineCellData, hasAvatar: Bool) {
|
init(width: CGFloat, height: CGFloat, cellData: MasterTimelineCellData, hasAvatar: Bool) {
|
||||||
|
|
||||||
|
let width = width - MasterTimelineCellLayout.chevronWidth
|
||||||
|
|
||||||
// If height == 0.0, then height is calculated.
|
// If height == 0.0, then height is calculated.
|
||||||
|
|
||||||
let showAvatar = hasAvatar && cellData.showAvatar
|
let showAvatar = hasAvatar && cellData.showAvatar
|
||||||
|
|
|
@ -107,6 +107,7 @@ private extension MasterTimelineTableViewCell {
|
||||||
|
|
||||||
func commonInit() {
|
func commonInit() {
|
||||||
|
|
||||||
|
addAccessoryView()
|
||||||
addSubviewAtInit(titleView, hidden: false)
|
addSubviewAtInit(titleView, hidden: false)
|
||||||
addSubviewAtInit(summaryView, hidden: true)
|
addSubviewAtInit(summaryView, hidden: true)
|
||||||
addSubviewAtInit(textView, hidden: true)
|
addSubviewAtInit(textView, hidden: true)
|
||||||
|
@ -118,6 +119,10 @@ private extension MasterTimelineTableViewCell {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func addAccessoryView() {
|
||||||
|
accessoryView = UIImageView(image: AppAssets.chevronRightImage)
|
||||||
|
}
|
||||||
|
|
||||||
func updatedLayoutRects() -> MasterTimelineCellLayout {
|
func updatedLayoutRects() -> MasterTimelineCellLayout {
|
||||||
|
|
||||||
return MasterTimelineCellLayout(width: bounds.width, height: bounds.height, cellData: cellData, hasAvatar: avatarImageView.image != nil)
|
return MasterTimelineCellLayout(width: bounds.width, height: bounds.height, cellData: cellData, hasAvatar: avatarImageView.image != nil)
|
||||||
|
|
Loading…
Reference in New Issue