Fix editing and reorder cell rendering issues.
This commit is contained in:
parent
f2191f1dcc
commit
a4b30793a8
@ -115,12 +115,12 @@ class MasterTableViewCell : UITableViewCell {
|
|||||||
|
|
||||||
override func willTransition(to state: UITableViewCell.StateMask) {
|
override func willTransition(to state: UITableViewCell.StateMask) {
|
||||||
super.willTransition(to: state)
|
super.willTransition(to: state)
|
||||||
showingEditControl = state == .showingEditControl
|
showingEditControl = state.contains(.showingEditControl)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func layoutSubviews() {
|
override func layoutSubviews() {
|
||||||
super.layoutSubviews()
|
super.layoutSubviews()
|
||||||
let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indent, shouldShowDisclosure: true)
|
let layout = MasterTableViewCellLayout(cellSize: bounds.size, shouldShowImage: shouldShowImage, label: titleView, unreadCountView: unreadCountView, showingEditingControl: showingEditControl, indent: indent, shouldShowDisclosure: !showsReorderControl)
|
||||||
layoutWith(layout)
|
layoutWith(layout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ import RSCore
|
|||||||
|
|
||||||
struct MasterTableViewCellLayout {
|
struct MasterTableViewCellLayout {
|
||||||
|
|
||||||
|
private static let indent = CGFloat(integerLiteral: 20)
|
||||||
|
private static let editingControlIndent = CGFloat(integerLiteral: 40)
|
||||||
private static let imageSize = CGSize(width: 16, height: 16)
|
private static let imageSize = CGSize(width: 16, height: 16)
|
||||||
private static let marginLeft = CGFloat(integerLiteral: 8)
|
private static let marginLeft = CGFloat(integerLiteral: 8)
|
||||||
private static let imageMarginRight = CGFloat(integerLiteral: 8)
|
private static let imageMarginRight = CGFloat(integerLiteral: 8)
|
||||||
@ -25,14 +27,20 @@ struct MasterTableViewCellLayout {
|
|||||||
|
|
||||||
init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool, indent: Bool, shouldShowDisclosure: Bool) {
|
init(cellSize: CGSize, shouldShowImage: Bool, label: UILabel, unreadCountView: MasterUnreadCountView, showingEditingControl: Bool, indent: Bool, shouldShowDisclosure: Bool) {
|
||||||
|
|
||||||
let bounds = CGRect(x: 0.0, y: 0.0, width: floor(cellSize.width), height: floor(cellSize.height))
|
var initialIndent = MasterTableViewCellLayout.marginLeft
|
||||||
|
if indent {
|
||||||
|
initialIndent += MasterTableViewCellLayout.indent
|
||||||
|
}
|
||||||
|
if showingEditingControl {
|
||||||
|
initialIndent += MasterTableViewCellLayout.editingControlIndent
|
||||||
|
}
|
||||||
|
|
||||||
|
let bounds = CGRect(x: initialIndent, y: 0.0, width: floor(cellSize.width - initialIndent), height: floor(cellSize.height))
|
||||||
|
|
||||||
// Favicon
|
// Favicon
|
||||||
var rFavicon = CGRect.zero
|
var rFavicon = CGRect.zero
|
||||||
if shouldShowImage {
|
if shouldShowImage {
|
||||||
var indentX = showingEditingControl ? MasterTableViewCellLayout.marginLeft + 40 : MasterTableViewCellLayout.marginLeft
|
rFavicon = CGRect(x: bounds.origin.x, y: 0.0, width: MasterTableViewCellLayout.imageSize.width, height: MasterTableViewCellLayout.imageSize.height)
|
||||||
indentX = indent ? indentX + 20 : indentX
|
|
||||||
rFavicon = CGRect(x: indentX, y: 0.0, width: MasterTableViewCellLayout.imageSize.width, height: MasterTableViewCellLayout.imageSize.height)
|
|
||||||
rFavicon = MasterTableViewCellLayout.centerVertically(rFavicon, bounds)
|
rFavicon = MasterTableViewCellLayout.centerVertically(rFavicon, bounds)
|
||||||
}
|
}
|
||||||
self.faviconRect = rFavicon
|
self.faviconRect = rFavicon
|
||||||
@ -44,7 +52,7 @@ struct MasterTableViewCellLayout {
|
|||||||
if shouldShowImage {
|
if shouldShowImage {
|
||||||
rLabel.origin.x = rFavicon.maxX + MasterTableViewCellLayout.imageMarginRight
|
rLabel.origin.x = rFavicon.maxX + MasterTableViewCellLayout.imageMarginRight
|
||||||
} else {
|
} else {
|
||||||
rLabel.origin.x = indent ? MasterTableViewCellLayout.marginLeft + 10 : MasterTableViewCellLayout.marginLeft
|
rLabel.origin.x = bounds.minX
|
||||||
}
|
}
|
||||||
|
|
||||||
rLabel = MasterTableViewCellLayout.centerVertically(rLabel, bounds)
|
rLabel = MasterTableViewCellLayout.centerVertically(rLabel, bounds)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user