This commit is contained in:
Justin Mazzocchi 2020-09-28 18:32:28 -07:00
parent a7e6db409a
commit 7335615b64
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
7 changed files with 47 additions and 42 deletions

View File

@ -57,8 +57,6 @@ extension AccountView: UITextViewDelegate {
}
private extension AccountView {
static let spacing: CGFloat = 8
static let stackViewSpacing: CGFloat = 4
static let avatarDimension: CGFloat = 50
func initialSetup() {
@ -71,7 +69,7 @@ private extension AccountView {
avatarImageView.clipsToBounds = true
stackView.translatesAutoresizingMaskIntoConstraints = false
stackView.axis = .vertical
stackView.spacing = Self.stackViewSpacing
stackView.spacing = .compactSpacing
stackView.addArrangedSubview(displayNameLabel)
stackView.addArrangedSubview(accountLabel)
stackView.addArrangedSubview(noteTextView)
@ -92,7 +90,7 @@ private extension AccountView {
avatarImageView.topAnchor.constraint(equalTo: readableContentGuide.topAnchor),
avatarImageView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor),
avatarImageView.bottomAnchor.constraint(lessThanOrEqualTo: readableContentGuide.bottomAnchor),
stackView.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor, constant: Self.spacing),
stackView.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor, constant: .defaultSpacing),
stackView.topAnchor.constraint(equalTo: readableContentGuide.topAnchor),
stackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor),
stackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor)

View File

@ -17,23 +17,12 @@ final class AttachmentView: UIView {
layoutMargins = .zero
addSubview(imageView)
imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true
imageView.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor).isActive = true
imageView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true
imageView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true
imageView.contentMode = .scaleAspectFill
imageView.clipsToBounds = true
addSubview(button)
button.translatesAutoresizingMaskIntoConstraints = false
button.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true
button.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor).isActive = true
button.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true
button.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true
let highlightedButtonBackgroundImage = UIColor(white: 0, alpha: 0.5).image()
button.setBackgroundImage(highlightedButtonBackgroundImage, for: .highlighted)
button.setBackgroundImage(.highlightedButtonBackground, for: .highlighted)
switch viewModel.attachment.type {
case .image:
@ -41,6 +30,17 @@ final class AttachmentView: UIView {
default:
break
}
NSLayoutConstraint.activate([
imageView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
imageView.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
imageView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
imageView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor),
button.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
button.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
button.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
button.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
])
}
@available(*, unavailable)

View File

@ -47,29 +47,30 @@ final class AttachmentsView: UIView {
}
private extension AttachmentsView {
static let spacing: CGFloat = 4
static let cornerRadius: CGFloat = 8
func initializationActions() {
backgroundColor = .clear
layoutMargins = .zero
clipsToBounds = true
layer.cornerRadius = Self.cornerRadius
layer.cornerRadius = .defaultCornerRadius
addSubview(containerStackView)
containerStackView.translatesAutoresizingMaskIntoConstraints = false
containerStackView.distribution = .fillEqually
containerStackView.spacing = Self.spacing
containerStackView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor).isActive = true
containerStackView.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor).isActive = true
containerStackView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true
containerStackView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true
containerStackView.spacing = .compactSpacing
leftStackView.distribution = .fillEqually
leftStackView.spacing = Self.spacing
leftStackView.spacing = .compactSpacing
leftStackView.axis = .vertical
rightStackView.distribution = .fillEqually
rightStackView.spacing = Self.spacing
rightStackView.spacing = .compactSpacing
rightStackView.axis = .vertical
containerStackView.addArrangedSubview(leftStackView)
containerStackView.addArrangedSubview(rightStackView)
NSLayoutConstraint.activate([
containerStackView.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor),
containerStackView.trailingAnchor.constraint(equalTo: layoutMarginsGuide.trailingAnchor),
containerStackView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
containerStackView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
])
}
}

View File

