Compare commits
No commits in common. "d96ec2a73297378268777305fa120db2f0dd8cf8" and "eafb506d64d93a4edcc00ccce770949d87122147" have entirely different histories.
d96ec2a732
...
eafb506d64
|
@ -91,33 +91,23 @@ class GalleryItemViewController: UIViewController {
|
||||||
view.addSubview(topControlsView)
|
view.addSubview(topControlsView)
|
||||||
|
|
||||||
var shareConfig = UIButton.Configuration.gray()
|
var shareConfig = UIButton.Configuration.gray()
|
||||||
shareConfig.cornerStyle = .dynamic
|
shareConfig.cornerStyle = .capsule
|
||||||
shareConfig.background.backgroundColor = .black.withAlphaComponent(0.25)
|
shareConfig.background.backgroundColor = .black.withAlphaComponent(0.25)
|
||||||
shareConfig.baseForegroundColor = .white
|
shareConfig.baseForegroundColor = .white
|
||||||
shareConfig.image = UIImage(systemName: "square.and.arrow.up")
|
shareConfig.image = UIImage(systemName: "square.and.arrow.up")
|
||||||
shareConfig.contentInsets = NSDirectionalEdgeInsets(top: 4, leading: 4, bottom: 4, trailing: 4)
|
|
||||||
shareButton = UIButton(configuration: shareConfig)
|
shareButton = UIButton(configuration: shareConfig)
|
||||||
shareButton.addTarget(self, action: #selector(shareButtonPressed), for: .touchUpInside)
|
shareButton.addTarget(self, action: #selector(shareButtonPressed), for: .touchUpInside)
|
||||||
shareButton.isPointerInteractionEnabled = true
|
|
||||||
shareButton.pointerStyleProvider = { button, effect, shape in
|
|
||||||
return UIPointerStyle(effect: .highlight(effect.preview), shape: .roundedRect(button.frame))
|
|
||||||
}
|
|
||||||
shareButton.translatesAutoresizingMaskIntoConstraints = false
|
shareButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
updateShareButton()
|
updateShareButton()
|
||||||
topControlsView.addSubview(shareButton)
|
topControlsView.addSubview(shareButton)
|
||||||
|
|
||||||
var closeConfig = UIButton.Configuration.gray()
|
var closeConfig = UIButton.Configuration.gray()
|
||||||
closeConfig.cornerStyle = .dynamic
|
closeConfig.cornerStyle = .capsule
|
||||||
closeConfig.background.backgroundColor = .black.withAlphaComponent(0.25)
|
closeConfig.background.backgroundColor = .black.withAlphaComponent(0.25)
|
||||||
closeConfig.baseForegroundColor = .white
|
closeConfig.baseForegroundColor = .white
|
||||||
closeConfig.image = UIImage(systemName: "xmark")
|
closeConfig.image = UIImage(systemName: "xmark")
|
||||||
closeConfig.contentInsets = NSDirectionalEdgeInsets(top: 4, leading: 4, bottom: 4, trailing: 4)
|
|
||||||
let closeButton = UIButton(configuration: closeConfig)
|
let closeButton = UIButton(configuration: closeConfig)
|
||||||
closeButton.addTarget(self, action: #selector(closeButtonPressed), for: .touchUpInside)
|
closeButton.addTarget(self, action: #selector(closeButtonPressed), for: .touchUpInside)
|
||||||
closeButton.isPointerInteractionEnabled = true
|
|
||||||
closeButton.pointerStyleProvider = { button, effect, shape in
|
|
||||||
return UIPointerStyle(effect: .highlight(effect.preview), shape: .roundedRect(button.frame))
|
|
||||||
}
|
|
||||||
closeButton.translatesAutoresizingMaskIntoConstraints = false
|
closeButton.translatesAutoresizingMaskIntoConstraints = false
|
||||||
topControlsView.addSubview(closeButton)
|
topControlsView.addSubview(closeButton)
|
||||||
|
|
||||||
|
@ -170,12 +160,10 @@ class GalleryItemViewController: UIViewController {
|
||||||
shareButtonLeadingConstraint,
|
shareButtonLeadingConstraint,
|
||||||
shareButtonTopConstraint,
|
shareButtonTopConstraint,
|
||||||
shareButton.bottomAnchor.constraint(equalTo: topControlsView.bottomAnchor),
|
shareButton.bottomAnchor.constraint(equalTo: topControlsView.bottomAnchor),
|
||||||
shareButton.widthAnchor.constraint(equalTo: shareButton.heightAnchor),
|
|
||||||
|
|
||||||
closeButtonTrailingConstraint,
|
closeButtonTrailingConstraint,
|
||||||
closeButtonTopConstraint,
|
closeButtonTopConstraint,
|
||||||
closeButton.bottomAnchor.constraint(equalTo: topControlsView.bottomAnchor),
|
closeButton.bottomAnchor.constraint(equalTo: topControlsView.bottomAnchor),
|
||||||
closeButton.widthAnchor.constraint(equalTo: closeButton.heightAnchor),
|
|
||||||
|
|
||||||
bottomControlsView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
bottomControlsView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
bottomControlsView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
bottomControlsView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
|
@ -184,8 +172,6 @@ class GalleryItemViewController: UIViewController {
|
||||||
captionTextView.heightAnchor.constraint(equalToConstant: 150),
|
captionTextView.heightAnchor.constraint(equalToConstant: 150),
|
||||||
])
|
])
|
||||||
|
|
||||||
updateTopControlsInsets()
|
|
||||||
|
|
||||||
singleTap = UITapGestureRecognizer(target: self, action: #selector(viewPressed))
|
singleTap = UITapGestureRecognizer(target: self, action: #selector(viewPressed))
|
||||||
singleTap.delegate = self
|
singleTap.delegate = self
|
||||||
doubleTap = UITapGestureRecognizer(target: self, action: #selector(viewDoublePressed))
|
doubleTap = UITapGestureRecognizer(target: self, action: #selector(viewDoublePressed))
|
||||||
|
@ -372,11 +358,6 @@ class GalleryItemViewController: UIViewController {
|
||||||
shareButtonTopConstraint.constant = 24
|
shareButtonTopConstraint.constant = 24
|
||||||
closeButtonTrailingConstraint.constant = 24
|
closeButtonTrailingConstraint.constant = 24
|
||||||
closeButtonTopConstraint.constant = 24
|
closeButtonTopConstraint.constant = 24
|
||||||
} else {
|
|
||||||
shareButtonLeadingConstraint.constant = 8
|
|
||||||
shareButtonTopConstraint.constant = 8
|
|
||||||
closeButtonTrailingConstraint.constant = 8
|
|
||||||
closeButtonTopConstraint.constant = 8
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,8 +102,6 @@ class GalleryPresentationAnimationController: NSObject, UIViewControllerAnimated
|
||||||
}
|
}
|
||||||
|
|
||||||
animator.addCompletion { _ in
|
animator.addCompletion { _ in
|
||||||
dimmingView.removeFromSuperview()
|
|
||||||
|
|
||||||
to.view.backgroundColor = .black
|
to.view.backgroundColor = .black
|
||||||
|
|
||||||
if sourceToDestTransform != nil {
|
if sourceToDestTransform != nil {
|
||||||
|
|
|
@ -348,8 +348,6 @@ private class MuteButton: UIControl {
|
||||||
imageView.centerXAnchor.constraint(equalTo: centerXAnchor),
|
imageView.centerXAnchor.constraint(equalTo: centerXAnchor),
|
||||||
imageView.centerYAnchor.constraint(equalTo: centerYAnchor),
|
imageView.centerYAnchor.constraint(equalTo: centerYAnchor),
|
||||||
])
|
])
|
||||||
|
|
||||||
addInteraction(UIPointerInteraction(delegate: nil))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
@ -397,8 +395,6 @@ private class MenuButton: UIControl {
|
||||||
|
|
||||||
isContextMenuInteractionEnabled = true
|
isContextMenuInteractionEnabled = true
|
||||||
showsMenuAsPrimaryAction = true
|
showsMenuAsPrimaryAction = true
|
||||||
|
|
||||||
addInteraction(UIPointerInteraction(delegate: nil))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
|
|
@ -158,8 +158,6 @@ private class VideoOverlayButton: UIControl {
|
||||||
imageView.topAnchor.constraint(equalTo: topAnchor, constant: 8),
|
imageView.topAnchor.constraint(equalTo: topAnchor, constant: 8),
|
||||||
imageView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8),
|
imageView.bottomAnchor.constraint(equalTo: bottomAnchor, constant: -8),
|
||||||
])
|
])
|
||||||
|
|
||||||
addInteraction(UIPointerInteraction(delegate: self))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
required init?(coder: NSCoder) {
|
required init?(coder: NSCoder) {
|
||||||
|
@ -177,25 +175,21 @@ private class VideoOverlayButton: UIControl {
|
||||||
}
|
}
|
||||||
|
|
||||||
override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
|
override func beginTracking(_ touch: UITouch, with event: UIEvent?) -> Bool {
|
||||||
if touch.type != .indirectPointer {
|
|
||||||
UIView.animate(withDuration: 0.2) {
|
UIView.animate(withDuration: 0.2) {
|
||||||
self.backgroundView.alpha = 1
|
self.backgroundView.alpha = 1
|
||||||
self.backgroundView.transform = CGAffineTransform(scaleX: 1/0.8, y: 1/0.8)
|
self.backgroundView.transform = CGAffineTransform(scaleX: 1/0.8, y: 1/0.8)
|
||||||
self.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
|
self.transform = CGAffineTransform(scaleX: 0.8, y: 0.8)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return super.beginTracking(touch, with: event)
|
return super.beginTracking(touch, with: event)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
|
override func endTracking(_ touch: UITouch?, with event: UIEvent?) {
|
||||||
if touch?.type != .indirectPointer {
|
|
||||||
UIView.animate(withDuration: 0.2) {
|
UIView.animate(withDuration: 0.2) {
|
||||||
self.backgroundView.alpha = 0
|
self.backgroundView.alpha = 0
|
||||||
self.backgroundView.transform = .identity
|
self.backgroundView.transform = .identity
|
||||||
self.transform = .identity
|
self.transform = .identity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||||
if gestureRecognizer is UITapGestureRecognizer {
|
if gestureRecognizer is UITapGestureRecognizer {
|
||||||
|
@ -204,14 +198,3 @@ private class VideoOverlayButton: UIControl {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension VideoOverlayButton: UIPointerInteractionDelegate {
|
|
||||||
func pointerInteraction(_ interaction: UIPointerInteraction, regionFor request: UIPointerRegionRequest, defaultRegion: UIPointerRegion) -> UIPointerRegion? {
|
|
||||||
return UIPointerRegion(rect: bounds)
|
|
||||||
}
|
|
||||||
|
|
||||||
func pointerInteraction(_ interaction: UIPointerInteraction, styleFor region: UIPointerRegion) -> UIPointerStyle? {
|
|
||||||
let preview = UITargetedPreview(view: self)
|
|
||||||
return UIPointerStyle(effect: .highlight(preview), shape: .path(UIBezierPath(ovalIn: frame)))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -499,7 +499,6 @@ extension AttachmentView: UIContextMenuInteractionDelegate {
|
||||||
var actions = [
|
var actions = [
|
||||||
UIAction(title: "Share…", image: UIImage(systemName: "square.and.arrow.up")) { [unowned self] _ in
|
UIAction(title: "Share…", image: UIImage(systemName: "square.and.arrow.up")) { [unowned self] _ in
|
||||||
let vc = UIActivityViewController(activityItems: [itemSource], applicationActivities: [SaveToPhotosActivity()])
|
let vc = UIActivityViewController(activityItems: [itemSource], applicationActivities: [SaveToPhotosActivity()])
|
||||||
vc.popoverPresentationController?.sourceView = self
|
|
||||||
self.delegate?.attachmentViewPresent(vc, animated: true)
|
self.delegate?.attachmentViewPresent(vc, animated: true)
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue