diff --git a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift index c61f90a50..91beee4c5 100644 --- a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift +++ b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift @@ -27,15 +27,6 @@ final class MediaPreviewViewController: UIViewController, NeedsDependency { let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial)) let pagingViewController = MediaPreviewPagingViewController() - let topToolbar: UIStackView = { - let stackView = TouchTransparentStackView() - stackView.axis = .horizontal - stackView.distribution = .equalSpacing - stackView.alignment = .fill - stackView.translatesAutoresizingMaskIntoConstraints = false - return stackView - }() - let closeButton = HUDButton { button in button.setImage(UIImage(systemName: "xmark", withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .bold))!, for: .normal) } @@ -64,18 +55,6 @@ extension MediaPreviewViewController { visualEffectView.pinTo(to: pagingViewController.view) pagingViewController.didMove(toParent: self) - view.addSubview(topToolbar) - NSLayoutConstraint.activate([ - topToolbar.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 12), - topToolbar.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor), - topToolbar.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor), - ]) - - topToolbar.addArrangedSubview(closeButton) - NSLayoutConstraint.activate([ - closeButton.widthAnchor.constraint(equalToConstant: HUDButton.height).priority(.defaultHigh), - ]) - altViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(altViewController.view) altViewController.didMove(toParent: self) @@ -86,7 +65,13 @@ extension MediaPreviewViewController { pagingViewController.interPageSpacing = 10 pagingViewController.delegate = self pagingViewController.dataSource = viewModel - + + view.addSubview(closeButton) + NSLayoutConstraint.activate([ + closeButton.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 12), + closeButton.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor), + closeButton.widthAnchor.constraint(equalTo: closeButton.heightAnchor), + ]) closeButton.button.addTarget(self, action: #selector(MediaPreviewViewController.closeButtonPressed(_:)), for: .touchUpInside) // bind view model @@ -149,7 +134,7 @@ extension MediaPreviewViewController { .sink { [weak self] showingChrome in UIView.animate(withDuration: 0.3) { self?.setNeedsStatusBarAppearanceUpdate() - self?.topToolbar.alpha = showingChrome ? 1 : 0 + self?.closeButton.alpha = showingChrome ? 1 : 0 } } .store(in: &disposeBag) diff --git a/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift b/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift index 4a88236e9..bbb73c12d 100644 --- a/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift +++ b/Mastodon/Scene/Transition/MediaPreview/MediaHostToMediaPreviewViewControllerAnimatedTransitioning.swift @@ -81,7 +81,7 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning { transitionItem.transitionView = transitionImageView transitionContext.containerView.addSubview(transitionImageView) - toVC.topToolbar.alpha = 0 + toVC.closeButton.alpha = 0 if UIAccessibility.isReduceTransparencyEnabled { toVC.visualEffectView.alpha = 0 @@ -101,7 +101,7 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning { toVC.pagingViewController.view.alpha = 1 transitionImageView.removeFromSuperview() UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) { - toVC.topToolbar.alpha = 1 + toVC.closeButton.alpha = 1 } transitionContext.completeTransition(position == .end) } @@ -140,11 +140,11 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning { // update top toolbar UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) { - fromVC.topToolbar.alpha = 0 + fromVC.closeButton.alpha = 0 } animator.addCompletion { position in UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) { - fromVC.topToolbar.alpha = position == .end ? 0 : 1 + fromVC.closeButton.alpha = position == .end ? 0 : 1 } } @@ -202,7 +202,7 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning { mediaPreviewTransitionContext.snapshot.contentMode = .scaleAspectFill mediaPreviewTransitionContext.snapshot.clipsToBounds = true transitionMaskView.addSubview(mediaPreviewTransitionContext.snapshot) - fromVC.view.bringSubviewToFront(fromVC.topToolbar) + fromVC.view.bringSubviewToFront(fromVC.closeButton) transitionItem.transitionView = mediaPreviewTransitionContext.transitionView transitionItem.snapshotTransitioning = mediaPreviewTransitionContext.snapshot