Profile avatar and animation improvements

This commit is contained in:
Justin Mazzocchi 2021-01-16 12:45:56 -08:00
parent 8fb20269e3
commit 0082360692
No known key found for this signature in database
GPG Key ID: E223E6937AAFB01C
3 changed files with 22 additions and 8 deletions

View File

@ -51,6 +51,7 @@ private extension ZoomAnimator {
if transitionView == nil, let transitionView = (fromReferenceView as? ZoomAnimatableView)?.transitionView() { if transitionView == nil, let transitionView = (fromReferenceView as? ZoomAnimatableView)?.transitionView() {
transitionView.frame = fromReferenceViewFrame transitionView.frame = fromReferenceViewFrame
transitionView.layer.contentsRect = fromReferenceView.layer.contentsRect transitionView.layer.contentsRect = fromReferenceView.layer.contentsRect
transitionView.layer.cornerRadius = fromReferenceView.layer.cornerRadius
self.transitionView = transitionView self.transitionView = transitionView
transitionContext.containerView.addSubview(transitionView) transitionContext.containerView.addSubview(transitionView)
} }
@ -67,6 +68,7 @@ private extension ZoomAnimator {
options: [.transitionCrossDissolve]) { options: [.transitionCrossDissolve]) {
self.transitionView?.frame = finalTransitionSize self.transitionView?.frame = finalTransitionSize
self.transitionView?.layer.contentsRect = .defaultContentsRect self.transitionView?.layer.contentsRect = .defaultContentsRect
self.transitionView?.layer.cornerRadius = 0
toVC.view.alpha = 1.0 toVC.view.alpha = 1.0
fromVC.tabBarController?.tabBar.alpha = 0 fromVC.tabBarController?.tabBar.alpha = 0
} completion: { _ in } completion: { _ in
@ -117,6 +119,7 @@ private extension ZoomAnimator {
} }
self.transitionView?.layer.contentsRect = toReferenceView?.layer.contentsRect ?? .defaultContentsRect self.transitionView?.layer.contentsRect = toReferenceView?.layer.contentsRect ?? .defaultContentsRect
self.transitionView?.layer.cornerRadius = toReferenceView?.layer.cornerRadius ?? 0
toVC.tabBarController?.tabBar.alpha = 1 toVC.tabBarController?.tabBar.alpha = 1
} completion: { _ in } completion: { _ in

View File

@ -84,6 +84,7 @@ final class ZoomDismissalInteractionController: NSObject {
} }
transitionView.layer.contentsRect = toReferenceView?.layer.contentsRect ?? .defaultContentsRect transitionView.layer.contentsRect = toReferenceView?.layer.contentsRect ?? .defaultContentsRect
transitionView.layer.cornerRadius = toReferenceView?.layer.cornerRadius ?? 0
toVC.tabBarController?.tabBar.alpha = 1 toVC.tabBarController?.tabBar.alpha = 1
} completion: { _ in } completion: { _ in

View File

@ -7,6 +7,7 @@ import ViewModels
final class AccountHeaderView: UIView { final class AccountHeaderView: UIView {
let headerImageView = AnimatedImageView() let headerImageView = AnimatedImageView()
let headerButton = UIButton() let headerButton = UIButton()
let avatarBackgroundView = UIView()
let avatarImageView = UIImageView() let avatarImageView = UIImageView()
let avatarButton = UIButton() let avatarButton = UIButton()
let relationshipButtonsStackView = UIStackView() let relationshipButtonsStackView = UIStackView()
@ -177,14 +178,19 @@ private extension AccountHeaderView {
headerButton.addAction(UIAction { [weak self] _ in self?.viewModel?.presentHeader() }, for: .touchUpInside) headerButton.addAction(UIAction { [weak self] _ in self?.viewModel?.presentHeader() }, for: .touchUpInside)
addSubview(avatarImageView) let avatarBackgroundViewDimension = Self.avatarDimension + .compactSpacing * 2
addSubview(avatarBackgroundView)
avatarBackgroundView.translatesAutoresizingMaskIntoConstraints = false
avatarBackgroundView.backgroundColor = .systemBackground
avatarBackgroundView.layer.cornerRadius = avatarBackgroundViewDimension / 2
avatarBackgroundView.addSubview(avatarImageView)
avatarImageView.translatesAutoresizingMaskIntoConstraints = false avatarImageView.translatesAutoresizingMaskIntoConstraints = false
avatarImageView.contentMode = .scaleAspectFill avatarImageView.contentMode = .scaleAspectFill
avatarImageView.clipsToBounds = true avatarImageView.clipsToBounds = true
avatarImageView.isUserInteractionEnabled = true avatarImageView.isUserInteractionEnabled = true
avatarImageView.layer.cornerRadius = Self.avatarDimension / 2 avatarImageView.layer.cornerRadius = Self.avatarDimension / 2
avatarImageView.layer.borderWidth = .compactSpacing
avatarImageView.layer.borderColor = UIColor.systemBackground.cgColor
avatarImageView.addSubview(avatarButton) avatarImageView.addSubview(avatarButton)
avatarButton.translatesAutoresizingMaskIntoConstraints = false avatarButton.translatesAutoresizingMaskIntoConstraints = false
@ -318,21 +324,25 @@ private extension AccountHeaderView {
headerButton.topAnchor.constraint(equalTo: headerImageView.topAnchor), headerButton.topAnchor.constraint(equalTo: headerImageView.topAnchor),
headerButton.bottomAnchor.constraint(equalTo: headerImageView.bottomAnchor), headerButton.bottomAnchor.constraint(equalTo: headerImageView.bottomAnchor),
headerButton.trailingAnchor.constraint(equalTo: headerImageView.trailingAnchor), headerButton.trailingAnchor.constraint(equalTo: headerImageView.trailingAnchor),
avatarBackgroundView.heightAnchor.constraint(equalToConstant: avatarBackgroundViewDimension),
avatarBackgroundView.widthAnchor.constraint(equalToConstant: avatarBackgroundViewDimension),
avatarBackgroundView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor),
avatarBackgroundView.centerYAnchor.constraint(equalTo: headerImageView.bottomAnchor),
avatarImageView.heightAnchor.constraint(equalToConstant: Self.avatarDimension), avatarImageView.heightAnchor.constraint(equalToConstant: Self.avatarDimension),
avatarImageView.widthAnchor.constraint(equalToConstant: Self.avatarDimension), avatarImageView.widthAnchor.constraint(equalToConstant: Self.avatarDimension),
avatarImageView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor), avatarImageView.centerXAnchor.constraint(equalTo: avatarBackgroundView.centerXAnchor),
avatarImageView.centerYAnchor.constraint(equalTo: headerImageView.bottomAnchor), avatarImageView.centerYAnchor.constraint(equalTo: avatarBackgroundView.centerYAnchor),
avatarButton.leadingAnchor.constraint(equalTo: avatarImageView.leadingAnchor), avatarButton.leadingAnchor.constraint(equalTo: avatarImageView.leadingAnchor),
avatarButton.topAnchor.constraint(equalTo: avatarImageView.topAnchor), avatarButton.topAnchor.constraint(equalTo: avatarImageView.topAnchor),
avatarButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor), avatarButton.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor),
avatarButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor), avatarButton.trailingAnchor.constraint(equalTo: avatarImageView.trailingAnchor),
relationshipButtonsStackView.leadingAnchor.constraint(equalTo: avatarImageView.trailingAnchor), relationshipButtonsStackView.leadingAnchor.constraint(equalTo: avatarBackgroundView.trailingAnchor),
relationshipButtonsStackView.topAnchor.constraint( relationshipButtonsStackView.topAnchor.constraint(
equalTo: headerImageView.bottomAnchor, equalTo: headerImageView.bottomAnchor,
constant: .defaultSpacing), constant: .defaultSpacing),
relationshipButtonsStackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor), relationshipButtonsStackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor),
relationshipButtonsStackView.bottomAnchor.constraint(equalTo: avatarImageView.bottomAnchor), relationshipButtonsStackView.bottomAnchor.constraint(equalTo: avatarBackgroundView.bottomAnchor),
baseStackView.topAnchor.constraint(equalTo: avatarImageView.bottomAnchor, constant: .defaultSpacing), baseStackView.topAnchor.constraint(equalTo: avatarBackgroundView.bottomAnchor, constant: .defaultSpacing),
baseStackView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor), baseStackView.leadingAnchor.constraint(equalTo: readableContentGuide.leadingAnchor),
baseStackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor), baseStackView.trailingAnchor.constraint(equalTo: readableContentGuide.trailingAnchor),
baseStackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor) baseStackView.bottomAnchor.constraint(equalTo: readableContentGuide.bottomAnchor)