@ -10,9 +10,13 @@ final class LoadingTableFooterView: UIView {
addSubview(activityIndicatorView)
activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
activityIndicatorView.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true
activityIndicatorView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor).isActive = true
activityIndicatorView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor).isActive = true
NSLayoutConstraint.activate([
activityIndicatorView.centerXAnchor.constraint(equalTo: centerXAnchor),
activityIndicatorView.topAnchor.constraint(equalTo: layoutMarginsGuide.topAnchor),
activityIndicatorView.bottomAnchor.constraint(equalTo: layoutMarginsGuide.bottomAnchor)
])
activityIndicatorView.startAnimating()
}

View File

@ -104,6 +104,7 @@ extension StatusView: UITextViewDelegate {
}
private extension StatusView {
// swiftlint:disable function_body_length
func initialSetup() {
Bundle.main.loadNibNamed(String(describing: type(of: self)), owner: self, options: nil)
@ -132,10 +133,8 @@ private extension StatusView {
contentTextView.delegate = self
let highlightedButtonBackgroundImage = UIColor(white: 0, alpha: 0.5).image()
avatarButton.setBackgroundImage(highlightedButtonBackgroundImage, for: .highlighted)
contextParentAvatarButton.setBackgroundImage(highlightedButtonBackgroundImage, for: .highlighted)
avatarButton.setBackgroundImage(.highlightedButtonBackground, for: .highlighted)
contextParentAvatarButton.setBackgroundImage(.highlightedButtonBackground, for: .highlighted)
let accountAction = UIAction { [weak self] _ in self?.statusConfiguration.viewModel.accountSelected() }
@ -173,7 +172,6 @@ private extension StatusView {
applyStatusConfiguration()
}
// swiftlint:disable function_body_length
func applyStatusConfiguration() {
let viewModel = statusConfiguration.viewModel
let mutableContent = NSMutableAttributedString(attributedString: viewModel.content)

View File

@ -8,6 +8,10 @@ extension CGFloat {
static let defaultCornerRadius: Self = 8
}
extension TimeInterval {
static let defaultAnimationDuration: Self = 0.5
}
extension UIImage {
static let highlightedButtonBackground = UIColor(white: 0, alpha: 0.5).image()
}

View File

@ -9,7 +9,7 @@ class WebfingerIndicatorView: UIVisualEffectView {
super.init(effect: nil)
clipsToBounds = true
layer.cornerRadius = 8
layer.cornerRadius = .defaultCornerRadius
contentView.addSubview(activityIndicatorView)
activityIndicatorView.translatesAutoresizingMaskIntoConstraints = false
@ -17,13 +17,13 @@ class WebfingerIndicatorView: UIVisualEffectView {
NSLayoutConstraint.activate([
trailingAnchor.constraint(
equalTo: activityIndicatorView.trailingAnchor, constant: 8),
equalTo: activityIndicatorView.trailingAnchor, constant: .defaultSpacing),
bottomAnchor.constraint(
equalTo: activityIndicatorView.bottomAnchor, constant: 8),
equalTo: activityIndicatorView.bottomAnchor, constant: .defaultSpacing),
activityIndicatorView.topAnchor.constraint(
equalTo: topAnchor, constant: 8),
equalTo: topAnchor, constant: .defaultSpacing),
activityIndicatorView.leadingAnchor.constraint(
equalTo: leadingAnchor, constant: 8),
equalTo: leadingAnchor, constant: .defaultSpacing),
activityIndicatorView.centerXAnchor.constraint(
equalTo: contentView.safeAreaLayoutGuide.centerXAnchor),
activityIndicatorView.centerYAnchor.constraint(
@ -44,15 +44,15 @@ extension WebfingerIndicatorView {
isHidden = false
activityIndicatorView.startAnimating()
UIView.animate(withDuration: 0.5) {
self.effect = UIBlurEffect(style: .systemUltraThinMaterial)
UIView.animate(withDuration: .defaultAnimationDuration) {
self.effect = UIBlurEffect(style: .systemChromeMaterial)
}
}
func stopAnimating() {
activityIndicatorView.stopAnimating()
UIView.animate(withDuration: 0.5) {
UIView.animate(withDuration: .defaultAnimationDuration) {
self.effect = nil
} completion: { _ in
self.isHidden = true