Fix building for iOS 14

This commit is contained in:
Shadowfacts 2022-06-28 17:28:48 -07:00
parent c6e06fe9f3
commit 0960699699
4 changed files with 36 additions and 16 deletions

View File

@ -2205,8 +2205,7 @@
CURRENT_PROJECT_VERSION = 31; CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = V4WK9KR9U2; DEVELOPMENT_TEAM = V4WK9KR9U2;
INFOPLIST_FILE = Tusker/Info.plist; INFOPLIST_FILE = Tusker/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1; IPHONEOS_DEPLOYMENT_TARGET = 14.3;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.3;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
@ -2236,8 +2235,7 @@
CURRENT_PROJECT_VERSION = 31; CURRENT_PROJECT_VERSION = 31;
DEVELOPMENT_TEAM = V4WK9KR9U2; DEVELOPMENT_TEAM = V4WK9KR9U2;
INFOPLIST_FILE = Tusker/Info.plist; INFOPLIST_FILE = Tusker/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.1; IPHONEOS_DEPLOYMENT_TARGET = 14.3;
"IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.3;
LD_RUNPATH_SEARCH_PATHS = ( LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",

View File

@ -154,6 +154,7 @@ extension ComposeAttachmentRow {
} }
private extension View { private extension View {
@available(iOS, obsoleted: 16.0)
@ViewBuilder @ViewBuilder
func contextMenu<M: View, P: View>(@ViewBuilder menuItems: () -> M, @ViewBuilder previewIfAvailable preview: () -> P) -> some View { func contextMenu<M: View, P: View>(@ViewBuilder menuItems: () -> M, @ViewBuilder previewIfAvailable preview: () -> P) -> some View {
if #available(iOS 16.0, *) { if #available(iOS 16.0, *) {

View File

@ -17,7 +17,7 @@ protocol LargeImageContentView: UIView {
func grayscaleStateChanged() func grayscaleStateChanged()
} }
class LargeImageImageContentView: UIImageView, LargeImageContentView, ImageAnalysisInteractionDelegate { class LargeImageImageContentView: UIImageView, LargeImageContentView {
@available(iOS 16.0, *) @available(iOS 16.0, *)
private static let analyzer = ImageAnalyzer() private static let analyzer = ImageAnalyzer()
@ -76,7 +76,10 @@ class LargeImageImageContentView: UIImageView, LargeImageContentView, ImageAnaly
self.image = image self.image = image
} }
} }
}
@available(iOS 16.0, *)
extension LargeImageImageContentView: ImageAnalysisInteractionDelegate {
func presentingViewController(for interaction: ImageAnalysisInteraction) -> UIViewController? { func presentingViewController(for interaction: ImageAnalysisInteraction) -> UIViewController? {
return owner return owner
} }

View File

@ -20,19 +20,23 @@ class EnhancedNavigationViewController: UINavigationController {
override var viewControllers: [UIViewController] { override var viewControllers: [UIViewController] {
didSet { didSet {
poppedViewControllers = [] poppedViewControllers = []
if #available(iOS 16.0, *) {
// TODO: this for loop might not be necessary
for vc in viewControllers { for vc in viewControllers {
configureNavItem(vc.navigationItem) configureNavItem(vc.navigationItem)
} }
updateTopNavItemState() updateTopNavItemState()
} }
} }
}
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.interactivePushTransition = InteractivePushTransition(navigationController: self) self.interactivePushTransition = InteractivePushTransition(navigationController: self)
if let topViewController { if #available(iOS 16.0, *),
let topViewController {
configureNavItem(topViewController.navigationItem) configureNavItem(topViewController.navigationItem)
updateTopNavItemState() updateTopNavItemState()
} }
@ -42,7 +46,9 @@ class EnhancedNavigationViewController: UINavigationController {
let popped = performAfterAnimating(block: { let popped = performAfterAnimating(block: {
super.popViewController(animated: animated) super.popViewController(animated: animated)
}, after: { }, after: {
if #available(iOS 16.0, *) {
self.updateTopNavItemState() self.updateTopNavItemState()
}
}, animated: animated) }, animated: animated)
if let popped { if let popped {
poppedViewControllers.insert(popped, at: 0) poppedViewControllers.insert(popped, at: 0)
@ -54,7 +60,9 @@ class EnhancedNavigationViewController: UINavigationController {
let popped = performAfterAnimating(block: { let popped = performAfterAnimating(block: {
super.popToRootViewController(animated: animated) super.popToRootViewController(animated: animated)
}, after: { }, after: {
if #available(iOS 16.0, *) {
self.updateTopNavItemState() self.updateTopNavItemState()
}
}, animated: animated) }, animated: animated)
if let popped { if let popped {
poppedViewControllers = popped poppedViewControllers = popped
@ -66,7 +74,9 @@ class EnhancedNavigationViewController: UINavigationController {
let popped = performAfterAnimating(block: { let popped = performAfterAnimating(block: {
super.popToViewController(viewController, animated: animated) super.popToViewController(viewController, animated: animated)
}, after: { }, after: {
if #available(iOS 16.0, *) {
self.updateTopNavItemState() self.updateTopNavItemState()
}
}, animated: animated) }, animated: animated)
if let popped { if let popped {
poppedViewControllers.insert(contentsOf: popped, at: 0) poppedViewControllers.insert(contentsOf: popped, at: 0)
@ -81,12 +91,16 @@ class EnhancedNavigationViewController: UINavigationController {
self.poppedViewControllers = [] self.poppedViewControllers = []
} }
if #available(iOS 16.0, *) {
configureNavItem(viewController.navigationItem) configureNavItem(viewController.navigationItem)
}
super.pushViewController(viewController, animated: animated) super.pushViewController(viewController, animated: animated)
if #available(iOS 16.0, *) {
updateTopNavItemState() updateTopNavItemState()
} }
}
func pushPoppedViewController() { func pushPoppedViewController() {
guard !poppedViewControllers.isEmpty else { guard !poppedViewControllers.isEmpty else {
@ -115,7 +129,9 @@ class EnhancedNavigationViewController: UINavigationController {
pushViewController(target, animated: true) pushViewController(target, animated: true)
}, after: { }, after: {
self.viewControllers.insert(contentsOf: toInsert, at: self.viewControllers.count - 1) self.viewControllers.insert(contentsOf: toInsert, at: self.viewControllers.count - 1)
if #available(iOS 16.0, *) {
self.updateTopNavItemState() self.updateTopNavItemState()
}
}, animated: true) }, animated: true)
} }
@ -135,6 +151,7 @@ class EnhancedNavigationViewController: UINavigationController {
}) })
} }
@available(iOS 16.0, *)
private func configureNavItem(_ navItem: UINavigationItem) { private func configureNavItem(_ navItem: UINavigationItem) {
guard useBrowserStyleNavigation, guard useBrowserStyleNavigation,
UIDevice.current.userInterfaceIdiom != .phone else { UIDevice.current.userInterfaceIdiom != .phone else {
@ -183,6 +200,7 @@ class EnhancedNavigationViewController: UINavigationController {
] ]
} }
@available(iOS 16.0, *)
private func updateTopNavItemState() { private func updateTopNavItemState() {
guard useBrowserStyleNavigation, guard useBrowserStyleNavigation,
UIDevice.current.userInterfaceIdiom != .phone, UIDevice.current.userInterfaceIdiom != .phone,