Skip to content

Commit 55b7b5c

Browse files
committed
Remove available checks
1 parent a618364 commit 55b7b5c

23 files changed

+68
-254
lines changed

WordPress/Classes/Extensions/Colors and Styles/WPStyleGuide+ApplicationStyles.swift

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,24 +57,20 @@ extension WPStyleGuide {
5757

5858
/// Style `UITableView` in the app
5959
class func configureTableViewAppearance() {
60-
if #available(iOS 15.0, *) {
61-
UITableView.appearance().sectionHeaderTopPadding = 0
62-
}
60+
UITableView.appearance().sectionHeaderTopPadding = 0
6361
}
6462

6563
/// Style the tab bar using Muriel colors
6664
class func configureTabBarAppearance() {
6765
UITabBar.appearance().tintColor = .tabSelected
6866
UITabBar.appearance().unselectedItemTintColor = .tabUnselected
6967

70-
if #available(iOS 15.0, *) {
71-
let appearance = UITabBarAppearance()
72-
appearance.configureWithOpaqueBackground()
73-
appearance.backgroundColor = .systemBackground
68+
let appearance = UITabBarAppearance()
69+
appearance.configureWithOpaqueBackground()
70+
appearance.backgroundColor = .systemBackground
7471

75-
UITabBar.appearance().standardAppearance = appearance
76-
UITabBar.appearance().scrollEdgeAppearance = appearance
77-
}
72+
UITabBar.appearance().standardAppearance = appearance
73+
UITabBar.appearance().scrollEdgeAppearance = appearance
7874
}
7975

8076
/// Style the `LightNavigationController` UINavigationBar and BarButtonItems
@@ -114,10 +110,7 @@ extension WPStyleGuide {
114110
appearance.configureWithDefaultBackground()
115111

116112
UIToolbar.appearance().standardAppearance = appearance
117-
118-
if #available(iOS 15.0, *) {
119-
UIToolbar.appearance().scrollEdgeAppearance = appearance
120-
}
113+
UIToolbar.appearance().scrollEdgeAppearance = appearance
121114
}
122115
}
123116

WordPress/Classes/Extensions/NSAttributedString+Helpers.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,7 @@ public extension NSAttributedString {
2626
for (value, image) in unwrappedEmbeds {
2727
let imageAttachment = NSTextAttachment()
2828
let gifType = UTType.gif.identifier
29-
var displayAnimatedGifs = false
30-
31-
// Check to see if the animated gif view provider is registered
32-
if #available(iOS 15.0, *) {
33-
displayAnimatedGifs = NSTextAttachment.textAttachmentViewProviderClass(forFileType: gifType) == AnimatedGifAttachmentViewProvider.self
34-
}
29+
let displayAnimatedGifs = NSTextAttachment.textAttachmentViewProviderClass(forFileType: gifType) == AnimatedGifAttachmentViewProvider.self
3530

3631
// When displaying an animated gif pass the gif data instead of the image
3732
if

WordPress/Classes/Extensions/UIApplication+mainWindow.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@ import UIKit
22

33
extension UIApplication {
44
@objc var mainWindow: UIWindow? {
5-
if #available(iOS 15, *) {
6-
return connectedScenes
7-
.compactMap { ($0 as? UIWindowScene)?.keyWindow }
8-
.first
9-
} else {
10-
return windows.filter { $0.isKeyWindow }.first
11-
}
5+
connectedScenes
6+
.compactMap { ($0 as? UIWindowScene)?.keyWindow }
7+
.first
128
}
139

1410
@objc var currentStatusBarFrame: CGRect {

WordPress/Classes/Utility/WebKitViewController.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,7 @@ class WebKitViewController: UIViewController, WebKitAuthenticatable {
349349
appearance.backgroundColor = UIColor(light: .white, dark: .appBarBackground)
350350

351351
toolBar.standardAppearance = appearance
352-
353-
if #available(iOS 15.0, *) {
354-
toolBar.scrollEdgeAppearance = appearance
355-
}
352+
toolBar.scrollEdgeAppearance = appearance
356353

357354
fixBarButtonsColorForBoldText(on: toolBar)
358355
}

WordPress/Classes/ViewRelated/Blaze/Overlay/BlazeOverlayViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,7 @@ final class BlazeOverlayViewController: UIViewController {
156156
navigationItem.standardAppearance = appearance
157157
navigationItem.compactAppearance = appearance
158158
navigationItem.scrollEdgeAppearance = appearance
159-
if #available(iOS 15.0, *) {
160-
navigationItem.compactScrollEdgeAppearance = appearance
161-
}
159+
navigationItem.compactScrollEdgeAppearance = appearance
162160
}
163161

