Edit icon on attachments

This commit is contained in:
Justin Mazzocchi 2021-01-31 06:52:20 -08:00
parent 15cc811102
commit 35a90f866c
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
4 changed files with 19 additions and 3 deletions

View file

@ -9,6 +9,7 @@ final class AttachmentView: UIView {
let playerView = PlayerView()
let imageView = AnimatedImageView()
let removeButton = UIButton(type: .close)
let editIcon = UIImageView()
let selectionButton = UIButton()
var playing: Bool = false {
@ -151,6 +152,15 @@ private extension AttachmentView {
self.parentViewModel.removeAttachment(viewModel: self.viewModel)
}])
addSubview(editIcon)
editIcon.translatesAutoresizingMaskIntoConstraints = false
editIcon.image = UIImage(
systemName: "pencil",
withConfiguration: UIImage.SymbolConfiguration(scale: .large))
editIcon.layer.shadowOffset = .zero
editIcon.layer.shadowRadius = .defaultShadowRadius
editIcon.layer.shadowOpacity = .defaultShadowOpacity
switch viewModel.attachment.type {
case .image, .video, .gifv:
imageView.kf.setImage(
@ -196,7 +206,9 @@ private extension AttachmentView {
selectionButton.topAnchor.constraint(equalTo: topAnchor),
selectionButton.bottomAnchor.constraint(equalTo: bottomAnchor),
removeButton.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
removeButton.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor)
removeButton.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
editIcon.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
editIcon.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
])
}
}

View file

@ -130,7 +130,7 @@ private extension EditThumbnailView {
previewImageContainerView.layer.cornerRadius = .defaultCornerRadius
previewImageContainerView.layer.shadowOffset = .zero
previewImageContainerView.layer.shadowRadius = .defaultShadowRadius
previewImageContainerView.layer.shadowOpacity = 0.25
previewImageContainerView.layer.shadowOpacity = .defaultShadowOpacity
previewImageContainerView.addSubview(previewImageView)
previewImageView.translatesAutoresizingMaskIntoConstraints = false

View file

@ -37,7 +37,7 @@ private extension NewStatusButtonView {
.cgPath
layer.shadowOffset = .zero
layer.shadowRadius = .defaultShadowRadius
layer.shadowOpacity = 0.25
layer.shadowOpacity = .defaultShadowOpacity
addSubview(blurView)
blurView.translatesAutoresizingMaskIntoConstraints = false

View file

@ -17,6 +17,10 @@ extension CGFloat {
static let systemMenuInset: Self = 15
}
extension Float {
static let defaultShadowOpacity: Self = 0.25
}
extension CGRect {
static let defaultContentsRect = Self(origin: .zero, size: .init(width: 1, height: 1))
}