diff --git a/Mastodon/Scene/Compose/ComposeViewController.swift b/Mastodon/Scene/Compose/ComposeViewController.swift index 0cc4557a4..ca33487ab 100644 --- a/Mastodon/Scene/Compose/ComposeViewController.swift +++ b/Mastodon/Scene/Compose/ComposeViewController.swift @@ -58,12 +58,7 @@ final class ComposeViewController: UIViewController, NeedsDependency { let shadowBackgroundContainer = ShadowBackgroundContainer() publishButton.translatesAutoresizingMaskIntoConstraints = false shadowBackgroundContainer.addSubview(publishButton) - NSLayoutConstraint.activate([ - publishButton.topAnchor.constraint(equalTo: shadowBackgroundContainer.topAnchor), - publishButton.leadingAnchor.constraint(equalTo: shadowBackgroundContainer.leadingAnchor), - publishButton.trailingAnchor.constraint(equalTo: shadowBackgroundContainer.trailingAnchor), - publishButton.bottomAnchor.constraint(equalTo: shadowBackgroundContainer.bottomAnchor), - ]) + publishButton.pinToParent() let barButtonItem = UIBarButtonItem(customView: shadowBackgroundContainer) return barButtonItem }() @@ -102,12 +97,7 @@ extension ComposeViewController { addChild(composeContentViewController) composeContentViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(composeContentViewController.view) - NSLayoutConstraint.activate([ - composeContentViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - composeContentViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - composeContentViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - composeContentViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + composeContentViewController.view.pinToParent() composeContentViewController.didMove(toParent: self) // bind title diff --git a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift index 31635dc85..870bfc72a 100644 --- a/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift +++ b/Mastodon/Scene/Discovery/Community/DiscoveryCommunityViewController.swift @@ -57,12 +57,7 @@ extension DiscoveryCommunityViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.refreshControl = refreshControl refreshControl.addTarget(self, action: #selector(DiscoveryCommunityViewController.refreshControlValueChanged(_:)), for: .valueChanged) diff --git a/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift b/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift index 52e5e1856..dec1d9c72 100644 --- a/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift +++ b/Mastodon/Scene/Discovery/ForYou/DiscoveryForYouViewController.swift @@ -56,12 +56,7 @@ extension DiscoveryForYouViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift index b56098b58..64d1231fe 100644 --- a/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift +++ b/Mastodon/Scene/Discovery/Hashtags/DiscoveryHashtagsViewController.swift @@ -56,12 +56,7 @@ extension DiscoveryHashtagsViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.refreshControl = refreshControl refreshControl.addTarget(self, action: #selector(DiscoveryHashtagsViewController.refreshControlValueChanged(_:)), for: .valueChanged) diff --git a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift index 558830473..4884aafac 100644 --- a/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift +++ b/Mastodon/Scene/Discovery/News/DiscoveryNewsViewController.swift @@ -56,12 +56,7 @@ extension DiscoveryNewsViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift index 893f564a3..9d772a27e 100644 --- a/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift +++ b/Mastodon/Scene/Discovery/Posts/DiscoveryPostsViewController.swift @@ -58,12 +58,7 @@ extension DiscoveryPostsViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() discoveryIntroBannerView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(discoveryIntroBannerView) diff --git a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift index aad97283c..4a0be3816 100644 --- a/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift +++ b/Mastodon/Scene/HashtagTimeline/HashtagTimelineViewController.swift @@ -80,12 +80,7 @@ extension HashtagTimelineViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift index c7633fffa..3caafef3d 100644 --- a/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift +++ b/Mastodon/Scene/HomeTimeline/HomeTimelineViewController.swift @@ -158,12 +158,7 @@ extension HomeTimelineViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() // // layout publish progress publishProgressView.translatesAutoresizingMaskIntoConstraints = false diff --git a/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift b/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift index 400b4ee98..38b80fe28 100644 --- a/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift +++ b/Mastodon/Scene/HomeTimeline/View/HomeTimelineNavigationBarTitleView.swift @@ -47,12 +47,7 @@ extension HomeTimelineNavigationBarTitleView { private func _init() { containerView.translatesAutoresizingMaskIntoConstraints = false addSubview(containerView) - NSLayoutConstraint.activate([ - containerView.topAnchor.constraint(equalTo: topAnchor), - containerView.leadingAnchor.constraint(equalTo: leadingAnchor), - containerView.trailingAnchor.constraint(equalTo: trailingAnchor), - containerView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + containerView.pinToParent() containerView.addArrangedSubview(logoButton) button.translatesAutoresizingMaskIntoConstraints = false diff --git a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift index 7f80bfe3c..5dede76df 100644 --- a/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift +++ b/Mastodon/Scene/MediaPreview/MediaPreviewViewController.swift @@ -65,12 +65,7 @@ extension MediaPreviewViewController { pagingViewController.view.translatesAutoresizingMaskIntoConstraints = false addChild(pagingViewController) visualEffectView.contentView.addSubview(pagingViewController.view) - NSLayoutConstraint.activate([ - visualEffectView.topAnchor.constraint(equalTo: pagingViewController.view.topAnchor), - visualEffectView.bottomAnchor.constraint(equalTo: pagingViewController.view.bottomAnchor), - visualEffectView.leadingAnchor.constraint(equalTo: pagingViewController.view.leadingAnchor), - visualEffectView.trailingAnchor.constraint(equalTo: pagingViewController.view.trailingAnchor), - ]) + visualEffectView.pinTo(to: pagingViewController.view) pagingViewController.didMove(toParent: self) closeButtonBackground.translatesAutoresizingMaskIntoConstraints = false diff --git a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift index 7bdbbfed2..3981c485a 100644 --- a/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift +++ b/Mastodon/Scene/MediaPreview/Video/MediaPreviewVideoViewController.swift @@ -39,23 +39,13 @@ extension MediaPreviewVideoViewController { addChild(playerViewController) playerViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(playerViewController.view) - NSLayoutConstraint.activate([ - playerViewController.view.centerXAnchor.constraint(equalTo: view.centerXAnchor), - playerViewController.view.centerYAnchor.constraint(equalTo: view.centerYAnchor), - playerViewController.view.widthAnchor.constraint(equalTo: view.widthAnchor), - playerViewController.view.heightAnchor.constraint(equalTo: view.heightAnchor), - ]) + playerViewController.view.pinToParent() playerViewController.didMove(toParent: self) if let contentOverlayView = playerViewController.contentOverlayView { previewImageView.translatesAutoresizingMaskIntoConstraints = false contentOverlayView.addSubview(previewImageView) - NSLayoutConstraint.activate([ - previewImageView.topAnchor.constraint(equalTo: contentOverlayView.topAnchor), - previewImageView.leadingAnchor.constraint(equalTo: contentOverlayView.leadingAnchor), - previewImageView.trailingAnchor.constraint(equalTo: contentOverlayView.trailingAnchor), - previewImageView.bottomAnchor.constraint(equalTo: contentOverlayView.bottomAnchor), - ]) + previewImageView.pinToParent() } playerViewController.delegate = self diff --git a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift index d088bb783..9b7416afc 100644 --- a/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift +++ b/Mastodon/Scene/Notification/NotificationTimeline/NotificationTimelineViewController.swift @@ -55,12 +55,7 @@ extension NotificationTimelineViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift index bfa3343bd..aba5a87dc 100644 --- a/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift +++ b/Mastodon/Scene/Onboarding/PickServer/View/PickServerCategoryView.swift @@ -48,12 +48,7 @@ extension PickServerCategoryView { container.translatesAutoresizingMaskIntoConstraints = false addSubview(container) - NSLayoutConstraint.activate([ - container.topAnchor.constraint(equalTo: topAnchor), - container.leadingAnchor.constraint(equalTo: leadingAnchor), - container.trailingAnchor.constraint(equalTo: trailingAnchor), - container.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + container.pinToParent() container.addArrangedSubview(titleLabel) highlightedIndicatorView.translatesAutoresizingMaskIntoConstraints = false diff --git a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift index dc5152f98..f239e59b7 100644 --- a/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift +++ b/Mastodon/Scene/Onboarding/Register/MastodonRegisterViewController.swift @@ -85,12 +85,7 @@ extension MastodonRegisterViewController { addChild(hostingViewController) hostingViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(hostingViewController.view) - NSLayoutConstraint.activate([ - hostingViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - hostingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - hostingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - hostingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + hostingViewController.view.pinToParent() navigationActionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(navigationActionView) diff --git a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift index 178d489be..d6870785c 100644 --- a/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift +++ b/Mastodon/Scene/Onboarding/ResendEmail/MastodonResendEmailViewController.swift @@ -49,12 +49,7 @@ extension MastodonResendEmailViewController { webView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(webView) - NSLayoutConstraint.activate([ - webView.topAnchor.constraint(equalTo: view.topAnchor), - webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - webView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - webView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + webView.pinToParent() let request = URLRequest(url: viewModel.resendEmailURL) webView.navigationDelegate = self.viewModel.navigationDelegate diff --git a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift index e22ea5748..ea0b58e28 100644 --- a/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift +++ b/Mastodon/Scene/Onboarding/ServerRules/MastodonServerRulesViewController.swift @@ -69,12 +69,7 @@ extension MastodonServerRulesViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() navigationActionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(navigationActionView) diff --git a/Mastodon/Scene/Onboarding/Share/NavigationActionView.swift b/Mastodon/Scene/Onboarding/Share/NavigationActionView.swift index c3236bdb4..54b473df8 100644 --- a/Mastodon/Scene/Onboarding/Share/NavigationActionView.swift +++ b/Mastodon/Scene/Onboarding/Share/NavigationActionView.swift @@ -84,21 +84,11 @@ extension NavigationActionView { backButton.translatesAutoresizingMaskIntoConstraints = false backButtonShadowContainer.addSubview(backButton) - NSLayoutConstraint.activate([ - backButton.topAnchor.constraint(equalTo: backButtonShadowContainer.topAnchor), - backButton.leadingAnchor.constraint(equalTo: backButtonShadowContainer.leadingAnchor), - backButton.trailingAnchor.constraint(equalTo: backButtonShadowContainer.trailingAnchor), - backButton.bottomAnchor.constraint(equalTo: backButtonShadowContainer.bottomAnchor), - ]) + backButton.pinToParent() nextButton.translatesAutoresizingMaskIntoConstraints = false nextButtonShadowContainer.addSubview(nextButton) - NSLayoutConstraint.activate([ - nextButton.topAnchor.constraint(equalTo: nextButtonShadowContainer.topAnchor), - nextButton.leadingAnchor.constraint(equalTo: nextButtonShadowContainer.leadingAnchor), - nextButton.trailingAnchor.constraint(equalTo: nextButtonShadowContainer.trailingAnchor), - nextButton.bottomAnchor.constraint(equalTo: nextButtonShadowContainer.bottomAnchor), - ]) + nextButton.pinToParent() } } diff --git a/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift b/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift index 537102dc9..ac2e5b171 100644 --- a/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift +++ b/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift @@ -20,12 +20,7 @@ extension OnboardingNavigationController { gradientBorderView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(gradientBorderView) - NSLayoutConstraint.activate([ - gradientBorderView.topAnchor.constraint(equalTo: view.topAnchor), - gradientBorderView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - gradientBorderView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - gradientBorderView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + gradientBorderView.pinToParent() updateBorderViewDisplay() } diff --git a/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift b/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift index 0530539a2..1fca1afef 100644 --- a/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift +++ b/Mastodon/Scene/Onboarding/Welcome/View/WelcomeIllustrationView.swift @@ -96,12 +96,7 @@ extension WelcomeIllustrationView { ].forEach { imageView in imageView.translatesAutoresizingMaskIntoConstraints = false addSubview(imageView) - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: cloudBaseImageView.topAnchor), - imageView.leadingAnchor.constraint(equalTo: cloudBaseImageView.leadingAnchor), - imageView.trailingAnchor.constraint(equalTo: cloudBaseImageView.trailingAnchor), - imageView.bottomAnchor.constraint(equalTo: cloudBaseImageView.bottomAnchor), - ]) + imageView.pinTo(to: cloudBaseImageView) } aspectLayoutConstraint = cloudBaseImageView.widthAnchor.constraint(equalTo: cloudBaseImageView.heightAnchor, multiplier: layout.artworkImageSize.width / layout.artworkImageSize.height) diff --git a/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift b/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift index 32696d197..86a4af800 100644 --- a/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift +++ b/Mastodon/Scene/Onboarding/Welcome/WelcomeViewController.swift @@ -124,22 +124,12 @@ extension WelcomeViewController { signUpButtonShadowView.translatesAutoresizingMaskIntoConstraints = false buttonContainer.addSubview(signUpButtonShadowView) buttonContainer.sendSubviewToBack(signUpButtonShadowView) - NSLayoutConstraint.activate([ - signUpButtonShadowView.topAnchor.constraint(equalTo: signUpButton.topAnchor), - signUpButtonShadowView.leadingAnchor.constraint(equalTo: signUpButton.leadingAnchor), - signUpButtonShadowView.trailingAnchor.constraint(equalTo: signUpButton.trailingAnchor), - signUpButtonShadowView.bottomAnchor.constraint(equalTo: signUpButton.bottomAnchor), - ]) + signUpButtonShadowView.pinTo(to: signUpButton) signInButtonShadowView.translatesAutoresizingMaskIntoConstraints = false buttonContainer.addSubview(signInButtonShadowView) buttonContainer.sendSubviewToBack(signInButtonShadowView) - NSLayoutConstraint.activate([ - signInButtonShadowView.topAnchor.constraint(equalTo: signInButton.topAnchor), - signInButtonShadowView.leadingAnchor.constraint(equalTo: signInButton.leadingAnchor), - signInButtonShadowView.trailingAnchor.constraint(equalTo: signInButton.trailingAnchor), - signInButtonShadowView.bottomAnchor.constraint(equalTo: signInButton.bottomAnchor), - ]) + signInButtonShadowView.pinTo(to: signInButton) signUpButton.addTarget(self, action: #selector(signUpButtonDidClicked(_:)), for: .touchUpInside) signInButton.addTarget(self, action: #selector(signInButtonDidClicked(_:)), for: .touchUpInside) diff --git a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift index eb1e6b39c..fe92d2ac4 100644 --- a/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift +++ b/Mastodon/Scene/Profile/About/ProfileAboutViewController.swift @@ -60,12 +60,7 @@ extension ProfileAboutViewController { collectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(collectionView) - NSLayoutConstraint.activate([ - collectionView.topAnchor.constraint(equalTo: view.topAnchor), - collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + collectionView.pinToParent() collectionView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift b/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift index 5edec2618..458c47335 100644 --- a/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift +++ b/Mastodon/Scene/Profile/Bookmark/BookmarkViewController.swift @@ -64,12 +64,7 @@ extension BookmarkViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift b/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift index b6d6f8313..3595303d9 100644 --- a/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift +++ b/Mastodon/Scene/Profile/FamiliarFollowers/FamiliarFollowersViewController.swift @@ -53,12 +53,7 @@ extension FamiliarFollowersViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift b/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift index c15adcf83..19f25f3ad 100644 --- a/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift +++ b/Mastodon/Scene/Profile/Favorite/FavoriteViewController.swift @@ -67,12 +67,7 @@ extension FavoriteViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift b/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift index 190fa27e5..c111d13d0 100644 --- a/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift +++ b/Mastodon/Scene/Profile/Follower/FollowerListViewController.swift @@ -58,12 +58,7 @@ extension FollowerListViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/Following/FollowingListViewController.swift b/Mastodon/Scene/Profile/Following/FollowingListViewController.swift index e16b600c2..3fa65918a 100644 --- a/Mastodon/Scene/Profile/Following/FollowingListViewController.swift +++ b/Mastodon/Scene/Profile/Following/FollowingListViewController.swift @@ -58,12 +58,7 @@ extension FollowingListViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift index a9941453b..cf2443552 100644 --- a/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift +++ b/Mastodon/Scene/Profile/Header/View/ProfileHeaderView.swift @@ -275,21 +275,11 @@ extension ProfileHeaderView { bannerImageViewOverlayVisualEffectView.translatesAutoresizingMaskIntoConstraints = false bannerImageView.addSubview(bannerImageViewOverlayVisualEffectView) - NSLayoutConstraint.activate([ - bannerImageViewOverlayVisualEffectView.topAnchor.constraint(equalTo: bannerImageView.topAnchor), - bannerImageViewOverlayVisualEffectView.leadingAnchor.constraint(equalTo: bannerImageView.leadingAnchor), - bannerImageViewOverlayVisualEffectView.trailingAnchor.constraint(equalTo: bannerImageView.trailingAnchor), - bannerImageViewOverlayVisualEffectView.bottomAnchor.constraint(equalTo: bannerImageView.bottomAnchor), - ]) + bannerImageViewOverlayVisualEffectView.pinToParent() editBannerButton.translatesAutoresizingMaskIntoConstraints = false bannerContainerView.addSubview(editBannerButton) - NSLayoutConstraint.activate([ - editBannerButton.topAnchor.constraint(equalTo: bannerImageView.topAnchor), - editBannerButton.leadingAnchor.constraint(equalTo: bannerImageView.leadingAnchor), - editBannerButton.trailingAnchor.constraint(equalTo: bannerImageView.trailingAnchor), - editBannerButton.bottomAnchor.constraint(equalTo: bannerImageView.bottomAnchor), - ]) + editBannerButton.pinTo(to: bannerImageView) bannerContainerView.isUserInteractionEnabled = true // follows you @@ -306,12 +296,7 @@ extension ProfileHeaderView { followsYouVibrantEffectView.translatesAutoresizingMaskIntoConstraints = false followsYouBlurEffectView.contentView.addSubview(followsYouVibrantEffectView) - NSLayoutConstraint.activate([ - followsYouVibrantEffectView.topAnchor.constraint(equalTo: followsYouBlurEffectView.topAnchor), - followsYouVibrantEffectView.leadingAnchor.constraint(equalTo: followsYouBlurEffectView.leadingAnchor), - followsYouVibrantEffectView.trailingAnchor.constraint(equalTo: followsYouBlurEffectView.trailingAnchor), - followsYouVibrantEffectView.bottomAnchor.constraint(equalTo: followsYouBlurEffectView.bottomAnchor), - ]) + followsYouVibrantEffectView.pinTo(to: followsYouBlurEffectView) followsYouLabel.translatesAutoresizingMaskIntoConstraints = false followsYouVibrantEffectView.contentView.addSubview(followsYouLabel) @@ -347,30 +332,15 @@ extension ProfileHeaderView { avatarImageViewOverlayVisualEffectView.translatesAutoresizingMaskIntoConstraints = false avatarImageViewBackgroundView.addSubview(avatarImageViewOverlayVisualEffectView) - NSLayoutConstraint.activate([ - avatarImageViewOverlayVisualEffectView.topAnchor.constraint(equalTo: avatarImageViewBackgroundView.topAnchor), - avatarImageViewOverlayVisualEffectView.leadingAnchor.constraint(equalTo: avatarImageViewBackgroundView.leadingAnchor), - avatarImageViewOverlayVisualEffectView.trailingAnchor.constraint(equalTo: avatarImageViewBackgroundView.trailingAnchor), - avatarImageViewOverlayVisualEffectView.bottomAnchor.constraint(equalTo: avatarImageViewBackgroundView.bottomAnchor), - ]) + avatarImageViewOverlayVisualEffectView.pinToParent() editAvatarBackgroundView.translatesAutoresizingMaskIntoConstraints = false avatarButton.addSubview(editAvatarBackgroundView) - NSLayoutConstraint.activate([ - editAvatarBackgroundView.topAnchor.constraint(equalTo: avatarButton.topAnchor), - editAvatarBackgroundView.leadingAnchor.constraint(equalTo: avatarButton.leadingAnchor), - editAvatarBackgroundView.trailingAnchor.constraint(equalTo: avatarButton.trailingAnchor), - editAvatarBackgroundView.bottomAnchor.constraint(equalTo: avatarButton.bottomAnchor), - ]) + editAvatarBackgroundView.pinToParent() editAvatarButtonOverlayIndicatorView.translatesAutoresizingMaskIntoConstraints = false editAvatarBackgroundView.addSubview(editAvatarButtonOverlayIndicatorView) - NSLayoutConstraint.activate([ - editAvatarButtonOverlayIndicatorView.topAnchor.constraint(equalTo: editAvatarBackgroundView.topAnchor), - editAvatarButtonOverlayIndicatorView.leadingAnchor.constraint(equalTo: editAvatarBackgroundView.leadingAnchor), - editAvatarButtonOverlayIndicatorView.trailingAnchor.constraint(equalTo: editAvatarBackgroundView.trailingAnchor), - editAvatarButtonOverlayIndicatorView.bottomAnchor.constraint(equalTo: editAvatarBackgroundView.bottomAnchor), - ]) + editAvatarButtonOverlayIndicatorView.pinToParent() editAvatarBackgroundView.isUserInteractionEnabled = true avatarButton.isUserInteractionEnabled = true @@ -456,11 +426,8 @@ extension ProfileHeaderView { relationshipActionButton.translatesAutoresizingMaskIntoConstraints = false relationshipActionButtonShadowContainer.addSubview(relationshipActionButton) + relationshipActionButton.pinToParent() NSLayoutConstraint.activate([ - relationshipActionButton.topAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.topAnchor), - relationshipActionButton.leadingAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.leadingAnchor), - relationshipActionButton.trailingAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.trailingAnchor), - relationshipActionButton.bottomAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.bottomAnchor), relationshipActionButton.widthAnchor.constraint(greaterThanOrEqualToConstant: ProfileHeaderView.friendshipActionButtonSize.width).priority(.required - 1), relationshipActionButton.heightAnchor.constraint(equalToConstant: ProfileHeaderView.friendshipActionButtonSize.height).priority(.defaultHigh), ]) diff --git a/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift b/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift index db92617b7..27c539d18 100644 --- a/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift +++ b/Mastodon/Scene/Profile/Paging/ProfilePagingViewController.swift @@ -99,12 +99,7 @@ extension ProfilePagingViewController { if let buttonBarView = self.buttonBarView { buttonBarShadowView.translatesAutoresizingMaskIntoConstraints = false view.insertSubview(buttonBarShadowView, belowSubview: buttonBarView) - NSLayoutConstraint.activate([ - buttonBarShadowView.topAnchor.constraint(equalTo: buttonBarView.topAnchor), - buttonBarShadowView.leadingAnchor.constraint(equalTo: buttonBarView.leadingAnchor), - buttonBarShadowView.trailingAnchor.constraint(equalTo: buttonBarView.trailingAnchor), - buttonBarShadowView.bottomAnchor.constraint(equalTo: buttonBarView.bottomAnchor), - ]) + buttonBarShadowView.pinTo(to: buttonBarView) viewModel.$needsSetupBottomShadow .receive(on: DispatchQueue.main) diff --git a/Mastodon/Scene/Profile/ProfileViewController.swift b/Mastodon/Scene/Profile/ProfileViewController.swift index 4b3cd5b20..15548a5fc 100644 --- a/Mastodon/Scene/Profile/ProfileViewController.swift +++ b/Mastodon/Scene/Profile/ProfileViewController.swift @@ -259,12 +259,7 @@ extension ProfileViewController { tabBarPagerController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tabBarPagerController.view) tabBarPagerController.didMove(toParent: self) - NSLayoutConstraint.activate([ - tabBarPagerController.view.topAnchor.constraint(equalTo: view.topAnchor), - tabBarPagerController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tabBarPagerController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tabBarPagerController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tabBarPagerController.view.pinToParent() tabBarPagerController.delegate = self tabBarPagerController.dataSource = self diff --git a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift index 8a983da33..6cdd6a594 100644 --- a/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift +++ b/Mastodon/Scene/Profile/Timeline/UserTimelineViewController.swift @@ -60,12 +60,7 @@ extension UserTimelineViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift b/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift index ebce374e7..07316cd3d 100644 --- a/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift +++ b/Mastodon/Scene/Profile/UserLIst/FavoritedBy/FavoritedByViewController.swift @@ -61,12 +61,7 @@ extension FavoritedByViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift b/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift index 0688bcccb..a45c491fc 100644 --- a/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift +++ b/Mastodon/Scene/Profile/UserLIst/RebloggedBy/RebloggedByViewController.swift @@ -61,12 +61,7 @@ extension RebloggedByViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Report/Report/ReportViewController.swift b/Mastodon/Scene/Report/Report/ReportViewController.swift index 793f07b2e..fb0417a7f 100644 --- a/Mastodon/Scene/Report/Report/ReportViewController.swift +++ b/Mastodon/Scene/Report/Report/ReportViewController.swift @@ -61,12 +61,7 @@ extension ReportViewController { reportReasonViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(reportReasonViewController.view) reportReasonViewController.didMove(toParent: self) - NSLayoutConstraint.activate([ - reportReasonViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - reportReasonViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - reportReasonViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - reportReasonViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + reportReasonViewController.view.pinToParent() } } diff --git a/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift b/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift index 2e8e53d18..517873abe 100644 --- a/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift +++ b/Mastodon/Scene/Report/ReportReason/ReportReasonViewController.swift @@ -57,12 +57,7 @@ extension ReportReasonViewController { addChild(hostingViewController) hostingViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(hostingViewController.view) - NSLayoutConstraint.activate([ - hostingViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - hostingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - hostingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - hostingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + hostingViewController.view.pinToParent() navigationActionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(navigationActionView) diff --git a/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift b/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift index 10dcdf373..1d67ad6c3 100644 --- a/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift +++ b/Mastodon/Scene/Report/ReportResult/ReportResultViewController.swift @@ -60,12 +60,7 @@ extension ReportResultViewController { addChild(hostingViewController) hostingViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(hostingViewController.view) - NSLayoutConstraint.activate([ - hostingViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - hostingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - hostingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - hostingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + hostingViewController.view.pinToParent() navigationActionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(navigationActionView) diff --git a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift index 3f1cdf331..00be4d800 100644 --- a/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift +++ b/Mastodon/Scene/Report/ReportServerRules/ReportServerRulesViewController.swift @@ -63,12 +63,7 @@ extension ReportServerRulesViewController { addChild(hostingViewController) hostingViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(hostingViewController.view) - NSLayoutConstraint.activate([ - hostingViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - hostingViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - hostingViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - hostingViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + hostingViewController.view.pinToParent() navigationActionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(navigationActionView) diff --git a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift index d45c196cd..6f934e13d 100644 --- a/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift +++ b/Mastodon/Scene/Report/ReportStatus/ReportStatusViewController.swift @@ -80,12 +80,7 @@ extension ReportStatusViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift b/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift index e644c29ea..76f312273 100644 --- a/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift +++ b/Mastodon/Scene/Report/ReportSupplementary/ReportSupplementaryViewController.swift @@ -93,12 +93,7 @@ extension ReportSupplementaryViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Report/Share/Cell/ReportCommentTableViewCell.swift b/Mastodon/Scene/Report/Share/Cell/ReportCommentTableViewCell.swift index d735a094c..ad6ce252a 100644 --- a/Mastodon/Scene/Report/Share/Cell/ReportCommentTableViewCell.swift +++ b/Mastodon/Scene/Report/Share/Cell/ReportCommentTableViewCell.swift @@ -74,11 +74,8 @@ extension ReportCommentTableViewCell { commentTextView.translatesAutoresizingMaskIntoConstraints = false commentTextViewShadowBackgroundContainer.addSubview(commentTextView) + commentTextView.pinToParent() NSLayoutConstraint.activate([ - commentTextView.topAnchor.constraint(equalTo: commentTextViewShadowBackgroundContainer.topAnchor), - commentTextView.leadingAnchor.constraint(equalTo: commentTextViewShadowBackgroundContainer.leadingAnchor), - commentTextView.trailingAnchor.constraint(equalTo: commentTextViewShadowBackgroundContainer.trailingAnchor), - commentTextView.bottomAnchor.constraint(equalTo: commentTextViewShadowBackgroundContainer.bottomAnchor), commentTextView.heightAnchor.constraint(greaterThanOrEqualToConstant: 100).priority(.defaultHigh), ]) } diff --git a/Mastodon/Scene/Report/Share/Cell/ReportResultActionTableViewCell.swift b/Mastodon/Scene/Report/Share/Cell/ReportResultActionTableViewCell.swift index 9b605a0c7..1828035a6 100644 --- a/Mastodon/Scene/Report/Share/Cell/ReportResultActionTableViewCell.swift +++ b/Mastodon/Scene/Report/Share/Cell/ReportResultActionTableViewCell.swift @@ -103,12 +103,7 @@ extension ReportResultActionTableViewCell { reportBannerLabel.translatesAutoresizingMaskIntoConstraints = false reportBannerShadowContainer.addSubview(reportBannerLabel) - NSLayoutConstraint.activate([ - reportBannerLabel.topAnchor.constraint(equalTo: reportBannerShadowContainer.topAnchor), - reportBannerLabel.leadingAnchor.constraint(equalTo: reportBannerShadowContainer.leadingAnchor), - reportBannerLabel.trailingAnchor.constraint(equalTo: reportBannerShadowContainer.trailingAnchor), - reportBannerLabel.bottomAnchor.constraint(equalTo: reportBannerShadowContainer.bottomAnchor), - ]) + reportBannerLabel.pinToParent() } diff --git a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift index df0c66fab..df7373363 100644 --- a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift +++ b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift @@ -442,12 +442,7 @@ extension MainTabBarController { composeButton.translatesAutoresizingMaskIntoConstraints = false composeButttonShadowBackgroundContainer.addSubview(composeButton) - NSLayoutConstraint.activate([ - composeButton.topAnchor.constraint(equalTo: composeButttonShadowBackgroundContainer.topAnchor), - composeButton.leadingAnchor.constraint(equalTo: composeButttonShadowBackgroundContainer.leadingAnchor), - composeButton.trailingAnchor.constraint(equalTo: composeButttonShadowBackgroundContainer.trailingAnchor), - composeButton.bottomAnchor.constraint(equalTo: composeButttonShadowBackgroundContainer.bottomAnchor), - ]) + composeButton.pinToParent() composeButton.setContentHuggingPriority(.required - 1, for: .horizontal) composeButton.setContentHuggingPriority(.required - 1, for: .vertical) } diff --git a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift index 70e1239b6..0133648a2 100644 --- a/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift +++ b/Mastodon/Scene/Root/Sidebar/SidebarViewController.swift @@ -101,12 +101,7 @@ extension SidebarViewController { collectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(collectionView) - NSLayoutConstraint.activate([ - collectionView.topAnchor.constraint(equalTo: view.topAnchor), - collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + collectionView.pinToParent() secondaryCollectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(secondaryCollectionView) diff --git a/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift b/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift index 30f618625..4436459fb 100644 --- a/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift +++ b/Mastodon/Scene/Search/Search/Cell/TrendCollectionViewCell.swift @@ -48,12 +48,7 @@ extension TrendCollectionViewCell { trendView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(trendView) - NSLayoutConstraint.activate([ - trendView.topAnchor.constraint(equalTo: contentView.topAnchor), - trendView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - trendView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), - trendView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - ]) + trendView.pinToParent() } override func updateConfiguration(using state: UICellConfigurationState) { diff --git a/Mastodon/Scene/Search/Search/SearchViewController.swift b/Mastodon/Scene/Search/Search/SearchViewController.swift index d5ac8e6bf..c190a1a4c 100644 --- a/Mastodon/Scene/Search/Search/SearchViewController.swift +++ b/Mastodon/Scene/Search/Search/SearchViewController.swift @@ -105,12 +105,7 @@ extension SearchViewController { addChild(discoveryViewController) discoveryViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(discoveryViewController.view) - NSLayoutConstraint.activate([ - discoveryViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - discoveryViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - discoveryViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - discoveryViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + discoveryViewController.view.pinToParent() // discoveryViewController.view.isHidden = true @@ -151,12 +146,7 @@ extension SearchViewController { searchBar.delegate = self searchBar.translatesAutoresizingMaskIntoConstraints = false titleViewContainer.addSubview(searchBar) - NSLayoutConstraint.activate([ - searchBar.topAnchor.constraint(equalTo: titleViewContainer.topAnchor), - searchBar.leadingAnchor.constraint(equalTo: titleViewContainer.leadingAnchor), - searchBar.trailingAnchor.constraint(equalTo: titleViewContainer.trailingAnchor), - searchBar.bottomAnchor.constraint(equalTo: titleViewContainer.bottomAnchor), - ]) + searchBar.pinToParent() searchBar.setContentHuggingPriority(.required, for: .horizontal) searchBar.setContentHuggingPriority(.required, for: .vertical) navigationItem.titleView = titleViewContainer diff --git a/Mastodon/Scene/Search/Search/View/SearchRecommendCollectionHeader.swift b/Mastodon/Scene/Search/Search/View/SearchRecommendCollectionHeader.swift index 1d4788ac8..0a65c6a25 100644 --- a/Mastodon/Scene/Search/Search/View/SearchRecommendCollectionHeader.swift +++ b/Mastodon/Scene/Search/Search/View/SearchRecommendCollectionHeader.swift @@ -62,12 +62,7 @@ extension SearchRecommendCollectionHeader { containerStackView.isLayoutMarginsRelativeArrangement = true containerStackView.translatesAutoresizingMaskIntoConstraints = false addSubview(containerStackView) - NSLayoutConstraint.activate([ - containerStackView.topAnchor.constraint(equalTo: topAnchor), - containerStackView.leadingAnchor.constraint(equalTo: leadingAnchor), - containerStackView.bottomAnchor.constraint(equalTo: bottomAnchor), - containerStackView.trailingAnchor.constraint(equalTo: trailingAnchor) - ]) + containerStackView.pinToParent() let horizontalStackView = UIStackView() horizontalStackView.spacing = 8 diff --git a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift index 62dd1a2cc..f3ebcad00 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchDetailViewController.swift @@ -116,12 +116,7 @@ extension SearchDetailViewController { searchHistoryViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), ]) } else { - NSLayoutConstraint.activate([ - searchHistoryViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - searchHistoryViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - searchHistoryViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - searchHistoryViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + searchHistoryViewController.view.pinToParent() } transition = Transition(style: .fade, duration: 0.1) @@ -289,12 +284,7 @@ extension SearchDetailViewController { navigationBarVisualEffectBackgroundView.translatesAutoresizingMaskIntoConstraints = false view.insertSubview(navigationBarVisualEffectBackgroundView, belowSubview: navigationBarBackgroundView) - NSLayoutConstraint.activate([ - navigationBarVisualEffectBackgroundView.topAnchor.constraint(equalTo: navigationBarBackgroundView.topAnchor), - navigationBarVisualEffectBackgroundView.leadingAnchor.constraint(equalTo: navigationBarBackgroundView.leadingAnchor), - navigationBarVisualEffectBackgroundView.trailingAnchor.constraint(equalTo: navigationBarBackgroundView.trailingAnchor), - navigationBarVisualEffectBackgroundView.bottomAnchor.constraint(equalTo: navigationBarBackgroundView.bottomAnchor), - ]) + navigationBarVisualEffectBackgroundView.pinTo(to: navigationBarBackgroundView) } else { navigationItem.setHidesBackButton(true, animated: false) navigationItem.titleView = nil diff --git a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift index 52d0ffb9c..ac08e7906 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchHistory/SearchHistoryViewController.swift @@ -47,12 +47,7 @@ extension SearchHistoryViewController { collectionView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(collectionView) - NSLayoutConstraint.activate([ - collectionView.topAnchor.constraint(equalTo: view.topAnchor), - collectionView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - collectionView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - collectionView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + collectionView.pinToParent() collectionView.delegate = self viewModel.setupDiffableDataSource( diff --git a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift index 67de62bf3..6a840f9b5 100644 --- a/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift +++ b/Mastodon/Scene/Search/SearchDetail/SearchResult/SearchResultViewController.swift @@ -49,12 +49,7 @@ extension SearchResultViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self // tableView.prefetchDataSource = self diff --git a/Mastodon/Scene/Settings/Cell/SettingsAppearanceTableViewCell.swift b/Mastodon/Scene/Settings/Cell/SettingsAppearanceTableViewCell.swift index 44b6b39c3..efad9693d 100644 --- a/Mastodon/Scene/Settings/Cell/SettingsAppearanceTableViewCell.swift +++ b/Mastodon/Scene/Settings/Cell/SettingsAppearanceTableViewCell.swift @@ -101,12 +101,7 @@ extension SettingsAppearanceTableViewCell { stackView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(stackView) - NSLayoutConstraint.activate([ - stackView.topAnchor.constraint(equalTo: contentView.topAnchor), - stackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - stackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - stackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), - ]) + stackView.pinToParent() stackView.addArrangedSubview(systemAppearanceView) stackView.addArrangedSubview(darkAppearanceView) diff --git a/Mastodon/Scene/Settings/SettingsViewController.swift b/Mastodon/Scene/Settings/SettingsViewController.swift index fc42968d4..fa6948ced 100644 --- a/Mastodon/Scene/Settings/SettingsViewController.swift +++ b/Mastodon/Scene/Settings/SettingsViewController.swift @@ -225,12 +225,7 @@ extension SettingsViewController { setupNavigation() view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() setupTableView() updateSectionHeaderStackViewLayout() diff --git a/Mastodon/Scene/Settings/View/AppearanceView.swift b/Mastodon/Scene/Settings/View/AppearanceView.swift index cdc29100b..a09401537 100644 --- a/Mastodon/Scene/Settings/View/AppearanceView.swift +++ b/Mastodon/Scene/Settings/View/AppearanceView.swift @@ -85,12 +85,7 @@ extension AppearanceView { private func setupUI() { imageView.translatesAutoresizingMaskIntoConstraints = false imageViewShadowBackgroundContainer.addSubview(imageView) - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: imageViewShadowBackgroundContainer.topAnchor), - imageView.leadingAnchor.constraint(equalTo: imageViewShadowBackgroundContainer.leadingAnchor), - imageView.trailingAnchor.constraint(equalTo: imageViewShadowBackgroundContainer.trailingAnchor), - imageView.bottomAnchor.constraint(equalTo: imageViewShadowBackgroundContainer.bottomAnchor), - ]) + imageView.pinToParent() imageViewShadowBackgroundContainer.cornerRadius = 4 stackView.addArrangedSubview(imageViewShadowBackgroundContainer) @@ -100,11 +95,8 @@ extension AppearanceView { addSubview(stackView) translatesAutoresizingMaskIntoConstraints = false stackView.translatesAutoresizingMaskIntoConstraints = false + stackView.pinToParent() NSLayoutConstraint.activate([ - stackView.topAnchor.constraint(equalTo: self.topAnchor), - stackView.leadingAnchor.constraint(equalTo: self.leadingAnchor), - stackView.bottomAnchor.constraint(equalTo: self.bottomAnchor), - stackView.trailingAnchor.constraint(equalTo: self.trailingAnchor), imageView.heightAnchor.constraint(equalTo: imageView.widthAnchor, multiplier: 121.0 / 100.0), // height / width ]) } diff --git a/Mastodon/Scene/Share/ContextMenu/ImagePreview/ContextMenuImagePreviewViewController.swift b/Mastodon/Scene/Share/ContextMenu/ImagePreview/ContextMenuImagePreviewViewController.swift index 0d3c4f574..12820e627 100644 --- a/Mastodon/Scene/Share/ContextMenu/ImagePreview/ContextMenuImagePreviewViewController.swift +++ b/Mastodon/Scene/Share/ContextMenu/ImagePreview/ContextMenuImagePreviewViewController.swift @@ -31,12 +31,7 @@ extension ContextMenuImagePreviewViewController { imageView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(imageView) - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: view.topAnchor), - imageView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - imageView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - imageView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + imageView.pinToParent() imageView.image = viewModel.thumbnail diff --git a/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift b/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift index ca46193b6..eb55dc575 100644 --- a/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift +++ b/Mastodon/Scene/Share/View/Content/ContentWarningOverlayView.swift @@ -93,12 +93,7 @@ extension ContentWarningOverlayView { vibrancyVisualEffectView.translatesAutoresizingMaskIntoConstraints = false blurVisualEffectView.contentView.addSubview(vibrancyVisualEffectView) - NSLayoutConstraint.activate([ - vibrancyVisualEffectView.topAnchor.constraint(equalTo: blurVisualEffectView.topAnchor), - vibrancyVisualEffectView.leadingAnchor.constraint(equalTo: blurVisualEffectView.leadingAnchor), - vibrancyVisualEffectView.trailingAnchor.constraint(equalTo: blurVisualEffectView.trailingAnchor), - vibrancyVisualEffectView.bottomAnchor.constraint(equalTo: blurVisualEffectView.bottomAnchor), - ]) + vibrancyVisualEffectView.pinTo(to: blurVisualEffectView) vibrancyContentWarningLabel.translatesAutoresizingMaskIntoConstraints = false vibrancyVisualEffectView.contentView.addSubview(vibrancyContentWarningLabel) @@ -110,12 +105,7 @@ extension ContentWarningOverlayView { blurVisualEffectView.translatesAutoresizingMaskIntoConstraints = false addSubview(blurVisualEffectView) - NSLayoutConstraint.activate([ - blurVisualEffectView.topAnchor.constraint(equalTo: topAnchor), - blurVisualEffectView.leadingAnchor.constraint(equalTo: leadingAnchor), - blurVisualEffectView.trailingAnchor.constraint(equalTo: trailingAnchor), - blurVisualEffectView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + blurVisualEffectView.pinToParent() // blur image style contentOverlayView.translatesAutoresizingMaskIntoConstraints = false @@ -134,12 +124,7 @@ extension ContentWarningOverlayView { blurContentWarningLabelContainer.translatesAutoresizingMaskIntoConstraints = false contentOverlayView.addSubview(blurContentWarningLabelContainer) - NSLayoutConstraint.activate([ - blurContentWarningLabelContainer.topAnchor.constraint(equalTo: topAnchor), - blurContentWarningLabelContainer.leadingAnchor.constraint(equalTo: leadingAnchor), - blurContentWarningLabelContainer.trailingAnchor.constraint(equalTo: trailingAnchor), - blurContentWarningLabelContainer.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + blurContentWarningLabelContainer.pinTo(to: self) let topPaddingView = UIView() let bottomPaddingView = UIView() diff --git a/Mastodon/Scene/Share/View/Content/DoubleTitleLabelNavigationBarTitleView.swift b/Mastodon/Scene/Share/View/Content/DoubleTitleLabelNavigationBarTitleView.swift index 6734b7b77..f5ac0f8ec 100644 --- a/Mastodon/Scene/Share/View/Content/DoubleTitleLabelNavigationBarTitleView.swift +++ b/Mastodon/Scene/Share/View/Content/DoubleTitleLabelNavigationBarTitleView.swift @@ -47,12 +47,7 @@ extension DoubleTitleLabelNavigationBarTitleView { containerView.distribution = .fill containerView.translatesAutoresizingMaskIntoConstraints = false addSubview(containerView) - NSLayoutConstraint.activate([ - containerView.topAnchor.constraint(equalTo: topAnchor), - containerView.leadingAnchor.constraint(equalTo: leadingAnchor), - containerView.trailingAnchor.constraint(equalTo: trailingAnchor), - containerView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + containerView.pinToParent() containerView.addArrangedSubview(titleLabel) containerView.addArrangedSubview(subtitleLabel) diff --git a/Mastodon/Scene/Share/Webview/WebViewController.swift b/Mastodon/Scene/Share/Webview/WebViewController.swift index cb690de93..209ee483d 100644 --- a/Mastodon/Scene/Share/Webview/WebViewController.swift +++ b/Mastodon/Scene/Share/Webview/WebViewController.swift @@ -49,12 +49,7 @@ extension WebViewController { webView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(webView) - NSLayoutConstraint.activate([ - webView.topAnchor.constraint(equalTo: view.topAnchor), - webView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - webView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - webView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + webView.pinToParent() let request = URLRequest(url: viewModel.url) webView.load(request) diff --git a/Mastodon/Scene/SuggestionAccount/CollectionViewCell/SuggestionAccountCollectionViewCell.swift b/Mastodon/Scene/SuggestionAccount/CollectionViewCell/SuggestionAccountCollectionViewCell.swift index 2fb467fbd..296935521 100644 --- a/Mastodon/Scene/SuggestionAccount/CollectionViewCell/SuggestionAccountCollectionViewCell.swift +++ b/Mastodon/Scene/SuggestionAccount/CollectionViewCell/SuggestionAccountCollectionViewCell.swift @@ -53,11 +53,6 @@ extension SuggestionAccountCollectionViewCell { private func configure() { contentView.addSubview(imageView) imageView.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: contentView.topAnchor), - imageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - imageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), - imageView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - ]) + imageView.pinToParent() } } diff --git a/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift b/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift index 47bd9d6b3..d259ebed4 100644 --- a/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift +++ b/Mastodon/Scene/SuggestionAccount/TableViewCell/SuggestionAccountTableViewCell.swift @@ -97,12 +97,7 @@ extension SuggestionAccountTableViewCell { containerStackView.isLayoutMarginsRelativeArrangement = true containerStackView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(containerStackView) - NSLayoutConstraint.activate([ - containerStackView.topAnchor.constraint(equalTo: contentView.topAnchor), - containerStackView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - containerStackView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), - containerStackView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - ]) + containerStackView.pinToParent() avatarButton.translatesAutoresizingMaskIntoConstraints = false containerStackView.addArrangedSubview(avatarButton) diff --git a/Mastodon/Scene/Thread/ThreadViewController.swift b/Mastodon/Scene/Thread/ThreadViewController.swift index 5dee182c6..e8e6ce130 100644 --- a/Mastodon/Scene/Thread/ThreadViewController.swift +++ b/Mastodon/Scene/Thread/ThreadViewController.swift @@ -87,12 +87,7 @@ extension ThreadViewController { tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource( diff --git a/MastodonSDK/Sources/MastodonExtension/UIView.swift b/MastodonSDK/Sources/MastodonExtension/UIView.swift index f96d1618a..fa62be6c0 100644 --- a/MastodonSDK/Sources/MastodonExtension/UIView.swift +++ b/MastodonSDK/Sources/MastodonExtension/UIView.swift @@ -46,3 +46,20 @@ extension UIView { return self } } + +public extension UIView { + + func pinToParent() { + pinTo(to: self.superview) + } + + func pinTo(to view: UIView?) { + guard let pinToView = view else { return } + NSLayoutConstraint.activate([ + topAnchor.constraint(equalTo: pinToView.topAnchor), + leadingAnchor.constraint(equalTo: pinToView.leadingAnchor), + trailingAnchor.constraint(equalTo: pinToView.trailingAnchor), + bottomAnchor.constraint(equalTo: pinToView.bottomAnchor), + ]) + } +} diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift index 9af1ce9bf..ccb483f35 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/AutoCompleteViewController.swift @@ -80,12 +80,7 @@ extension AutoCompleteViewController { tableView.translatesAutoresizingMaskIntoConstraints = false containerBackgroundView.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: containerBackgroundView.topAnchor), - tableView.leadingAnchor.constraint(equalTo: containerBackgroundView.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: containerBackgroundView.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: containerBackgroundView.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDiffableDataSource(tableView: tableView) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift index 6b842c9f1..98690a3ce 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/AutoComplete/View/AutoCompleteTopChevronView.swift @@ -65,12 +65,7 @@ extension AutoCompleteTopChevronView { shadowView.translatesAutoresizingMaskIntoConstraints = false addSubview(shadowView) - NSLayoutConstraint.activate([ - shadowView.topAnchor.constraint(equalTo: topAnchor), - shadowView.leadingAnchor.constraint(equalTo: leadingAnchor), - shadowView.trailingAnchor.constraint(equalTo: trailingAnchor), - shadowView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + shadowView.pinToParent() shadowLayer.fillColor = topViewBackgroundColor.cgColor shadowView.layer.addSublayer(shadowLayer) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift index b84b47385..48e27aaf2 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/ComposeContentViewController.swift @@ -108,12 +108,7 @@ extension ComposeContentViewController { // setup tableView tableView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(tableView) - NSLayoutConstraint.activate([ - tableView.topAnchor.constraint(equalTo: view.topAnchor), - tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + tableView.pinToParent() tableView.delegate = self viewModel.setupDataSource(tableView: tableView) diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerInputView.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerInputView.swift index 2fa582883..237164ae2 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerInputView.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerInputView.swift @@ -44,12 +44,7 @@ extension CustomEmojiPickerInputView { collectionView.translatesAutoresizingMaskIntoConstraints = false addSubview(collectionView) - NSLayoutConstraint.activate([ - collectionView.topAnchor.constraint(equalTo: topAnchor), - collectionView.leadingAnchor.constraint(equalTo: leadingAnchor), - collectionView.trailingAnchor.constraint(equalTo: trailingAnchor), - collectionView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + collectionView.pinToParent() activityIndicatorView.hidesWhenStopped = true activityIndicatorView.startAnimating() diff --git a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerItemCollectionViewCell.swift b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerItemCollectionViewCell.swift index c92e689bc..49b1a8269 100644 --- a/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerItemCollectionViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/Scene/ComposeContent/EmojiPicker/CustomEmojiPickerItemCollectionViewCell.swift @@ -46,12 +46,7 @@ extension CustomEmojiPickerItemCollectionViewCell { private func _init() { emojiImageView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(emojiImageView) - NSLayoutConstraint.activate([ - emojiImageView.topAnchor.constraint(equalTo: contentView.topAnchor), - emojiImageView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - emojiImageView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), - emojiImageView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - ]) + emojiImageView.pinToParent() isAccessibilityElement = true accessibilityTraits = .button diff --git a/MastodonSDK/Sources/MastodonUI/SwiftUI/AnimatedImage.swift b/MastodonSDK/Sources/MastodonUI/SwiftUI/AnimatedImage.swift index 9a0f65108..29dd16549 100644 --- a/MastodonSDK/Sources/MastodonUI/SwiftUI/AnimatedImage.swift +++ b/MastodonSDK/Sources/MastodonUI/SwiftUI/AnimatedImage.swift @@ -37,12 +37,7 @@ final public class FLAnimatedImageViewProxy: UIView { imageView.translatesAutoresizingMaskIntoConstraints = false addSubview(imageView) - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: topAnchor), - imageView.leadingAnchor.constraint(equalTo: leadingAnchor), - imageView.trailingAnchor.constraint(equalTo: trailingAnchor), - imageView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + imageView.pinToParent() } required init?(coder: NSCoder) { diff --git a/MastodonSDK/Sources/MastodonUI/View/Button/AvatarButton.swift b/MastodonSDK/Sources/MastodonUI/View/Button/AvatarButton.swift index 57257fd89..d970ac69c 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Button/AvatarButton.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Button/AvatarButton.swift @@ -32,12 +32,7 @@ open class AvatarButton: UIControl { avatarImageView.frame = bounds avatarImageView.translatesAutoresizingMaskIntoConstraints = false addSubview(avatarImageView) - NSLayoutConstraint.activate([ - avatarImageView.topAnchor.constraint(equalTo: topAnchor), - avatarImageView.leadingAnchor.constraint(equalTo: leadingAnchor), - avatarImageView.trailingAnchor.constraint(equalTo: trailingAnchor), - avatarImageView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + avatarImageView.pinToParent() isAccessibilityElement = true accessibilityLabel = L10n.Common.Controls.Status.showUserProfile diff --git a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift index e3359fb58..b28f63942 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Container/MediaGridContainerView.swift @@ -136,12 +136,7 @@ extension MediaGridContainerView { private func layoutContentWarningOverlay() { contentWarningOverlay.translatesAutoresizingMaskIntoConstraints = false addSubview(contentWarningOverlay) - NSLayoutConstraint.activate([ - contentWarningOverlay.topAnchor.constraint(equalTo: topAnchor), - contentWarningOverlay.leadingAnchor.constraint(equalTo: leadingAnchor), - contentWarningOverlay.trailingAnchor.constraint(equalTo: trailingAnchor), - contentWarningOverlay.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + contentWarningOverlay.pinToParent() } } @@ -208,12 +203,7 @@ extension MediaGridContainerView { let containerVerticalStackView = createStackView(axis: .vertical) containerVerticalStackView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(containerVerticalStackView) - NSLayoutConstraint.activate([ - containerVerticalStackView.topAnchor.constraint(equalTo: view.topAnchor), - containerVerticalStackView.leadingAnchor.constraint(equalTo: view.leadingAnchor), - containerVerticalStackView.trailingAnchor.constraint(equalTo: view.trailingAnchor), - containerVerticalStackView.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + containerVerticalStackView.pinToParent() let count = mediaViews.count switch count { diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView.swift index c15f8878a..32d9bce96 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/FamiliarFollowersDashboardView.swift @@ -45,12 +45,7 @@ extension FamiliarFollowersDashboardView { stackView.translatesAutoresizingMaskIntoConstraints = false addSubview(stackView) - NSLayoutConstraint.activate([ - stackView.topAnchor.constraint(equalTo: topAnchor), - stackView.leadingAnchor.constraint(equalTo: leadingAnchor), - stackView.trailingAnchor.constraint(equalTo: trailingAnchor), - stackView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + stackView.pinToParent() avatarContainerView.translatesAutoresizingMaskIntoConstraints = false stackView.addArrangedSubview(avatarContainerView) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift index f4cee0922..54560a8ce 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/MediaView.swift @@ -138,12 +138,7 @@ extension MediaView { private func layoutImage() { imageView.translatesAutoresizingMaskIntoConstraints = false container.addSubview(imageView) - NSLayoutConstraint.activate([ - imageView.topAnchor.constraint(equalTo: container.topAnchor), - imageView.leadingAnchor.constraint(equalTo: container.leadingAnchor), - imageView.trailingAnchor.constraint(equalTo: container.trailingAnchor), - imageView.bottomAnchor.constraint(equalTo: container.bottomAnchor), - ]) + imageView.pinToParent() } private func bindImage(configuration: Configuration, info: Configuration.ImageInfo) { @@ -168,12 +163,7 @@ extension MediaView { // use view controller as View here playerViewController.view.translatesAutoresizingMaskIntoConstraints = false container.addSubview(playerViewController.view) - NSLayoutConstraint.activate([ - playerViewController.view.topAnchor.constraint(equalTo: container.topAnchor), - playerViewController.view.leadingAnchor.constraint(equalTo: container.leadingAnchor), - playerViewController.view.trailingAnchor.constraint(equalTo: container.trailingAnchor), - playerViewController.view.bottomAnchor.constraint(equalTo: container.bottomAnchor), - ]) + playerViewController.view.pinToParent() setupIndicatorViewHierarchy() playerIndicatorLabel.attributedText = NSAttributedString(string: "GIF") @@ -213,12 +203,7 @@ extension MediaView { private func layoutBlurhash() { blurhashImageView.translatesAutoresizingMaskIntoConstraints = false container.addSubview(blurhashImageView) - NSLayoutConstraint.activate([ - blurhashImageView.topAnchor.constraint(equalTo: container.topAnchor), - blurhashImageView.leadingAnchor.constraint(equalTo: container.leadingAnchor), - blurhashImageView.trailingAnchor.constraint(equalTo: container.trailingAnchor), - blurhashImageView.bottomAnchor.constraint(equalTo: container.bottomAnchor), - ]) + blurhashImageView.pinToParent() } private func bindBlurhash(configuration: Configuration) { @@ -304,12 +289,7 @@ extension MediaView { guard container.superview == nil else { return } container.translatesAutoresizingMaskIntoConstraints = false addSubview(container) - NSLayoutConstraint.activate([ - container.topAnchor.constraint(equalTo: topAnchor), - container.leadingAnchor.constraint(equalTo: leadingAnchor), - container.trailingAnchor.constraint(equalTo: trailingAnchor), - container.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + container.pinToParent() } private func setupIndicatorViewHierarchy() { @@ -329,12 +309,7 @@ extension MediaView { if vibrancyEffectView.superview == nil { vibrancyEffectView.translatesAutoresizingMaskIntoConstraints = false blurEffectView.contentView.addSubview(vibrancyEffectView) - NSLayoutConstraint.activate([ - vibrancyEffectView.topAnchor.constraint(equalTo: blurEffectView.contentView.topAnchor), - vibrancyEffectView.leadingAnchor.constraint(equalTo: blurEffectView.contentView.leadingAnchor), - vibrancyEffectView.trailingAnchor.constraint(equalTo: blurEffectView.contentView.trailingAnchor), - vibrancyEffectView.bottomAnchor.constraint(equalTo: blurEffectView.contentView.bottomAnchor), - ]) + vibrancyEffectView.pinToParent() } if playerIndicatorLabel.superview == nil { diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/NewsView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/NewsView.swift index 0d4298035..304bcebc4 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/NewsView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/NewsView.swift @@ -79,12 +79,7 @@ extension NewsView { container.spacing = 8 container.translatesAutoresizingMaskIntoConstraints = false addSubview(container) - NSLayoutConstraint.activate([ - container.topAnchor.constraint(equalTo: topAnchor), - container.leadingAnchor.constraint(equalTo: leadingAnchor), - container.trailingAnchor.constraint(equalTo: trailingAnchor), - container.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + container.pinToParent() // textContainer: V - [ providerContainer | headlineLabel | (spacer) | footnoteLabel ] let textContainer = UIStackView() diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift index e52422770..e6263dda9 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/NotificationView.swift @@ -292,21 +292,11 @@ extension NotificationView { acceptFollowRequestButton.translatesAutoresizingMaskIntoConstraints = false acceptFollowRequestButtonShadowBackgroundContainer.addSubview(acceptFollowRequestButton) - NSLayoutConstraint.activate([ - acceptFollowRequestButton.topAnchor.constraint(equalTo: acceptFollowRequestButtonShadowBackgroundContainer.topAnchor), - acceptFollowRequestButton.leadingAnchor.constraint(equalTo: acceptFollowRequestButtonShadowBackgroundContainer.leadingAnchor), - acceptFollowRequestButton.trailingAnchor.constraint(equalTo: acceptFollowRequestButtonShadowBackgroundContainer.trailingAnchor), - acceptFollowRequestButton.bottomAnchor.constraint(equalTo: acceptFollowRequestButtonShadowBackgroundContainer.bottomAnchor), - ]) + acceptFollowRequestButton.pinToParent() rejectFollowRequestButton.translatesAutoresizingMaskIntoConstraints = false rejectFollowRequestButtonShadowBackgroundContainer.addSubview(rejectFollowRequestButton) - NSLayoutConstraint.activate([ - rejectFollowRequestButton.topAnchor.constraint(equalTo: rejectFollowRequestButtonShadowBackgroundContainer.topAnchor), - rejectFollowRequestButton.leadingAnchor.constraint(equalTo: rejectFollowRequestButtonShadowBackgroundContainer.leadingAnchor), - rejectFollowRequestButton.trailingAnchor.constraint(equalTo: rejectFollowRequestButtonShadowBackgroundContainer.trailingAnchor), - rejectFollowRequestButton.bottomAnchor.constraint(equalTo: rejectFollowRequestButtonShadowBackgroundContainer.bottomAnchor), - ]) + rejectFollowRequestButton.pinToParent() followRequestContainerView.axis = .horizontal followRequestContainerView.distribution = .fillEqually diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/PollOptionView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/PollOptionView.swift index 04a032563..514657e62 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/PollOptionView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/PollOptionView.swift @@ -110,12 +110,7 @@ extension PollOptionView { voteProgressStripView.translatesAutoresizingMaskIntoConstraints = false roundedBackgroundView.addSubview(voteProgressStripView) - NSLayoutConstraint.activate([ - voteProgressStripView.topAnchor.constraint(equalTo: roundedBackgroundView.topAnchor), - voteProgressStripView.leadingAnchor.constraint(equalTo: roundedBackgroundView.leadingAnchor), - voteProgressStripView.trailingAnchor.constraint(equalTo: roundedBackgroundView.trailingAnchor), - voteProgressStripView.bottomAnchor.constraint(equalTo: roundedBackgroundView.bottomAnchor), - ]) + voteProgressStripView.pinToParent() checkmarkBackgroundView.translatesAutoresizingMaskIntoConstraints = false roundedBackgroundView.addSubview(checkmarkBackgroundView) @@ -138,12 +133,7 @@ extension PollOptionView { plusCircleImageView.translatesAutoresizingMaskIntoConstraints = false addSubview(plusCircleImageView) - NSLayoutConstraint.activate([ - plusCircleImageView.topAnchor.constraint(equalTo: checkmarkBackgroundView.topAnchor), - plusCircleImageView.leadingAnchor.constraint(equalTo: checkmarkBackgroundView.leadingAnchor), - plusCircleImageView.trailingAnchor.constraint(equalTo: checkmarkBackgroundView.trailingAnchor), - plusCircleImageView.bottomAnchor.constraint(equalTo: checkmarkBackgroundView.bottomAnchor), - ]) + plusCircleImageView.pinTo(to: checkmarkBackgroundView) optionTextField.translatesAutoresizingMaskIntoConstraints = false roundedBackgroundView.addSubview(optionTextField) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift index b93d44b73..cb7d8f839 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/ProfileCardView.swift @@ -137,12 +137,7 @@ extension ProfileCardView { container.spacing = 8 container.translatesAutoresizingMaskIntoConstraints = false addSubview(container) - NSLayoutConstraint.activate([ - container.topAnchor.constraint(equalTo: topAnchor), - container.leadingAnchor.constraint(equalTo: leadingAnchor), - container.trailingAnchor.constraint(equalTo: trailingAnchor), - container.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + container.pinToParent() // bannerContainer let bannerContainer = UIView() @@ -237,11 +232,8 @@ extension ProfileCardView { relationshipActionButton.translatesAutoresizingMaskIntoConstraints = false relationshipActionButtonShadowContainer.addSubview(relationshipActionButton) + relationshipActionButton.pinToParent() NSLayoutConstraint.activate([ - relationshipActionButton.topAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.topAnchor), - relationshipActionButton.leadingAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.leadingAnchor), - relationshipActionButton.trailingAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.trailingAnchor), - relationshipActionButton.bottomAnchor.constraint(equalTo: relationshipActionButtonShadowContainer.bottomAnchor), relationshipActionButtonShadowContainer.widthAnchor.constraint(greaterThanOrEqualToConstant: ProfileCardView.friendshipActionButtonSize.width).priority(.required - 1), relationshipActionButtonShadowContainer.heightAnchor.constraint(equalToConstant: ProfileCardView.friendshipActionButtonSize.height).priority(.required - 1), ]) diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift index 563bc7e3d..4943746b1 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/StatusView.swift @@ -236,12 +236,7 @@ extension StatusView { // container containerStackView.translatesAutoresizingMaskIntoConstraints = false addSubview(containerStackView) - NSLayoutConstraint.activate([ - containerStackView.topAnchor.constraint(equalTo: topAnchor), - containerStackView.leadingAnchor.constraint(equalTo: leadingAnchor), - containerStackView.trailingAnchor.constraint(equalTo: trailingAnchor), - containerStackView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + containerStackView.pinToParent() // header headerIconImageView.isUserInteractionEnabled = false @@ -392,12 +387,7 @@ extension StatusView.Style { statusView.spoilerOverlayView.translatesAutoresizingMaskIntoConstraints = false statusView.containerStackView.addSubview(statusView.spoilerOverlayView) - NSLayoutConstraint.activate([ - statusView.contentContainer.topAnchor.constraint(equalTo: statusView.spoilerOverlayView.topAnchor), - statusView.contentContainer.leadingAnchor.constraint(equalTo: statusView.spoilerOverlayView.leadingAnchor), - statusView.contentContainer.trailingAnchor.constraint(equalTo: statusView.spoilerOverlayView.trailingAnchor), - statusView.contentContainer.bottomAnchor.constraint(equalTo: statusView.spoilerOverlayView.bottomAnchor), - ]) + statusView.contentContainer.pinTo(to: statusView.spoilerOverlayView) // media container: V - [ mediaGridContainerView ] statusView.mediaContainerView.translatesAutoresizingMaskIntoConstraints = false @@ -409,12 +399,7 @@ extension StatusView.Style { statusView.mediaGridContainerView.translatesAutoresizingMaskIntoConstraints = false statusView.mediaContainerView.addSubview(statusView.mediaGridContainerView) - NSLayoutConstraint.activate([ - statusView.mediaGridContainerView.topAnchor.constraint(equalTo: statusView.mediaContainerView.topAnchor), - statusView.mediaGridContainerView.leadingAnchor.constraint(equalTo: statusView.mediaContainerView.leadingAnchor), - statusView.mediaGridContainerView.trailingAnchor.constraint(equalTo: statusView.mediaContainerView.trailingAnchor), - statusView.mediaGridContainerView.bottomAnchor.constraint(equalTo: statusView.mediaContainerView.bottomAnchor), - ]) + statusView.mediaGridContainerView.pinToParent() // pollContainerView: V - [ pollTableView | pollStatusStackView ] statusView.pollAdaptiveMarginContainerView.contentView = statusView.pollContainerView diff --git a/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift b/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift index cb066abfd..901a6547f 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Content/UserView.swift @@ -66,12 +66,7 @@ extension UserView { // container containerStackView.translatesAutoresizingMaskIntoConstraints = false addSubview(containerStackView) - NSLayoutConstraint.activate([ - containerStackView.topAnchor.constraint(equalTo: topAnchor), - containerStackView.leadingAnchor.constraint(equalTo: leadingAnchor), - containerStackView.trailingAnchor.constraint(equalTo: trailingAnchor), - containerStackView.bottomAnchor.constraint(equalTo: bottomAnchor) - ]) + containerStackView.pinToParent() avatarButton.translatesAutoresizingMaskIntoConstraints = false containerStackView.addArrangedSubview(avatarButton) diff --git a/MastodonSDK/Sources/MastodonUI/View/Control/SpoilerOverlayView.swift b/MastodonSDK/Sources/MastodonUI/View/Control/SpoilerOverlayView.swift index 98139b00e..c9074f9b5 100644 --- a/MastodonSDK/Sources/MastodonUI/View/Control/SpoilerOverlayView.swift +++ b/MastodonSDK/Sources/MastodonUI/View/Control/SpoilerOverlayView.swift @@ -48,12 +48,7 @@ extension SpoilerOverlayView { private func _init() { containerStackView.translatesAutoresizingMaskIntoConstraints = false addSubview(containerStackView) - NSLayoutConstraint.activate([ - containerStackView.topAnchor.constraint(equalTo: topAnchor), - containerStackView.leadingAnchor.constraint(equalTo: leadingAnchor), - containerStackView.trailingAnchor.constraint(equalTo: trailingAnchor), - containerStackView.bottomAnchor.constraint(equalTo: bottomAnchor), - ]) + containerStackView.pinToParent() let topPaddingView = UIView() topPaddingView.translatesAutoresizingMaskIntoConstraints = false diff --git a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/PollOptionTableViewCell.swift b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/PollOptionTableViewCell.swift index 6ae6ea0b5..d1e1a90f4 100644 --- a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/PollOptionTableViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/PollOptionTableViewCell.swift @@ -53,12 +53,7 @@ extension PollOptionTableViewCell { pollOptionView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(pollOptionView) - NSLayoutConstraint.activate([ - pollOptionView.topAnchor.constraint(equalTo: contentView.topAnchor), - pollOptionView.leadingAnchor.constraint(equalTo: contentView.leadingAnchor), - pollOptionView.trailingAnchor.constraint(equalTo: contentView.trailingAnchor), - pollOptionView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor), - ]) + pollOptionView.pinToParent() pollOptionView.setup(style: .plain) } diff --git a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift index 2d210f20c..a14028ea2 100644 --- a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/ProfileCardTableViewCell.swift @@ -67,12 +67,7 @@ extension ProfileCardTableViewCell { profileCardView.translatesAutoresizingMaskIntoConstraints = false contentView.addSubview(profileCardView) - NSLayoutConstraint.activate([ - profileCardView.topAnchor.constraint(equalTo: shadowBackgroundContainer.topAnchor), - profileCardView.leadingAnchor.constraint(equalTo: shadowBackgroundContainer.leadingAnchor), - profileCardView.trailingAnchor.constraint(equalTo: shadowBackgroundContainer.trailingAnchor), - profileCardView.bottomAnchor.constraint(equalTo: shadowBackgroundContainer.bottomAnchor), - ]) + profileCardView.pinTo(to: shadowBackgroundContainer) profileCardView.delegate = self diff --git a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift index 6e396dc6d..7f5b355d3 100644 --- a/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift +++ b/MastodonSDK/Sources/MastodonUI/View/TableViewCell/TimelineLoaderTableViewCell.swift @@ -96,12 +96,7 @@ open class TimelineLoaderTableViewCell: UITableViewCell { stackView.translatesAutoresizingMaskIntoConstraints = false stackView.isUserInteractionEnabled = false contentView.addSubview(stackView) - NSLayoutConstraint.activate([ - stackView.topAnchor.constraint(equalTo: loadMoreButton.topAnchor), - stackView.leadingAnchor.constraint(equalTo: loadMoreButton.leadingAnchor), - stackView.trailingAnchor.constraint(equalTo: loadMoreButton.trailingAnchor), - stackView.bottomAnchor.constraint(equalTo: loadMoreButton.bottomAnchor), - ]) + stackView.pinTo(to: loadMoreButton) let leftPaddingView = UIView() leftPaddingView.translatesAutoresizingMaskIntoConstraints = false stackView.addArrangedSubview(leftPaddingView) diff --git a/ShareActionExtension/Scene/ShareViewController.swift b/ShareActionExtension/Scene/ShareViewController.swift index 7757452cd..372ce5876 100644 --- a/ShareActionExtension/Scene/ShareViewController.swift +++ b/ShareActionExtension/Scene/ShareViewController.swift @@ -102,12 +102,7 @@ extension ShareViewController { addChild(composeContentViewController) composeContentViewController.view.translatesAutoresizingMaskIntoConstraints = false view.addSubview(composeContentViewController.view) - NSLayoutConstraint.activate([ - composeContentViewController.view.topAnchor.constraint(equalTo: view.topAnchor), - composeContentViewController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor), - composeContentViewController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor), - composeContentViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor), - ]) + composeContentViewController.view.pinToParent() composeContentViewController.didMove(toParent: self) self.composeContentViewModel = composeContentViewModel