From 35a90f866cc481de081b292e14126dee9ebd798d Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Sun, 31 Jan 2021 06:52:20 -0800 Subject: [PATCH] Edit icon on attachments --- Views/UIKit/AttachmentView.swift | 14 +++++++++++++- Views/UIKit/EditThumbnailView.swift | 2 +- Views/UIKit/NewStatusButtonView.swift | 2 +- Views/ViewConstants.swift | 4 ++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Views/UIKit/AttachmentView.swift b/Views/UIKit/AttachmentView.swift index 7e6a0bc..84f3229 100644 --- a/Views/UIKit/AttachmentView.swift +++ b/Views/UIKit/AttachmentView.swift @@ -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) ]) } } diff --git a/Views/UIKit/EditThumbnailView.swift b/Views/UIKit/EditThumbnailView.swift index 3f135b5..5a230c6 100644 --- a/Views/UIKit/EditThumbnailView.swift +++ b/Views/UIKit/EditThumbnailView.swift @@ -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 diff --git a/Views/UIKit/NewStatusButtonView.swift b/Views/UIKit/NewStatusButtonView.swift index 426f64c..3dc6e2a 100644 --- a/Views/UIKit/NewStatusButtonView.swift +++ b/Views/UIKit/NewStatusButtonView.swift @@ -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 diff --git a/Views/ViewConstants.swift b/Views/ViewConstants.swift index 8e85b09..ca2c138 100644 --- a/Views/ViewConstants.swift +++ b/Views/ViewConstants.swift @@ -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)) }