Skip to content

Commit

Permalink
refactor: remove #available(iOS 13.0, *) checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Feb 1, 2023
1 parent 50287e4 commit 7c20f85
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 71 deletions.
7 changes: 1 addition & 6 deletions IVPNClient/Scenes/MainScreen/Map/MapMarkerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,7 @@ class MapMarkerView: UIView {

private func addObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(hidePopup), name: Notification.Name.HideConnectionInfoPopup, object: nil)

if #available(iOS 13.0, *) {
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive), name: UIScene.didActivateNotification, object: nil)
} else {
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil)
}
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive), name: UIScene.didActivateNotification, object: nil)
}

// MARK: - Private methods -
Expand Down
11 changes: 3 additions & 8 deletions IVPNClient/Scenes/MainScreen/View/ControlPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,8 @@ class ControlPanelView: UITableView {
// MARK: - Methods -

func setupView() {
if #available(iOS 13.0, *) {
connectSwitch.thumbTintColor = UIColor.init(named: Theme.ivpnGray17)
connectSwitch.onTintColor = UIColor.init(named: Theme.ivpnBlue)
}

connectSwitch.thumbTintColor = UIColor.init(named: Theme.ivpnGray17)
connectSwitch.onTintColor = UIColor.init(named: Theme.ivpnBlue)
updateConnectSwitch()
UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: protectionStatusTableCell)

Expand Down Expand Up @@ -149,9 +146,7 @@ class ControlPanelView: UITableView {
}

private func updateConnectSwitch() {
if #available(iOS 13.0, *) {
connectSwitch.subviews[0].subviews[0].backgroundColor = UIColor.init(named: Theme.ivpnRedOff)
}
connectSwitch.subviews[0].subviews[0].backgroundColor = UIColor.init(named: Theme.ivpnRedOff)
}

}
7 changes: 1 addition & 6 deletions IVPNClient/Scenes/SecureDNS/View/SecureDNSView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ class SecureDNSView: UITableView {
// MARK: - Observers -

private func addObservers() {
if #available(iOS 13.0, *) {
NotificationCenter.default.addObserver(self, selector: #selector(updateEnableSwitch), name: UIScene.didActivateNotification, object: nil)
} else {
NotificationCenter.default.addObserver(self, selector: #selector(updateEnableSwitch), name: UIApplication.didBecomeActiveNotification, object: nil)
}

NotificationCenter.default.addObserver(self, selector: #selector(updateEnableSwitch), name: UIScene.didActivateNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateResolvedDNS), name: Notification.Name.UpdateResolvedDNS, object: nil)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ class CreateAccountViewController: UIViewController {

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

}
4 changes: 1 addition & 3 deletions IVPNClient/Scenes/Signup/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ class LoginViewController: UIViewController {

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

// MARK: - Observers -
Expand Down
5 changes: 1 addition & 4 deletions IVPNClient/Scenes/Signup/Payment/PaymentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ class PaymentViewController: UITableViewController {
}

private func setupView() {
if #available(iOS 13.0, *) {
isModalInPresentation = true
}

isModalInPresentation = true
view.backgroundColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)
payButton?.set(title: "Pay", subtitle: "")

Expand Down
4 changes: 1 addition & 3 deletions IVPNClient/Scenes/Signup/Scanner/ScannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ class ScannerViewController: UIViewController, AVCaptureMetadataOutputObjectsDel

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()

evaluateCameraAccess()
startCaptureSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ class SelectPlanViewController: UITableViewController {
super.viewWillAppear(animated)
// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -179,10 +177,7 @@ class SelectPlanViewController: UITableViewController {
}

private func setupView() {
if #available(iOS 13.0, *) {
isModalInPresentation = true
}

isModalInPresentation = true
tableView.separatorStyle = .none
view.addSubview(spinner)
view.addSubview(retryButton)
Expand Down
25 changes: 9 additions & 16 deletions IVPNClient/Scenes/ViewControllers/NavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,15 @@ class NavigationController: UINavigationController {
UINavigationBar.appearance().tintColor = UIColor.init(named: Theme.ivpnBlue)
navigationBar.prefersLargeTitles = true

if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: .bold), NSAttributedString.Key.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.backgroundColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)!
appearance.shadowImage = nil
appearance.shadowColor = nil
navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = appearance
} else {
navigationBar.barTintColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)
navigationBar.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: .bold), NSAttributedString.Key.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
navigationBar.shadowImage = UIImage()
navigationBar.barTintColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)!
}
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: .bold), NSAttributedString.Key.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.backgroundColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)!
appearance.shadowImage = nil
appearance.shadowColor = nil
navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = appearance
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class TermsOfServiceViewController: UIViewController {
super.viewWillAppear(animated)
// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

// MARK: - Methods -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class UpgradePlanViewController: UIViewController {

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

// MARK: - @IBActions -
Expand Down
6 changes: 1 addition & 5 deletions IVPNClient/Utilities/Extensions/UIImageView+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ extension UIImageView {
func setFlagIconBorder() {
layer.cornerRadius = 2.0
layer.shadowRadius = 0.5
if #available(iOS 13.0, *) {
layer.shadowColor = UIColor.label.cgColor
} else {
layer.shadowColor = UIColor.black.cgColor
}
layer.shadowColor = UIColor.label.cgColor
layer.shadowOffset = CGSize(width: 0, height: 0)
layer.shadowOpacity = 0.3
backgroundColor = UIColor.clear
Expand Down
7 changes: 3 additions & 4 deletions IVPNClient/Utilities/Extensions/UIViewController+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ extension UIViewController {
// MARK: - @IBActions -

@IBAction func dismissViewController(_ sender: Any) {
if #available(iOS 13.0, *) {
if let presentationController = navigationController?.presentationController {
presentationController.delegate?.presentationControllerDidDismiss?(presentationController)
}
if let presentationController = navigationController?.presentationController {
presentationController.delegate?.presentationControllerDidDismiss?(presentationController)
}

navigationController?.dismiss(animated: true)
}

Expand Down

0 comments on commit 7c20f85

Please sign in to comment.