mirror of
https://github.com/lux-tel/session-ios.git
synced 2026-10-30 20:38:32 +00:00
• Refactored "SignalAttachment" to be "PendingAttachment" and "ProcessedAttachment" • Added libWebP and SDWebImageWebPCoder for WebP encoding • Added an `icon` option to the ImageDataManager • Updated display picture editing to use `ImageDataManager.DataSource` where possible (avoid loading as data) • Updated the group creation and display picture update processes to be (mostly) async/await • Updated PhotoLibrary attachment processing to be async/await • Updated the main logic in AttachmentUploadJob to be async/await • Fixed an issue where link previews wouldn't render correctly
58 lines
2.0 KiB
Swift
58 lines
2.0 KiB
Swift
// Copyright © 2022 Rangeproof Pty Ltd. All rights reserved.
|
|
|
|
import UIKit
|
|
import SessionUIKit
|
|
import SessionUtilitiesKit
|
|
|
|
protocol ApprovalRailCellViewDelegate: AnyObject {
|
|
func approvalRailCellView(_ approvalRailCellView: ApprovalRailCellView, didRemoveItem attachmentItem: PendingAttachmentRailItem)
|
|
func canRemoveApprovalRailCellView(_ approvalRailCellView: ApprovalRailCellView) -> Bool
|
|
}
|
|
|
|
// MARK: -
|
|
|
|
public class ApprovalRailCellView: GalleryRailCellView {
|
|
|
|
weak var approvalRailCellDelegate: ApprovalRailCellViewDelegate?
|
|
|
|
lazy var deleteButton: UIButton = {
|
|
let button = OWSButton { [weak self] in
|
|
guard let self = self else { return }
|
|
|
|
guard let attachmentItem = item as? PendingAttachmentRailItem else {
|
|
Log.error("[ApprovalRailCellView] attachmentItem was unexpectedly nil")
|
|
return
|
|
}
|
|
|
|
self.approvalRailCellDelegate?.approvalRailCellView(self, didRemoveItem: attachmentItem)
|
|
}
|
|
|
|
button.setImage(UIImage(named: "x-24")?.withRenderingMode(.alwaysTemplate), for: .normal)
|
|
button.themeTintColor = .white
|
|
button.themeShadowColor = .black
|
|
button.layer.shadowRadius = 2
|
|
button.layer.shadowOpacity = 0.66
|
|
button.layer.shadowOffset = .zero
|
|
button.set(.width, to: 24)
|
|
button.set(.height, to: 24)
|
|
|
|
return button
|
|
}()
|
|
|
|
override func setIsSelected(_ isSelected: Bool) {
|
|
super.setIsSelected(isSelected)
|
|
|
|
if isSelected {
|
|
if let approvalRailCellDelegate = self.approvalRailCellDelegate,
|
|
approvalRailCellDelegate.canRemoveApprovalRailCellView(self) {
|
|
|
|
addSubview(deleteButton)
|
|
deleteButton.pin(.top, to: .top, of: self, withInset: cellBorderWidth)
|
|
deleteButton.pin(.trailing, to: .trailing, of: self, withInset: -(cellBorderWidth + 4))
|
|
}
|
|
} else {
|
|
deleteButton.removeFromSuperview()
|
|
}
|
|
}
|
|
}
|