Cannot delete last item in rail

pull/2/head
Michael Kirk 6 years ago
parent abf35decde
commit 19002a13b1

@ -7,6 +7,7 @@ import UIKit
protocol ApprovalRailCellViewDelegate: class { protocol ApprovalRailCellViewDelegate: class {
func approvalRailCellView(_ approvalRailCellView: ApprovalRailCellView, didRemoveItem attachmentItem: SignalAttachmentItem) func approvalRailCellView(_ approvalRailCellView: ApprovalRailCellView, didRemoveItem attachmentItem: SignalAttachmentItem)
func canRemoveApprovalRailCellView(_ approvalRailCellView: ApprovalRailCellView) -> Bool
} }
// MARK: - // MARK: -
@ -55,10 +56,13 @@ public class ApprovalRailCellView: GalleryRailCellView {
super.setIsSelected(isSelected) super.setIsSelected(isSelected)
if isSelected { if isSelected {
addSubview(deleteButton) if let approvalRailCellDelegate = self.approvalRailCellDelegate,
approvalRailCellDelegate.canRemoveApprovalRailCellView(self) {
deleteButton.autoPinEdge(toSuperviewEdge: .top, withInset: cellBorderWidth) addSubview(deleteButton)
deleteButton.autoPinEdge(toSuperviewEdge: .trailing, withInset: cellBorderWidth + 4) deleteButton.autoPinEdge(toSuperviewEdge: .top, withInset: cellBorderWidth)
deleteButton.autoPinEdge(toSuperviewEdge: .trailing, withInset: cellBorderWidth + 4)
}
} else { } else {
deleteButton.removeFromSuperview() deleteButton.removeFromSuperview()
} }

@ -801,6 +801,10 @@ extension AttachmentApprovalViewController: ApprovalRailCellViewDelegate {
func approvalRailCellView(_ approvalRailCellView: ApprovalRailCellView, didRemoveItem attachmentItem: SignalAttachmentItem) { func approvalRailCellView(_ approvalRailCellView: ApprovalRailCellView, didRemoveItem attachmentItem: SignalAttachmentItem) {
remove(attachmentItem: attachmentItem) remove(attachmentItem: attachmentItem)
} }
func canRemoveApprovalRailCellView(_ approvalRailCellView: ApprovalRailCellView) -> Bool {
return self.attachmentItems.count > 1
}
} }
// MARK: - // MARK: -

Loading…
Cancel
Save