Skip to content

Commit 21bc222

Browse files
authored
Remove redundant availability checks for iOS <= 15.0 (#8291)
2 parents 70743e2 + 428395d commit 21bc222

File tree

13 files changed

+17
-74
lines changed

13 files changed

+17
-74
lines changed

WooCommerce/Classes/Authentication/AuthenticatedWebViewController.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ private extension AuthenticatedWebViewController {
7878

7979
func extendContentUnderSafeAreas() {
8080
webView.scrollView.clipsToBounds = false
81-
if #available(iOS 15.0, *) {
82-
view.backgroundColor = webView.underPageBackgroundColor
83-
} else {
84-
view.backgroundColor = webView.backgroundColor
85-
}
81+
view.backgroundColor = webView.underPageBackgroundColor
8682
}
8783

8884
func configureProgressBar() {

WooCommerce/Classes/Authentication/WebAuth/WebKitViewController.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -272,10 +272,7 @@ class WebKitViewController: UIViewController {
272272
appearance.backgroundColor = UIColor(light: .white, dark: .gray)
273273

274274
toolBar.standardAppearance = appearance
275-
276-
if #available(iOS 15.0, *) {
277-
toolBar.scrollEdgeAppearance = appearance
278-
}
275+
toolBar.scrollEdgeAppearance = appearance
279276

280277
fixBarButtonsColorForBoldText(on: toolBar)
281278
}

WooCommerce/Classes/Extensions/UITabBar+Appearance.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ extension UITabBar {
2424
/// This is needed because the tab bar background has the wrong color under iOS 15 (using Xcode 13).
2525
/// More: issue-5018
2626
///
27-
if #available(iOS 15.0, *) {
28-
appearance.scrollEdgeAppearance = appearance.standardAppearance
29-
}
27+
appearance.scrollEdgeAppearance = appearance.standardAppearance
3028
}
3129

3230
/// Creates an appearance object for a tabbar with the default WC style.

WooCommerce/Classes/Extensions/UIViewController+Helpers.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ extension UIViewController {
1515
/// Removes the text of the navigation bar back button in the next view controller of the navigation stack.
1616
///
1717
func removeNavigationBackBarButtonText() {
18-
if #available(iOS 14.0, *) {
19-
navigationItem.backButtonDisplayMode = .minimal
20-
} else {
21-
navigationItem.backBarButtonItem = UIBarButtonItem(image: UIImage(), style: .plain, target: nil, action: nil)
22-
}
18+
navigationItem.backButtonDisplayMode = .minimal
2319
}
2420

2521
/// Show the X close button or a custom close button with title on the left bar button item position

WooCommerce/Classes/Styles/Style.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,10 @@ final class StyleManager {
5959
private extension StyleManager {
6060
class func fontForTextStyle(_ style: UIFont.TextStyle, weight: UIFont.Weight, maximumPointSize: CGFloat = maxFontSize) -> UIFont {
6161
let traits = [UIFontDescriptor.TraitKey.weight: weight]
62-
if #available(iOS 11, *) {
63-
var fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
64-
fontDescriptor = fontDescriptor.addingAttributes([.traits: traits])
65-
let fontToGetSize = UIFont(descriptor: fontDescriptor, size: CGFloat(0.0))
66-
return UIFontMetrics(forTextStyle: style).scaledFont(for: fontToGetSize, maximumPointSize: maximumPointSize)
67-
}
68-
69-
var scaledFontDescriptor = fontDescriptor(style, maximumPointSize: maximumPointSize)
70-
scaledFontDescriptor = scaledFontDescriptor.addingAttributes([.traits: traits])
71-
return UIFont(descriptor: scaledFontDescriptor, size: CGFloat(0.0))
62+
var fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
63+
fontDescriptor = fontDescriptor.addingAttributes([.traits: traits])
64+
let fontToGetSize = UIFont(descriptor: fontDescriptor, size: CGFloat(0.0))
65+
return UIFontMetrics(forTextStyle: style).scaledFont(for: fontToGetSize, maximumPointSize: maximumPointSize)
7266
}
7367

7468

WooCommerce/Classes/View Modifiers/View+AutofocusTextModifier.swift

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import SwiftUI
22

33
/// Autofocus for `TextField` and `TextEditor` in iOS 15 and later
44
///
5-
@available(iOS 15.0, *)
65
struct AutofocusTextModifier: ViewModifier {
76

87
@FocusState private var textFieldIsFocused: Bool
@@ -27,14 +26,6 @@ extension View {
2726
/// Autofocus in `TextField` and `TextEditor` is available only for iOS15+
2827
///
2928
func focused() -> some View {
30-
// Conditional check has to be done inside the Group function builder,
31-
// otherwise the iOS 15 modifier will be loaded into memory and the app will crash.
32-
Group {
33-
if #available(iOS 15.0, *) {
34-
self.modifier(AutofocusTextModifier())
35-
} else {
36-
self
37-
}
38-
}
29+
modifier(AutofocusTextModifier())
3930
}
4031
}

WooCommerce/Classes/ViewRelated/Coupons/CouponListViewController.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,8 @@ final class CouponListViewController: UIViewController, GhostableViewController
154154
snapshot.appendSections([.main])
155155
snapshot.appendItems(viewModels, toSection: Section.main)
156156

157-
if #available(iOS 15.0, *) {
158-
// minimally reloads the list without computing diff or animation
159-
self.dataSource.applySnapshotUsingReloadData(snapshot)
160-
} else {
161-
self.dataSource.apply(snapshot)
162-
}
157+
// minimally reloads the list without computing diff or animation
158+
self.dataSource.applySnapshotUsingReloadData(snapshot)
163159
}
164160
.store(in: &subscriptions)
165161

WooCommerce/Classes/ViewRelated/Dashboard/MyStore/TopPerformerDataViewController.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ private extension TopPerformerDataViewController {
128128
tableView.applyFooterViewForHidingExtraRowPlaceholders()
129129

130130
// Removes extra top padding in iOS 15+.
131-
if #available(iOS 15.0, *) {
132-
tableView.sectionHeaderTopPadding = 0
133-
}
131+
tableView.sectionHeaderTopPadding = 0
134132
}
135133

136134
func configureResultsController() {

WooCommerce/Classes/ViewRelated/Orders/Order Creation/CustomerSection/OrderCustomerSection.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ private extension OrderCustomerSectionContent {
135135
}
136136
}
137137

138-
@available(iOS 15.0, *)
139138
struct OrderCustomerSection_Previews: PreviewProvider {
140139
static var previews: some View {
141140
let emptyViewModel = EditableOrderViewModel.CustomerDataViewModel(billingAddress: nil, shippingAddress: nil)

WooCommerce/Classes/ViewRelated/Orders/Order Details/Issue Refunds/IssueRefundCoordinatingController.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,6 @@ private extension IssueRefundCoordinatingController {
134134
let viewProperties = InProgressViewProperties(title: Localization.issuingRefund, message: "")
135135
let inProgressViewController = InProgressViewController(viewProperties: viewProperties)
136136

137-
// Before iOS 13, a modal with transparent background requires certain
138-
// `modalPresentationStyle` to prevent the view from turning dark after being presented.
139-
if #available(iOS 13.0, *) {} else {
140-
inProgressViewController.modalPresentationStyle = .overCurrentContext
141-
}
142-
143137
present(inProgressViewController, animated: true)
144138
}
145139

0 commit comments

Comments
 (0)