164162
private func setupView() {

WordPress/Classes/ViewRelated/Blaze/Webview/BlazeWebViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ class BlazeWebViewController: UIViewController, BlazeWebView {
9090
navigationItem.standardAppearance = appearance
9191
navigationItem.compactAppearance = appearance
9292
navigationItem.scrollEdgeAppearance = appearance
93-
if #available(iOS 15.0, *) {
94-
navigationItem.compactScrollEdgeAppearance = appearance
95-
}
93+
navigationItem.compactScrollEdgeAppearance = appearance
9694
}
9795

9896
// MARK: Reachability Helpers

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/BlogDashboardViewController.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,20 +325,6 @@ extension BlogDashboardViewController {
325325
}
326326
}
327327

328-
// MARK: - UI Popover Delegate
329-
330-
/// This view controller may host a `DashboardPromptsCardCell` that requires presenting a `MenuSheetViewController`,
331-
/// a fallback implementation of `UIMenu` for iOS 13. For more details, see the docs on `MenuSheetViewController`.
332-
///
333-
/// NOTE: This should be removed once we drop support for iOS 13.
334-
///
335-
extension BlogDashboardViewController: UIPopoverPresentationControllerDelegate {
336-
// Force popover views to be presented as a popover (instead of being presented as a form sheet on iPhones).
337-
public func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
338-
return .none
339-
}
340-
}
341-
342328
// MARK: - Helper functions
343329

344330
private extension Collection where Element == DashboardCardModel {

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Pages/DashboardPageCreationCell.swift

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,14 @@ class DashboardPageCreationCell: UITableViewCell {
5252
button.addTarget(self, action: #selector(createPageButtonTapped), for: .touchUpInside)
5353
let font = WPStyleGuide.fontForTextStyle(.callout, fontWeight: .bold)
5454

55-
if #available(iOS 15.0, *) {
56-
var buttonConfig: UIButton.Configuration = .plain()
57-
buttonConfig.contentInsets = Metrics.createPageButtonContentInsets
58-
buttonConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer({ incoming in
59-
var outgoing = incoming
60-
outgoing.font = font
61-
return outgoing
62-
})
63-
button.configuration = buttonConfig
64-
} else {
65-
button.titleLabel?.font = font
66-
button.setTitleColor(.jetpackGreen, for: .normal)
67-
button.contentEdgeInsets = Metrics.createPageButtonContentEdgeInsets
68-
button.flipInsetsForRightToLeftLayoutDirection()
69-
}
55+
var buttonConfig: UIButton.Configuration = .plain()
56+
buttonConfig.contentInsets = Metrics.createPageButtonContentInsets
57+
buttonConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer({ incoming in
58+
var outgoing = incoming
59+
outgoing.font = font
60+
return outgoing
61+
})
62+
button.configuration = buttonConfig
7063

7164
return button
7265
}()

WordPress/Classes/ViewRelated/Blog/Blog Dashboard/Cards/Prompts/DashboardPromptsCardCell.swift

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,11 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
1212
frameView.translatesAutoresizingMaskIntoConstraints = false
1313
frameView.setTitle(Strings.cardFrameTitle)
1414

15-
// NOTE: Remove the logic when support for iOS 14 is dropped
16-
if #available (iOS 15.0, *) {
17-
// assign an empty closure so the button appears.
18-
frameView.onEllipsisButtonTap = {
19-
BlogDashboardAnalytics.trackContextualMenuAccessed(for: .prompts)
20-
}
21-
frameView.ellipsisButton.showsMenuAsPrimaryAction = true
22-
frameView.ellipsisButton.menu = contextMenu
23-
} else {
24-
// Show a fallback implementation using `MenuSheetViewController`.
25-
// iOS 13 doesn't support showing UIMenu programmatically.
26-
// iOS 14 doesn't support `UIDeferredMenuElement.uncached`.
27-
frameView.onEllipsisButtonTap = { [weak self] in
28-
BlogDashboardAnalytics.trackContextualMenuAccessed(for: .prompts)
29-
self?.showMenuSheet()
30-
}
15+
frameView.onEllipsisButtonTap = {
16+
BlogDashboardAnalytics.trackContextualMenuAccessed(for: .prompts)
3117
}
18+
frameView.ellipsisButton.showsMenuAsPrimaryAction = true
19+
frameView.ellipsisButton.menu = contextMenu
3220

3321
return frameView
3422
}()
@@ -313,7 +301,6 @@ class DashboardPromptsCardCell: UICollectionViewCell, Reusable {
313301
return [defaultItems, [.learnMore(learnMoreTapped)]]
314302
}
315303

