mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 04:53:36 +00:00
[ios] Removing conditionals for unsupported iOS versions
Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
@@ -7,9 +7,7 @@ final class RangeFirstCell: Cell {
|
||||
contentView.addSubview(rangeBgView)
|
||||
rangeBgView.alignToSuperview(UIEdgeInsets(top: 4, left: 4, bottom: -4, right: 0))
|
||||
rangeBgView.layer.cornerRadius = 8
|
||||
if #available(iOS 13.0, *) {
|
||||
rangeBgView.layer.cornerCurve = .continuous
|
||||
}
|
||||
rangeBgView.layer.maskedCorners = [.layerMinXMinYCorner, .layerMinXMaxYCorner]
|
||||
super.addSubviews()
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ final class RangeLastCell: Cell {
|
||||
contentView.addSubview(rangeBgView)
|
||||
rangeBgView.alignToSuperview(UIEdgeInsets(top: 4, left: 0, bottom: -4, right: -4))
|
||||
rangeBgView.layer.cornerRadius = 8
|
||||
if #available(iOS 13.0, *) {
|
||||
rangeBgView.layer.cornerCurve = .continuous
|
||||
}
|
||||
rangeBgView.layer.maskedCorners = [.layerMaxXMinYCorner, .layerMaxXMaxYCorner]
|
||||
super.addSubviews()
|
||||
}
|
||||
|
||||
@@ -7,9 +7,7 @@ final class RangeSingleCell: Cell {
|
||||
contentView.addSubview(rangeBgView)
|
||||
rangeBgView.alignToSuperview(UIEdgeInsets(top: 4, left: 4, bottom: -4, right: -4))
|
||||
rangeBgView.layer.cornerRadius = 8
|
||||
if #available(iOS 13.0, *) {
|
||||
rangeBgView.layer.cornerCurve = .continuous
|
||||
}
|
||||
super.addSubviews()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,7 @@ class SelectedSingleCell: Cell {
|
||||
contentView.addSubview(selectedBgView)
|
||||
selectedBgView.alignToSuperview(UIEdgeInsets(top: 4, left: 4, bottom: -4, right: -4))
|
||||
selectedBgView.layer.cornerRadius = 8
|
||||
if #available(iOS 13.0, *) {
|
||||
selectedBgView.layer.cornerCurve = .continuous
|
||||
}
|
||||
super.addSubviews()
|
||||
}
|
||||
|
||||
|
||||
@@ -5,11 +5,9 @@ extension CALayer {
|
||||
if let maskedCorners {
|
||||
self.maskedCorners = maskedCorners
|
||||
}
|
||||
if #available(iOS 13.0, *) {
|
||||
cornerCurve = .continuous
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension CACornerMask {
|
||||
static var all: CACornerMask {
|
||||
|
||||
@@ -54,9 +54,7 @@ final class CarPlayService: NSObject {
|
||||
applyBaseRootTemplate()
|
||||
router.restoreTripPreviewOnCarplay(beforeRootTemplateDidAppear: true)
|
||||
}
|
||||
if #available(iOS 13.0, *) {
|
||||
updateContentStyle(configuration.contentStyle)
|
||||
}
|
||||
FrameworkHelper.updatePositionArrowOffset(false, offset: 5)
|
||||
|
||||
CarPlayWindowScaleAdjuster.updateAppearance(
|
||||
|
||||
@@ -96,7 +96,6 @@ final class ListTemplateBuilder {
|
||||
bookmarkId: bookmark.bookmarkId))
|
||||
return item
|
||||
})
|
||||
if #available(iOS 15.0, *) {
|
||||
let maxItemCount = CPListTemplate.maximumItemCount - 1
|
||||
if items.count >= maxItemCount {
|
||||
items = Array(items.prefix(maxItemCount))
|
||||
@@ -104,7 +103,6 @@ final class ListTemplateBuilder {
|
||||
cropWarning.isEnabled = false
|
||||
items.append(cropWarning)
|
||||
}
|
||||
}
|
||||
let section = CPListSection(items: items)
|
||||
template.updateSections([section])
|
||||
}
|
||||
|
||||
@@ -29,12 +29,7 @@ class CopyableLabel: UILabel {
|
||||
var rect = bounds
|
||||
rect.origin = locationOfTouchInLabel
|
||||
rect.size = CGSize(width: 1, height: 1)
|
||||
if #available(iOS 13, *) {
|
||||
menu.showMenu(from: self, rect: rect)
|
||||
} else {
|
||||
menu.setTargetRect(rect, in: self)
|
||||
menu.setMenuVisible(true, animated: false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
final class LoadingOverlayViewController: UIViewController {
|
||||
private var activityIndicator: UIActivityIndicatorView = {
|
||||
let indicator: UIActivityIndicatorView
|
||||
if #available(iOS 13.0, *) {
|
||||
indicator = UIActivityIndicatorView(style: .large)
|
||||
} else {
|
||||
indicator = UIActivityIndicatorView(style: .whiteLarge)
|
||||
}
|
||||
indicator.color = .white
|
||||
indicator.startAnimating()
|
||||
indicator.translatesAutoresizingMaskIntoConstraints = false
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import Foundation
|
||||
|
||||
var isiPad: Bool {
|
||||
if #available(iOS 14.0, *), ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
if ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
return true
|
||||
}
|
||||
return UIDevice.current.userInterfaceIdiom == .pad
|
||||
|
||||
@@ -45,10 +45,6 @@
|
||||
listener.applyTheme()
|
||||
}
|
||||
}
|
||||
|
||||
if #available(iOS 13, *) {} else {
|
||||
UISearchBarRenderer.setAppearance()
|
||||
}
|
||||
}
|
||||
|
||||
private func updateView(_ view: UIView?) {
|
||||
|
||||
@@ -10,9 +10,7 @@ final class ThemeManager: NSObject {
|
||||
}
|
||||
|
||||
private func update(theme: MWMTheme) {
|
||||
if #available(iOS 13.0, *) {
|
||||
updateSystemUserInterfaceStyle(theme)
|
||||
}
|
||||
|
||||
let actualTheme: MWMTheme = { theme in
|
||||
let isVehicleRouting = MWMRouter.isRoutingActive() && (MWMRouter.type() == .vehicle)
|
||||
@@ -22,19 +20,9 @@ final class ThemeManager: NSObject {
|
||||
case .night: fallthrough
|
||||
case .vehicleNight: return isVehicleRouting ? .vehicleNight : .night
|
||||
case .auto:
|
||||
if #available(iOS 13.0, *) {
|
||||
let isDarkModeEnabled = UIScreen.main.traitCollection.userInterfaceStyle == .dark
|
||||
guard isVehicleRouting else { return isDarkModeEnabled ? .night : .day }
|
||||
return isDarkModeEnabled ? .vehicleNight : .vehicleDay
|
||||
} else {
|
||||
guard isVehicleRouting else { return .day }
|
||||
switch FrameworkHelper.daytime(at: LocationManager.lastLocation()) {
|
||||
case .day: return .vehicleDay
|
||||
case .night: return .vehicleNight
|
||||
@unknown default:
|
||||
fatalError()
|
||||
}
|
||||
}
|
||||
@unknown default:
|
||||
fatalError()
|
||||
}
|
||||
|
||||
@@ -15,23 +15,15 @@ class UINavigationBarRenderer: UIViewRenderer {
|
||||
class func render(_ control: UINavigationBar, style: Style) {
|
||||
super.render(control, style: style)
|
||||
if let barTintColor = style.barTintColor {
|
||||
if #available(iOS 13.0, *) {
|
||||
let appearance = UINavigationBarAppearance()
|
||||
appearance.configureWithOpaqueBackground()
|
||||
appearance.backgroundColor = barTintColor
|
||||
control.standardAppearance = appearance
|
||||
control.scrollEdgeAppearance = appearance
|
||||
} else {
|
||||
control.barTintColor = barTintColor
|
||||
}
|
||||
}
|
||||
if let shadowImage = style.shadowImage {
|
||||
if #available(iOS 13.0, *) {
|
||||
control.standardAppearance.shadowImage = shadowImage
|
||||
control.scrollEdgeAppearance!.shadowImage = shadowImage
|
||||
} else {
|
||||
control.shadowImage = shadowImage
|
||||
}
|
||||
}
|
||||
|
||||
var attributes = [NSAttributedString.Key: Any]()
|
||||
@@ -41,11 +33,7 @@ class UINavigationBarRenderer: UIViewRenderer {
|
||||
if let fontColor = style.fontColor {
|
||||
attributes[NSAttributedString.Key.foregroundColor] = fontColor
|
||||
}
|
||||
if #available(iOS 13.0, *) {
|
||||
control.standardAppearance.titleTextAttributes = attributes
|
||||
control.scrollEdgeAppearance!.titleTextAttributes = attributes
|
||||
} else {
|
||||
control.titleTextAttributes = attributes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,10 @@ extension UISearchBar {
|
||||
class UISearchBarRenderer: UIViewRenderer {
|
||||
class func render(_ control: UISearchBar, style: Style) {
|
||||
super.render(control, style: style)
|
||||
if #available(iOS 13, *) {
|
||||
|
||||
let searchTextField = control.searchTextField
|
||||
// Default search bar implementation adds the grey transparent image for background. This code removes it and updates the corner radius. This is not working on iPad designed for mac.
|
||||
if #available(iOS 14.0, *), ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
} else {
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
control.setSearchFieldBackgroundImage(UIImage(), for: .normal)
|
||||
}
|
||||
searchTextField.layer.setCornerRadius(.buttonDefault)
|
||||
@@ -54,14 +53,6 @@ class UISearchBarRenderer: UIViewRenderer {
|
||||
let clearButtonImage = UIImage(named: "ic_clear")?.withRenderingMode(.alwaysTemplate).withTintColor(tintColor)
|
||||
control.setImage(clearButtonImage, for: .clear, state: .normal)
|
||||
}
|
||||
} else {
|
||||
// Default search bar implementation for iOS12 adds the dark grey transparent image for background. This code removes it and replace with the custom image accordingly to the documentation - see 'setSearchFieldBackgroundImage'.
|
||||
if let backgroundColor = style.backgroundColor {
|
||||
let image = getSearchBarBackgroundImage(color: backgroundColor)
|
||||
control.setSearchFieldBackgroundImage(image, for: .normal)
|
||||
control.searchTextPositionAdjustment = UIOffset(horizontal: 6.0, vertical: 0.0)
|
||||
}
|
||||
}
|
||||
if let barTintColor = style.barTintColor {
|
||||
let position = control.delegate?.position?(for: control) ?? control.barPosition
|
||||
control.setBackgroundImage(barTintColor.getImage(), for: position, barMetrics: .defaultPrompt)
|
||||
|
||||
@@ -57,8 +57,6 @@ class UIViewRenderer {
|
||||
if let round = style.round, round == true {
|
||||
control.layer.cornerRadius = control.size.height / 2
|
||||
}
|
||||
if #available(iOS 13.0, *) {
|
||||
control.layer.cornerCurve = .continuous
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ final class ColorPicker: NSObject {
|
||||
|
||||
switch pickerType {
|
||||
case .defaultColorPicker(let color):
|
||||
if #available(iOS 14.0, *), !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
if !ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
colorPickerViewController = defaultColorPickerViewController(with: color)
|
||||
} else {
|
||||
colorPickerViewController = bookmarksColorPickerViewController(with: BookmarkColor.bookmarkColor(from: color) ?? .none)
|
||||
|
||||
@@ -9,11 +9,7 @@ final class DocumentPicker: NSObject {
|
||||
completionHandler: @escaping URLsCompletionHandler) {
|
||||
self.completionHandler = completionHandler
|
||||
let documentPickerViewController: UIDocumentPickerViewController
|
||||
if #available(iOS 14.0, *) {
|
||||
documentPickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: fileTypes.map(\.utType), asCopy: true)
|
||||
} else {
|
||||
documentPickerViewController = UIDocumentPickerViewController(documentTypes: fileTypes.map(\.typeIdentifier), in: .import)
|
||||
}
|
||||
documentPickerViewController.delegate = self
|
||||
// TODO: Enable multiple selection when the multiple files parsing support will be added to the bookmark_manager.
|
||||
documentPickerViewController.allowsMultipleSelection = false
|
||||
|
||||
@@ -39,7 +39,7 @@ final class PlacePageEditBookmarkOrTrackViewController: UIViewController {
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
if #available(iOS 13.0, *), traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
|
||||
if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
|
||||
applyTheme()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ final class CircleImageButton: UIButton {
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
if #available(iOS 13.0, *), traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
|
||||
if traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) {
|
||||
circleImageView.applyTheme()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,26 +111,10 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
|
||||
}
|
||||
|
||||
func showShareTrackMenu() {
|
||||
if #available(iOS 14.0, *) {
|
||||
// The menu will be shown by the shareButton itself
|
||||
} else {
|
||||
let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
|
||||
let kmlAction = UIAlertAction(title: L("export_file"), style: .default) { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.presenter?.onExportTrackButtonPress(.text, from: self.shareButton)
|
||||
}
|
||||
let gpxAction = UIAlertAction(title: L("export_file_gpx"), style: .default) { [weak self] _ in
|
||||
guard let self else { return }
|
||||
self.presenter?.onExportTrackButtonPress(.gpx, from: self.shareButton)
|
||||
}
|
||||
alert.addAction(kmlAction)
|
||||
alert.addAction(gpxAction)
|
||||
present(alert, animated: true, completion: nil)
|
||||
}
|
||||
}
|
||||
|
||||
private func configureTrackSharingMenu() {
|
||||
if #available(iOS 14.0, *) {
|
||||
let menu = UIMenu(title: "", image: nil, children: [
|
||||
UIAction(title: L("export_file"), image: nil, handler: { [weak self] _ in
|
||||
guard let self else { return }
|
||||
@@ -145,4 +129,3 @@ extension PlacePageHeaderViewController: PlacePageHeaderViewProtocol {
|
||||
shareButton.showsMenuAsPrimaryAction = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -488,7 +488,7 @@ class PlacePageInfoViewController: UIViewController {
|
||||
longPressHandler: { [weak self] in
|
||||
self?.copyCoordinatesToPasteboard()
|
||||
})
|
||||
if #available(iOS 14.0, *) {
|
||||
|
||||
let menu = UIMenu(children: coordFormats.enumerated().map { (index, format) in
|
||||
UIAction(title: format, handler: { [weak self] _ in
|
||||
self?.setCoordinatesSelected(formatId: index)
|
||||
@@ -498,7 +498,6 @@ class PlacePageInfoViewController: UIViewController {
|
||||
coordinatesView?.accessoryButton.menu = menu
|
||||
coordinatesView?.accessoryButton.showsMenuAsPrimaryAction = true
|
||||
}
|
||||
}
|
||||
|
||||
private func setCoordinatesSelected(formatId: Int) {
|
||||
guard let coordFormats = placePageInfoData.coordFormats as? Array<String> else { return }
|
||||
|
||||
@@ -58,13 +58,6 @@ final class PlacePageScrollView: UIScrollView {
|
||||
|
||||
override func viewDidLayoutSubviews() {
|
||||
super.viewDidLayoutSubviews()
|
||||
if #available(iOS 13.0, *) {
|
||||
// See https://github.com/organicmaps/organicmaps/issues/6917 for the details.
|
||||
} else if previousTraitCollection == nil {
|
||||
scrollView.contentInset = alternativeSizeClass(iPhone: UIEdgeInsets(top: scrollView.height, left: 0, bottom: 0, right: 0),
|
||||
iPad: UIEdgeInsets.zero)
|
||||
updateSteps()
|
||||
}
|
||||
panGesture.isEnabled = alternativeSizeClass(iPhone: false, iPad: true)
|
||||
previousTraitCollection = traitCollection
|
||||
}
|
||||
@@ -170,8 +163,7 @@ final class PlacePageScrollView: UIScrollView {
|
||||
actionBarContainerView.layer.setCornerRadius(.modalSheet, maskedCorners: cornersToMask)
|
||||
actionBarContainerView.layer.masksToBounds = true
|
||||
|
||||
// See https://github.com/organicmaps/organicmaps/issues/6917 for the details.
|
||||
if #available(iOS 13.0, *), previousTraitCollection == nil {
|
||||
if previousTraitCollection == nil {
|
||||
scrollView.contentInset = alternativeSizeClass(iPhone: UIEdgeInsets(top: view.height, left: 0, bottom: 0, right: 0),
|
||||
iPad: UIEdgeInsets.zero)
|
||||
scrollView.layoutIfNeeded()
|
||||
|
||||
@@ -61,11 +61,7 @@ final class PlaceholderView: UIView {
|
||||
if let activityIndicator = activityIndicator {
|
||||
activityIndicator.hidesWhenStopped = true
|
||||
activityIndicator.startAnimating()
|
||||
if #available(iOS 13.0, *) {
|
||||
activityIndicator.style = .medium
|
||||
} else {
|
||||
activityIndicator.style = .gray
|
||||
}
|
||||
}
|
||||
|
||||
titleLabel.text = title
|
||||
|
||||
@@ -65,12 +65,10 @@ final class SearchOnMapHeaderView: UIView {
|
||||
searchBar.setStyle(.defaultSearchBar)
|
||||
searchBar.placeholder = L("search")
|
||||
searchBar.showsCancelButton = false
|
||||
if #available(iOS 13.0, *) {
|
||||
searchBar.searchTextField.clearButtonMode = .always
|
||||
searchBar.returnKeyType = .search
|
||||
searchBar.searchTextField.enablesReturnKeyAutomatically = true
|
||||
}
|
||||
}
|
||||
|
||||
private func setupCancelButton() {
|
||||
cancelContainer.setStyle(.background)
|
||||
|
||||
@@ -99,7 +99,7 @@ final class SearchOnMapViewController: UIViewController {
|
||||
|
||||
override func viewWillTransition(to size: CGSize, with coordinator: any UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransition(to: size, with: coordinator)
|
||||
if #available(iOS 14.0, *), ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
if ProcessInfo.processInfo.isiOSAppOnMac {
|
||||
updateFrameOfPresentedViewInContainerView()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user