Skip to content

Commit

Permalink
Remove additional iOS 15 checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
samsymons committed Jul 19, 2024
1 parent b90cdfb commit 3930bb1
Show file tree
Hide file tree
Showing 28 changed files with 23 additions and 89 deletions.
7 changes: 0 additions & 7 deletions Core/DefaultVariantManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,6 @@ public struct VariantIOS: Variant {
.contains(where: { Locale.current.regionCode == $0 }) }

static let inEnglish = { return Locale.current.languageCode == "en" }

static let iOS15 = { () -> Bool in
if #available(iOS 15, *) {
return true
}
return false
}
}

/// This variant is used for returning users to separate them from really new users.
Expand Down
13 changes: 2 additions & 11 deletions DuckDuckGo/AnimatableTypingText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,8 @@ struct AnimatableTypingText: View {
.frame(maxWidth: .infinity, alignment: .leading)
.visibility(.invisible)

if #available(iOS 15, *) {
Text(AttributedString(model.typedAttributedText))
.frame(maxWidth: .infinity, alignment: .leading)
} else {
Text(model.typedAttributedText.string)
.frame(maxWidth: .infinity, alignment: .leading)
}
Text(AttributedString(model.typedAttributedText))
.frame(maxWidth: .infinity, alignment: .leading)
}
.onChange(of: startAnimating.wrappedValue, perform: { shouldAnimate in
if shouldAnimate {
Expand Down Expand Up @@ -128,10 +123,6 @@ final class AnimatableTypingTextModel: ObservableObject {
private func showCharacter() {

func attributedTypedString(forTypedChars typedChars: [String.Element]) -> NSAttributedString {
guard #available(iOS 15, *) else {
return NSAttributedString(string: String(typedChars))
}

let chars = Array(text)
let untypedChars = chars[typedChars.count ..< chars.count]
let combined = NSMutableAttributedString(string: String(typedChars))
Expand Down
6 changes: 2 additions & 4 deletions DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -996,10 +996,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate {
Task {
if case .success(let hasEntitlements) = await accountManager.hasEntitlement(forProductName: .networkProtection),
hasEntitlements {
if #available(iOS 15, *) {
let networkProtectionRoot = NetworkProtectionRootViewController()
presentSettings(with: networkProtectionRoot)
}
let networkProtectionRoot = NetworkProtectionRootViewController()
presentSettings(with: networkProtectionRoot)
} else {
(window?.rootViewController as? MainViewController)?.segueToPrivacyPro()
}
Expand Down
30 changes: 11 additions & 19 deletions DuckDuckGo/AutofillLoginDetailsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,19 @@ struct AutofillLoginDetailsView: View {
usernameCell()
} footer: {
if !viewModel.isSignedIn {
if #available(iOS 15, *) {
var attributedString: AttributedString {
let text = String(format: UserText.autofillSignInToManageEmail, UserText.autofillEnableEmailProtection)
var attributedString = AttributedString(text)
if let range = attributedString.range(of: UserText.autofillEnableEmailProtection) {
attributedString[range].foregroundColor = Color(ThemeManager.shared.currentTheme.buttonTintColor)
}
return attributedString
var attributedString: AttributedString {
let text = String(format: UserText.autofillSignInToManageEmail, UserText.autofillEnableEmailProtection)
var attributedString = AttributedString(text)
if let range = attributedString.range(of: UserText.autofillEnableEmailProtection) {
attributedString[range].foregroundColor = Color(ThemeManager.shared.currentTheme.buttonTintColor)
}
Text(attributedString)
.font(.footnote)
.lineLimit(nil)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
} else {
Text(String(format: UserText.autofillSignInToManageEmail, UserText.autofillEnableEmailProtection))
.font(.footnote)
.lineLimit(nil)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
return attributedString
}
Text(attributedString)
.font(.footnote)
.lineLimit(nil)
.multilineTextAlignment(.leading)
.fixedSize(horizontal: false, vertical: true)
}
}
.onTapGesture {
Expand Down
6 changes: 2 additions & 4 deletions DuckDuckGo/HistoryDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ struct HistoryDebugRootView: View {
}
.navigationTitle("\(model.history.count) History Items")
.toolbar {
if #available(iOS 15, *) {
Button("Delete All", role: .destructive) {
model.deleteAll()
}
Button("Delete All", role: .destructive) {
model.deleteAll()
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/HomeMessageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ struct HomeMessageView: View {

@ViewBuilder
private var subtitle: some View {
if #available(iOS 15, *), let attributed = try? AttributedString(markdown: viewModel.subtitle) {
if let attributed = try? AttributedString(markdown: viewModel.subtitle) {
Text(attributed)
.daxBodyRegular()
} else {
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/ImportPasswordsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ private extension String {

}

@available(iOS 15, *)
private extension AttributedString {

mutating func applyFontStyle(forSubstring substring: String, withFont font: Font) {
Expand Down
6 changes: 2 additions & 4 deletions DuckDuckGo/MainViewController+KeyCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,8 @@ extension MainViewController {
]

let commands = [alwaysAvailable, browsingCommands, findInPageCommands, arrowKeys, other].flatMap { $0 }
if #available(iOS 15, *) {
commands.forEach {
$0.wantsPriorityOverSystemBehavior = true
}
commands.forEach {
$0.wantsPriorityOverSystemBehavior = true
}
return commands
}
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/NetworkProtectionDNSSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ struct NetworkProtectionDNSSettingsView: View {
}
}

@available(iOS 15, *)
private struct ChecklistItem<Content>: View where Content: View {
let isSelected: Bool
let action: () -> Void
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/NetworkProtectionRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import SwiftUI
import NetworkProtection
import Subscription

@available(iOS 15, *)
struct NetworkProtectionRootView: View {
let statusViewModel: NetworkProtectionStatusViewModel

Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/NetworkProtectionRootViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import SwiftUI

@available(iOS 15, *)
final class NetworkProtectionRootViewController: UIHostingController<NetworkProtectionRootView> {

init() {
Expand All @@ -40,7 +39,6 @@ final class NetworkProtectionRootViewController: UIHostingController<NetworkProt
}
}

@available(iOS 15, *)
extension NetworkProtectionRootViewController {

private func decorate() {
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/NetworkProtectionStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import SwiftUI
import NetworkProtection

@available(iOS 15, *)
struct NetworkProtectionStatusView: View {
@Environment(\.colorScheme) var colorScheme

Expand Down
4 changes: 0 additions & 4 deletions DuckDuckGo/NetworkProtectionVPNLocationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import Foundation
import SwiftUI

@available(iOS 15, *)
struct NetworkProtectionVPNLocationView: View {
@StateObject var model = NetworkProtectionVPNLocationViewModel(accountManager: AppDependencyProvider.shared.subscriptionManager.accountManager)

Expand Down Expand Up @@ -97,7 +96,6 @@ struct NetworkProtectionVPNLocationView: View {
}
}

@available(iOS 15, *)
private struct CountryItem: View {
let itemModel: NetworkProtectionVPNCountryItemModel
let action: () -> Void
Expand Down Expand Up @@ -145,7 +143,6 @@ private struct CountryItem: View {
}
}

@available(iOS 15, *)
private struct ChecklistItem<Content>: View where Content: View {
let isSelected: Bool
let action: () -> Void
Expand All @@ -170,7 +167,6 @@ private struct ChecklistItem<Content>: View where Content: View {
}
}

@available(iOS 15, *)
private struct MenuItem: View {
let isSelected: Bool
let title: String
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/NetworkProtectionVPNSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import SwiftUI
import DesignResourcesKit

@available(iOS 15, *)
struct NetworkProtectionVPNSettingsView: View {
@StateObject var viewModel = NetworkProtectionVPNSettingsViewModel()

Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/SettingsLegacyViewProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ class SettingsLegacyViewProvider: ObservableObject {
var autoclearData: UIViewController { instantiate("AutoClearSettingsViewController", fromStoryboard: "Settings") }
var keyboard: UIViewController { instantiate("Keyboard", fromStoryboard: "Settings") }
var feedback: UIViewController { instantiate("Feedback", fromStoryboard: "Feedback") }

@available(iOS 15, *)
var netP: UIViewController { NetworkProtectionRootViewController() }

@MainActor
Expand Down
6 changes: 2 additions & 4 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -597,10 +597,8 @@ extension SettingsViewModel {

#if NETWORK_PROTECTION
case .netP:
if #available(iOS 15, *) {
firePixel(.privacyProVPNSettings)
pushViewController(legacyViewProvider.netP)
}
firePixel(.privacyProVPNSettings)
pushViewController(legacyViewProvider.netP)
#endif
}
}
Expand Down
2 changes: 0 additions & 2 deletions DuckDuckGo/SpeechRecognizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ final class SpeechRecognizer: NSObject, SpeechRecognizerProtocol {
return normalized
}

// https://app.asana.com/0/1201011656765697/1201271104639596
@available(iOS 15, *)
func startRecording(resultHandler: @escaping (_ text: String?,
_ error: Error?,
_ speechDidFinish: Bool) -> Void,
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/SpeechRecognizerProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ protocol SpeechRecognizerProtocol {
func getVolumeLevel(from channelData: UnsafeMutablePointer<Float>) -> Float
func stopRecording()

@available(iOS 15, *)
func startRecording(resultHandler: @escaping (_ text: String?,
_ error: Error?, _
speechDidFinish: Bool) -> Void,
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Subscription/Views/SubscriptionEmailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ struct SubscriptionEmailView: View {
}

// Commented out because CI fails if a SwiftUI preview is enabled https://app.asana.com/0/414709148257752/1206774081310425/f
// @available(iOS 15.0, *)
// struct SubscriptionEmailView_Previews: PreviewProvider {
// static var previews: some View {
// SubscriptionEmailView()
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Subscription/Views/SubscriptionFlowView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ struct SubscriptionFlowView: View {
}

// Commented out because CI fails if a SwiftUI preview is enabled https://app.asana.com/0/414709148257752/1206774081310425/f
// @available(iOS 15.0, *)
// struct SubscriptionFlowView_Previews: PreviewProvider {
// static var previews: some View {
// SubscriptionFlowView()
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Subscription/Views/SubscriptionITPView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ struct SubscriptionITPView: View {
}

// Commented out because CI fails if a SwiftUI preview is enabled https://app.asana.com/0/414709148257752/1206774081310425/f
// @available(iOS 15.0, *)
// struct SubscriptionITPView_Previews: PreviewProvider {
// static var previews: some View {
// SubscriptionITPView()
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/Subscription/Views/SubscriptionPIRView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ struct SubscriptionPIRView: View {
}

// Commented out because CI fails if a SwiftUI preview is enabled https://app.asana.com/0/414709148257752/1206774081310425/f
// @available(iOS 15.0, *)
// struct SubscriptionPIRView_Previews: PreviewProvider {
// static var previews: some View {
// SubscriptionPIRView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ struct SubscriptionSettingsView: View {
}

// Commented out because CI fails if a SwiftUI preview is enabled https://app.asana.com/0/414709148257752/1206774081310425/f
// @available(iOS 15.0, *)
// struct SubscriptionSettingsView_Previews: PreviewProvider {
// static var previews: some View {
// SubscriptionSettingsView()
Expand Down
4 changes: 1 addition & 3 deletions DuckDuckGo/VoiceSearchFeedbackView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ struct VoiceSearchFeedbackView: View {
voiceFeedbackView
}
.onAppear {
if #available(iOS 15, *) {
speechModel.startSpeechRecognizer()
}
speechModel.startSpeechRecognizer()
speechModel.startSilenceAnimation()
}.onDisappear {
speechModel.stopSpeechRecognizer()
Expand Down
1 change: 0 additions & 1 deletion DuckDuckGo/VoiceSearchFeedbackViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class VoiceSearchFeedbackViewModel: ObservableObject {
self.speechRecognizer = speechRecognizer
}

@available(iOS 15, *)
func startSpeechRecognizer() {
speechRecognizer.startRecording { [weak self] text, error, speechDidFinish in
DispatchQueue.main.async {
Expand Down
8 changes: 0 additions & 8 deletions DuckDuckGoTests/AnimatableTypingTextModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ final class AnimatableTypingTextModelTests: XCTestCase {
}

func testWhenTimerFiresThenTypedTextIsPublished_iOS15() throws {
guard #available(iOS 15, *) else {
throw XCTSkip("Test available only on iOS 15*")
}

// GIVEN
let text = "Hello World!!!"
var typedText: NSAttributedString = .init(string: "")
Expand All @@ -97,10 +93,6 @@ final class AnimatableTypingTextModelTests: XCTestCase {
}

func testWhenStopAnimatingIsCalledThenWholeTextIsPublished_iOS15() throws {
guard #available(iOS 15, *) else {
throw XCTSkip("Test available only on iOS 15*")
}

// GIVEN
let text = "Hello World!!!"
var typedText: NSAttributedString = .init(string: "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ public struct PasteCodeView: View {
.padding()
}

@available(iOS 15, *)
var instructionsString: AttributedString {
let baseString = UserText.manuallyEnterCodeInstructionAttributed(syncMenuPath: UserText.syncMenuPath, menuItem: UserText.viewTextCodeMenuItem)
var instructions = AttributedString(baseString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public struct ScanOrSeeCode: View {
return Text(instructionsString)
}

@available(iOS 15, *)
var instructionsString: AttributedString {
let baseString = UserText.scanOrSeeCodeInstructionAttributed(syncMenuPath: UserText.syncMenuPath)
var instructions = AttributedString(baseString)
Expand Down

0 comments on commit 3930bb1

Please sign in to comment.