Catalyst: Fix gallery close/share buttons

This commit is contained in:
Shadowfacts 2024-03-31 14:12:07 -04:00
parent 23e5e87915
commit 908c4ee085
1 changed files with 9 additions and 2 deletions

View File

@ -102,6 +102,7 @@ class GalleryItemViewController: UIViewController {
shareButton.pointerStyleProvider = { button, effect, shape in shareButton.pointerStyleProvider = { button, effect, shape in
return UIPointerStyle(effect: .highlight(effect.preview), shape: .roundedRect(button.frame)) return UIPointerStyle(effect: .highlight(effect.preview), shape: .roundedRect(button.frame))
} }
shareButton.preferredBehavioralStyle = .pad
shareButton.translatesAutoresizingMaskIntoConstraints = false shareButton.translatesAutoresizingMaskIntoConstraints = false
updateShareButton() updateShareButton()
topControlsView.addSubview(shareButton) topControlsView.addSubview(shareButton)
@ -118,6 +119,7 @@ class GalleryItemViewController: UIViewController {
closeButton.pointerStyleProvider = { button, effect, shape in closeButton.pointerStyleProvider = { button, effect, shape in
return UIPointerStyle(effect: .highlight(effect.preview), shape: .roundedRect(button.frame)) return UIPointerStyle(effect: .highlight(effect.preview), shape: .roundedRect(button.frame))
} }
closeButton.preferredBehavioralStyle = .pad
closeButton.translatesAutoresizingMaskIntoConstraints = false closeButton.translatesAutoresizingMaskIntoConstraints = false
topControlsView.addSubview(closeButton) topControlsView.addSubview(closeButton)
@ -152,10 +154,15 @@ class GalleryItemViewController: UIViewController {
updateCaptionTextView() updateCaptionTextView()
bottomControlsView.addArrangedSubview(captionTextView) bottomControlsView.addArrangedSubview(captionTextView)
closeButtonTrailingConstraint = topControlsView.trailingAnchor.constraint(equalTo: closeButton.trailingAnchor) #if targetEnvironment(macCatalyst)
closeButtonTopConstraint = closeButton.topAnchor.constraint(equalTo: topControlsView.safeAreaLayoutGuide.topAnchor)
shareButtonTopConstraint = shareButton.topAnchor.constraint(equalTo: topControlsView.safeAreaLayoutGuide.topAnchor)
#else
closeButtonTopConstraint = closeButton.topAnchor.constraint(equalTo: topControlsView.topAnchor) closeButtonTopConstraint = closeButton.topAnchor.constraint(equalTo: topControlsView.topAnchor)
shareButtonLeadingConstraint = shareButton.leadingAnchor.constraint(equalTo: topControlsView.leadingAnchor)
shareButtonTopConstraint = shareButton.topAnchor.constraint(equalTo: topControlsView.topAnchor) shareButtonTopConstraint = shareButton.topAnchor.constraint(equalTo: topControlsView.topAnchor)
#endif
closeButtonTrailingConstraint = topControlsView.trailingAnchor.constraint(equalTo: closeButton.trailingAnchor)
shareButtonLeadingConstraint = shareButton.leadingAnchor.constraint(equalTo: topControlsView.leadingAnchor)
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor), scrollView.leadingAnchor.constraint(equalTo: view.leadingAnchor),