From 670e2f9af613fd215bc3ebeef69e0f4a3a017d39 Mon Sep 17 00:00:00 2001 From: Justin Mazzocchi <2831158+jzzocc@users.noreply.github.com> Date: Tue, 13 Oct 2020 13:11:27 -0700 Subject: [PATCH] Cleanup --- Views/AccountHeaderView.swift | 4 ++-- Views/AccountView.swift | 3 +-- Views/Status/CardView.swift | 9 ++++----- Views/Status/StatusAttachmentsView.swift | 9 ++++----- Views/Status/StatusView.swift | 3 +-- Views/TouchFallthroughTextView.swift | 19 ++++++++----------- 6 files changed, 20 insertions(+), 27 deletions(-) diff --git a/Views/AccountHeaderView.swift b/Views/AccountHeaderView.swift index 72a6364..c501a2d 100644 --- a/Views/AccountHeaderView.swift +++ b/Views/AccountHeaderView.swift @@ -35,7 +35,7 @@ class AccountHeaderView: UIView { override init(frame: CGRect) { super.init(frame: frame) - initializationActions() + initialSetup() } @available(*, unavailable) @@ -62,7 +62,7 @@ extension AccountHeaderView: UITextViewDelegate { } private extension AccountHeaderView { - func initializationActions() { + func initialSetup() { let baseStackView = UIStackView() addSubview(headerImageView) diff --git a/Views/AccountView.swift b/Views/AccountView.swift index f158acb..b288932 100644 --- a/Views/AccountView.swift +++ b/Views/AccountView.swift @@ -17,6 +17,7 @@ class AccountView: UIView { super.init(frame: .zero) initialSetup() + applyAccountConfiguration() } @available(*, unavailable) @@ -93,8 +94,6 @@ private extension AccountView { stackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor), stackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor) ]) - - applyAccountConfiguration() } func applyAccountConfiguration() { diff --git a/Views/Status/CardView.swift b/Views/Status/CardView.swift index aa5039a..0b6e9f9 100644 --- a/Views/Status/CardView.swift +++ b/Views/Status/CardView.swift @@ -35,19 +35,18 @@ final class CardView: UIView { override init(frame: CGRect) { super.init(frame: frame) - initializationActions() + initialSetup() } + @available(*, unavailable) required init?(coder: NSCoder) { - super.init(coder: coder) - - initializationActions() + fatalError("init(coder:) has not been implemented") } } private extension CardView { // swiftlint:disable:next function_body_length - func initializationActions() { + func initialSetup() { backgroundColor = .secondarySystemBackground layer.cornerRadius = .defaultCornerRadius clipsToBounds = true diff --git a/Views/Status/StatusAttachmentsView.swift b/Views/Status/StatusAttachmentsView.swift index 878c4e4..3d38b31 100644 --- a/Views/Status/StatusAttachmentsView.swift +++ b/Views/Status/StatusAttachmentsView.swift @@ -52,18 +52,17 @@ final class StatusAttachmentsView: UIView { override init(frame: CGRect) { super.init(frame: frame) - initializationActions() + initialSetup() } + @available(*, unavailable) required init?(coder: NSCoder) { - super.init(coder: coder) - - initializationActions() + fatalError("init(coder:) has not been implemented") } } private extension StatusAttachmentsView { - func initializationActions() { + func initialSetup() { backgroundColor = .clear layoutMargins = .zero clipsToBounds = true diff --git a/Views/Status/StatusView.swift b/Views/Status/StatusView.swift index 5068fb6..2e96099 100644 --- a/Views/Status/StatusView.swift +++ b/Views/Status/StatusView.swift @@ -50,6 +50,7 @@ final class StatusView: UIView { super.init(frame: .zero) initialSetup() + applyStatusConfiguration() } @available(*, unavailable) @@ -287,8 +288,6 @@ private extension StatusView { avatarButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor), avatarButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor) ]) - - applyStatusConfiguration() } func applyStatusConfiguration() { diff --git a/Views/TouchFallthroughTextView.swift b/Views/TouchFallthroughTextView.swift index b86aac0..8c62af5 100644 --- a/Views/TouchFallthroughTextView.swift +++ b/Views/TouchFallthroughTextView.swift @@ -9,12 +9,17 @@ final class TouchFallthroughTextView: UITextView { override init(frame: CGRect, textContainer: NSTextContainer?) { super.init(frame: frame, textContainer: textContainer) - initializationActions() + + clipsToBounds = false + textDragInteraction?.isEnabled = false + textContainerInset = .zero + self.textContainer.lineFragmentPadding = 0 + linkTextAttributes = [.foregroundColor: tintColor as Any, .underlineColor: UIColor.clear] } + @available(*, unavailable) required init?(coder: NSCoder) { - super.init(coder: coder) - initializationActions() + fatalError("init(coder:) has not been implemented") } override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { @@ -124,14 +129,6 @@ final class TouchFallthroughTextView: UITextView { private extension TouchFallthroughTextView { static let linkHighlightViewTransform = CGAffineTransform(scaleX: 1.1, y: 1.1) - func initializationActions() { - clipsToBounds = false - textDragInteraction?.isEnabled = false - textContainerInset = .zero - textContainer.lineFragmentPadding = 0 - linkTextAttributes = [.foregroundColor: tintColor as Any, .underlineColor: UIColor.clear] - } - func removeLinkHighlightView() { UIView.animate(withDuration: .defaultAnimationDuration) { self.linkHighlightView?.alpha = 0