Remove stackview (#806)

This commit is contained in:
Nathan Mattes 2022-12-26 14:13:15 +01:00
parent 577e2c665a
commit 4f3ae5cce0
2 changed files with 13 additions and 28 deletions

View File

@ -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)

View File

@ -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