diff --git a/Mastodon.xcodeproj/project.pbxproj b/Mastodon.xcodeproj/project.pbxproj index 3f70434b6..db397ba80 100644 --- a/Mastodon.xcodeproj/project.pbxproj +++ b/Mastodon.xcodeproj/project.pbxproj @@ -101,6 +101,8 @@ 62FD27D12893707600B205C5 /* BookmarkViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FD27D02893707600B205C5 /* BookmarkViewController.swift */; }; 62FD27D32893707B00B205C5 /* BookmarkViewController+DataSourceProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FD27D22893707B00B205C5 /* BookmarkViewController+DataSourceProvider.swift */; }; 62FD27D52893708A00B205C5 /* BookmarkViewModel+Diffable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62FD27D42893708A00B205C5 /* BookmarkViewModel+Diffable.swift */; }; + 855149C8295F1C5F00943D96 /* UIInterfaceOrientationMask.swift in Sources */ = {isa = PBXBuildFile; fileRef = 855149C7295F1C5F00943D96 /* UIInterfaceOrientationMask.swift */; }; + 855149CA29606D6400943D96 /* PortraitAlertController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 855149C929606D6400943D96 /* PortraitAlertController.swift */; }; 85904C02293BC0EB0011C817 /* ImageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85904C01293BC0EB0011C817 /* ImageProvider.swift */; }; 85904C04293BC1940011C817 /* URLActivityItemWithMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85904C03293BC1940011C817 /* URLActivityItemWithMetadata.swift */; }; 85BC11B32932414900E191CD /* AltViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 85BC11B22932414900E191CD /* AltViewController.swift */; }; @@ -618,6 +620,8 @@ 7CB58D292DA7ACEF179A9050 /* Pods-Mastodon.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon.profile.xcconfig"; path = "Target Support Files/Pods-Mastodon/Pods-Mastodon.profile.xcconfig"; sourceTree = ""; }; 7CEFFAE9AF9284B13C0A758D /* Pods-MastodonTests.asdk - debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MastodonTests.asdk - debug.xcconfig"; path = "Target Support Files/Pods-MastodonTests/Pods-MastodonTests.asdk - debug.xcconfig"; sourceTree = ""; }; 819CEC9DCAD8E8E7BD85A7BB /* Pods-Mastodon.asdk.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Mastodon.asdk.xcconfig"; path = "Target Support Files/Pods-Mastodon/Pods-Mastodon.asdk.xcconfig"; sourceTree = ""; }; + 855149C7295F1C5F00943D96 /* UIInterfaceOrientationMask.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIInterfaceOrientationMask.swift; sourceTree = ""; }; + 855149C929606D6400943D96 /* PortraitAlertController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PortraitAlertController.swift; sourceTree = ""; }; 85904C01293BC0EB0011C817 /* ImageProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageProvider.swift; sourceTree = ""; }; 85904C03293BC1940011C817 /* URLActivityItemWithMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLActivityItemWithMetadata.swift; sourceTree = ""; }; 85BC11B22932414900E191CD /* AltViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AltViewController.swift; sourceTree = ""; }; @@ -2274,6 +2278,7 @@ 2AE244472927831100BDBF7C /* UIImage+SFSymbols.swift */, DBCC3B2F261440A50045B23D /* UITabBarController.swift */, 2A1FE47D2938C11200784BF1 /* Collection+IsNotEmpty.swift */, + 855149C7295F1C5F00943D96 /* UIInterfaceOrientationMask.swift */, ); path = Extension; sourceTree = ""; @@ -2543,6 +2548,7 @@ DBF3B7402733EB9400E21627 /* MastodonLocalCode.swift */, 85904C01293BC0EB0011C817 /* ImageProvider.swift */, 85904C03293BC1940011C817 /* URLActivityItemWithMetadata.swift */, + 855149C929606D6400943D96 /* PortraitAlertController.swift */, ); path = Helper; sourceTree = ""; @@ -3185,6 +3191,7 @@ DB1E347825F519300079D7DF /* PickServerItem.swift in Sources */, DB336F3F278E668C0031E64B /* StatusTableViewCell+ViewModel.swift in Sources */, DB63F764279A5E3C00455B82 /* NotificationTimelineViewController.swift in Sources */, + 855149C8295F1C5F00943D96 /* UIInterfaceOrientationMask.swift in Sources */, DBA5A53126F08EF000CACBAA /* DragIndicatorView.swift in Sources */, DB1FD45A25F27898004CFCFC /* CategoryPickerItem.swift in Sources */, DB6180F626391D580018D199 /* MediaPreviewableViewController.swift in Sources */, @@ -3529,6 +3536,7 @@ DBEFCD7D282A2A3B00C0ABEA /* ReportServerRulesViewController.swift in Sources */, DBB525362611ECEB002F1F29 /* UserTimelineViewController.swift in Sources */, DB98EB4927B0F0CD0082E365 /* ReportStatusTableViewCell.swift in Sources */, + 855149CA29606D6400943D96 /* PortraitAlertController.swift in Sources */, DBF3B7412733EB9400E21627 /* MastodonLocalCode.swift in Sources */, DB98EB6527B216500082E365 /* ReportResultViewModel.swift in Sources */, DB4F096A269EDAD200D62E92 /* SearchResultViewModel+State.swift in Sources */, diff --git a/Mastodon/Extension/UIInterfaceOrientationMask.swift b/Mastodon/Extension/UIInterfaceOrientationMask.swift new file mode 100644 index 000000000..2bc93fe85 --- /dev/null +++ b/Mastodon/Extension/UIInterfaceOrientationMask.swift @@ -0,0 +1,14 @@ +// +// UIInterfaceOrientationMask.swift +// Mastodon +// +// Created by Jed Fox on 2022-12-30. +// + +import UIKit + +extension UIInterfaceOrientationMask { + public static var portraitOnPhone: Self { + return UIDevice.current.userInterfaceIdiom == .phone ? .portrait : .all + } +} diff --git a/Mastodon/Helper/PortraitAlertController.swift b/Mastodon/Helper/PortraitAlertController.swift new file mode 100644 index 000000000..afb93464a --- /dev/null +++ b/Mastodon/Helper/PortraitAlertController.swift @@ -0,0 +1,14 @@ +// +// PortraitAlertController.swift +// Mastodon +// +// Created by Jed Fox on 2022-12-31. +// + +import UIKit + +class PortraitAlertController: UIAlertController { + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + .portraitOnPhone + } +} diff --git a/Mastodon/Scene/Account/AccountViewController.swift b/Mastodon/Scene/Account/AccountViewController.swift index 7a0e529cc..75ea91fd6 100644 --- a/Mastodon/Scene/Account/AccountViewController.swift +++ b/Mastodon/Scene/Account/AccountViewController.swift @@ -49,6 +49,9 @@ final class AccountListViewController: UIViewController, NeedsDependency { return tableView }() + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + .portraitOnPhone + } } // MARK: - PanModalPresentable diff --git a/Mastodon/Scene/Compose/ComposeViewController.swift b/Mastodon/Scene/Compose/ComposeViewController.swift index 9f287dbf8..fa5a1ef37 100644 --- a/Mastodon/Scene/Compose/ComposeViewController.swift +++ b/Mastodon/Scene/Compose/ComposeViewController.swift @@ -129,7 +129,7 @@ extension ComposeViewController { extension ComposeViewController { private func showDismissConfirmAlertController() { - let alertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) + let alertController = PortraitAlertController(title: nil, message: nil, preferredStyle: .actionSheet) let discardAction = UIAlertAction(title: L10n.Common.Controls.Actions.discard, style: .destructive) { [weak self] _ in guard let self = self else { return } self.dismiss(animated: true, completion: nil) diff --git a/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift b/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift index ac2e5b171..69108feb0 100644 --- a/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift +++ b/Mastodon/Scene/Onboarding/Share/OnboardingNavigationController.swift @@ -25,9 +25,8 @@ extension OnboardingNavigationController { updateBorderViewDisplay() } - override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { - super.traitCollectionDidChange(previousTraitCollection) - + override var supportedInterfaceOrientations: UIInterfaceOrientationMask { + .portraitOnPhone } } diff --git a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift index 00769e9f9..bf4d6beb1 100644 --- a/Mastodon/Scene/Root/MainTab/MainTabBarController.swift +++ b/Mastodon/Scene/Root/MainTab/MainTabBarController.swift @@ -370,7 +370,7 @@ extension MainTabBarController { } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { - return UIDevice.current.userInterfaceIdiom == .phone ? .portrait : .all + .portraitOnPhone } } diff --git a/Mastodon/Scene/Root/RootSplitViewController.swift b/Mastodon/Scene/Root/RootSplitViewController.swift index 5332140db..c4caefd5f 100644 --- a/Mastodon/Scene/Root/RootSplitViewController.swift +++ b/Mastodon/Scene/Root/RootSplitViewController.swift @@ -114,7 +114,7 @@ extension RootSplitViewController { } override var supportedInterfaceOrientations: UIInterfaceOrientationMask { - return UIDevice.current.userInterfaceIdiom == .phone ? .portrait : .all + .portraitOnPhone } override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {