Remove stackview (#806)
This commit is contained in:
parent
577e2c665a
commit
4f3ae5cce0
|
@ -27,15 +27,6 @@ final class MediaPreviewViewController: UIViewController, NeedsDependency {
|
||||||
let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial))
|
let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .systemMaterial))
|
||||||
let pagingViewController = MediaPreviewPagingViewController()
|
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
|
let closeButton = HUDButton { button in
|
||||||
button.setImage(UIImage(systemName: "xmark", withConfiguration: UIImage.SymbolConfiguration(pointSize: 16, weight: .bold))!, for: .normal)
|
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)
|
visualEffectView.pinTo(to: pagingViewController.view)
|
||||||
pagingViewController.didMove(toParent: self)
|
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
|
altViewController.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
view.addSubview(altViewController.view)
|
view.addSubview(altViewController.view)
|
||||||
altViewController.didMove(toParent: self)
|
altViewController.didMove(toParent: self)
|
||||||
|
@ -86,7 +65,13 @@ extension MediaPreviewViewController {
|
||||||
pagingViewController.interPageSpacing = 10
|
pagingViewController.interPageSpacing = 10
|
||||||
pagingViewController.delegate = self
|
pagingViewController.delegate = self
|
||||||
pagingViewController.dataSource = viewModel
|
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)
|
closeButton.button.addTarget(self, action: #selector(MediaPreviewViewController.closeButtonPressed(_:)), for: .touchUpInside)
|
||||||
|
|
||||||
// bind view model
|
// bind view model
|
||||||
|
@ -149,7 +134,7 @@ extension MediaPreviewViewController {
|
||||||
.sink { [weak self] showingChrome in
|
.sink { [weak self] showingChrome in
|
||||||
UIView.animate(withDuration: 0.3) {
|
UIView.animate(withDuration: 0.3) {
|
||||||
self?.setNeedsStatusBarAppearanceUpdate()
|
self?.setNeedsStatusBarAppearanceUpdate()
|
||||||
self?.topToolbar.alpha = showingChrome ? 1 : 0
|
self?.closeButton.alpha = showingChrome ? 1 : 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
|
@ -81,7 +81,7 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning {
|
||||||
transitionItem.transitionView = transitionImageView
|
transitionItem.transitionView = transitionImageView
|
||||||
transitionContext.containerView.addSubview(transitionImageView)
|
transitionContext.containerView.addSubview(transitionImageView)
|
||||||
|
|
||||||
toVC.topToolbar.alpha = 0
|
toVC.closeButton.alpha = 0
|
||||||
|
|
||||||
if UIAccessibility.isReduceTransparencyEnabled {
|
if UIAccessibility.isReduceTransparencyEnabled {
|
||||||
toVC.visualEffectView.alpha = 0
|
toVC.visualEffectView.alpha = 0
|
||||||
|
@ -101,7 +101,7 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning {
|
||||||
toVC.pagingViewController.view.alpha = 1
|
toVC.pagingViewController.view.alpha = 1
|
||||||
transitionImageView.removeFromSuperview()
|
transitionImageView.removeFromSuperview()
|
||||||
UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) {
|
UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) {
|
||||||
toVC.topToolbar.alpha = 1
|
toVC.closeButton.alpha = 1
|
||||||
}
|
}
|
||||||
transitionContext.completeTransition(position == .end)
|
transitionContext.completeTransition(position == .end)
|
||||||
}
|
}
|
||||||
|
@ -140,11 +140,11 @@ extension MediaHostToMediaPreviewViewControllerAnimatedTransitioning {
|
||||||
|
|
||||||
// update top toolbar
|
// update top toolbar
|
||||||
UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) {
|
UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) {
|
||||||
fromVC.topToolbar.alpha = 0
|
fromVC.closeButton.alpha = 0
|
||||||
}
|
}
|
||||||
animator.addCompletion { position in
|
animator.addCompletion { position in
|
||||||
UIView.animate(withDuration: 0.33, delay: 0, options: [.curveEaseInOut]) {
|
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.contentMode = .scaleAspectFill
|
||||||
mediaPreviewTransitionContext.snapshot.clipsToBounds = true
|
mediaPreviewTransitionContext.snapshot.clipsToBounds = true
|
||||||
transitionMaskView.addSubview(mediaPreviewTransitionContext.snapshot)
|
transitionMaskView.addSubview(mediaPreviewTransitionContext.snapshot)
|
||||||
fromVC.view.bringSubviewToFront(fromVC.topToolbar)
|
fromVC.view.bringSubviewToFront(fromVC.closeButton)
|
||||||
|
|
||||||
transitionItem.transitionView = mediaPreviewTransitionContext.transitionView
|
transitionItem.transitionView = mediaPreviewTransitionContext.transitionView
|
||||||
transitionItem.snapshotTransitioning = mediaPreviewTransitionContext.snapshot
|
transitionItem.snapshotTransitioning = mediaPreviewTransitionContext.snapshot
|
||||||
|
|
Loading…
Reference in New Issue