316-
@available(iOS 15.0, *)
317304
private var contextMenu: UIMenu {
318305
return .init(title: String(), options: .displayInline, children: contextMenuItems.map { menuSection in
319306
UIMenu(title: String(), options: .displayInline, children: [
@@ -526,27 +513,6 @@ private extension DashboardPromptsCardCell {
526513
BloggingPromptsIntroductionPresenter(interactionType: .actionable(blog: blog)).present(from: presenterViewController)
527514
}
528515

529-
// Fallback context menu implementation for iOS 13.
530-
func showMenuSheet() {
531-
guard let presenterViewController = presenterViewController else {
532-
return
533-
}
534-
WPAnalytics.track(.promptsDashboardCardMenu)
535-
536-
let menuViewController = MenuSheetViewController(items: contextMenuItems.map { menuSection in
537-
menuSection.map { $0.toMenuSheetItem }
538-
})
539-
540-
menuViewController.modalPresentationStyle = .popover
541-
if let popoverPresentationController = menuViewController.popoverPresentationController {
542-
popoverPresentationController.delegate = presenterViewController
543-
popoverPresentationController.sourceView = cardFrameView.ellipsisButton
544-
popoverPresentationController.sourceRect = cardFrameView.ellipsisButton.bounds
545-
}
546-
547-
presenterViewController.present(menuViewController, animated: true)
548-
}
549-
550516
// MARK: Constants
551517

552518
struct Strings {
@@ -648,21 +614,6 @@ private extension DashboardPromptsCardCell {
648614
}
649615
}
650616
}
651-
652-
var toMenuSheetItem: MenuSheetViewController.MenuItem {
653-
switch self {
654-
case .viewMore(let handler),
655-
.skip(let handler),
656-
.remove(let handler),
657-
.learnMore(let handler):
658-
return MenuSheetViewController.MenuItem(
659-
title: title,
660-
image: image,
661-
destructive: menuAttributes.contains(.destructive),
662-
handler: handler
663-
)
664-
}
665-
}
666617
}
667618
}
668619

WordPress/Classes/ViewRelated/Blog/QuickStartChecklistViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,7 @@ private extension QuickStartChecklistViewController {
107107
navigationItem.standardAppearance = appearance
108108
navigationItem.compactAppearance = appearance
109109
navigationItem.scrollEdgeAppearance = appearance
110-
if #available(iOS 15.0, *) {
111-
navigationItem.compactScrollEdgeAppearance = appearance
112-
}
110+
navigationItem.compactScrollEdgeAppearance = appearance
113111
}
114112

115113
func startObservingForQuickStart() {

0 commit comments

Comments
 (0)