From f3dd65f32861d7e6491a3dd08d9f70f35889c1e8 Mon Sep 17 00:00:00 2001 From: Ian Saultz <52051793+atierian@users.noreply.github.com> Date: Wed, 24 Nov 2021 13:24:54 -0500 Subject: [PATCH] Remove >5.3 Swift language feature usage to support Xcode 12 (#14) --- .../MGLPointFeature+Geo.Place.swift | 22 +++++++++---------- .../AMLMapView/AMLMapViewSettings.swift | 2 +- .../_MGLMapViewWrapper+Coordinator.swift | 16 +++++++------- .../SupportingViews/AMLPlaceCellView.swift | 4 ++-- .../SupportingViews/AMLSearchBar.swift | 4 ++-- 5 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Sources/AmplifyMapLibreAdapter/Extensions/MGLPointFeature+Geo.Place.swift b/Sources/AmplifyMapLibreAdapter/Extensions/MGLPointFeature+Geo.Place.swift index d2285ba..e36c867 100644 --- a/Sources/AmplifyMapLibreAdapter/Extensions/MGLPointFeature+Geo.Place.swift +++ b/Sources/AmplifyMapLibreAdapter/Extensions/MGLPointFeature+Geo.Place.swift @@ -96,29 +96,29 @@ public extension Geo.Place { fileprivate extension Dictionary where Key == String, Value == Any { private func placeKey(for keyPath: KeyPath) -> String { switch keyPath { - case \.street: return "aml_geo.place_street" - case \.addressNumber: return "aml_geo.place_addressNumber" - case \.label: return "aml_geo.place_label" - case \.country: return "aml_geo.place_country" - case \.municipality: return "aml_geo.place_municipality" - case \.neighborhood: return "aml_geo.place_neighborhood" - case \.postalCode: return "aml_geo.place_postalCode" - case \.region: return "aml_geo.place_region" - case \.subRegion: return "aml_geo.place_subRegion" + case \Geo.Place.street: return "aml_geo.place_street" + case \Geo.Place.addressNumber: return "aml_geo.place_addressNumber" + case \Geo.Place.label: return "aml_geo.place_label" + case \Geo.Place.country: return "aml_geo.place_country" + case \Geo.Place.municipality: return "aml_geo.place_municipality" + case \Geo.Place.neighborhood: return "aml_geo.place_neighborhood" + case \Geo.Place.postalCode: return "aml_geo.place_postalCode" + case \Geo.Place.region: return "aml_geo.place_region" + case \Geo.Place.subRegion: return "aml_geo.place_subRegion" default: return "aml_geo.place_default" } } subscript(_ placeKeyPath: KeyPath) -> T? { get { - if placeKeyPath ~= \.coordinates { + if placeKeyPath ~= \Geo.Place.coordinates { return getCoordinate() as? T } let key = placeKey(for: placeKeyPath) return self[key] as? T } set { - if placeKeyPath ~= \.coordinates { + if placeKeyPath ~= \Geo.Place.coordinates { setCoordinate(newValue) return } diff --git a/Sources/AmplifyMapLibreUI/AMLMapView/AMLMapViewSettings.swift b/Sources/AmplifyMapLibreUI/AMLMapView/AMLMapViewSettings.swift index 2b79ae4..57669d6 100644 --- a/Sources/AmplifyMapLibreUI/AMLMapView/AMLMapViewSettings.swift +++ b/Sources/AmplifyMapLibreUI/AMLMapView/AMLMapViewSettings.swift @@ -58,7 +58,7 @@ internal class AMLMapViewSettings: ObservableObject { maxZoomLevel: Double = 22, hideAttributionButton: Bool = false, compassPosition: MGLOrnamentPosition = .bottomLeft, - featureImage: UIImage = .init( + featureImage: UIImage = UIImage( named: "AMLFeatureView", in: Bundle.module, compatibleWith: nil diff --git a/Sources/AmplifyMapLibreUI/MGLMapViewWrapper/_MGLMapViewWrapper+Coordinator.swift b/Sources/AmplifyMapLibreUI/MGLMapViewWrapper/_MGLMapViewWrapper+Coordinator.swift index 45aa6fa..8954633 100644 --- a/Sources/AmplifyMapLibreUI/MGLMapViewWrapper/_MGLMapViewWrapper+Coordinator.swift +++ b/Sources/AmplifyMapLibreUI/MGLMapViewWrapper/_MGLMapViewWrapper+Coordinator.swift @@ -67,7 +67,7 @@ extension _MGLMapViewWrapper.Coordinator { /// - Identifier: `"aml_cluster_number_layer"` /// - Parameter style: The `MGLStyle` that the layers will be added to. private func setupRenderingLayers(for style: MGLStyle) { - let locationSource = locationSource() + let locationSource = makeLocationSource() style.addSource(locationSource) let defaultImage = UIImage( named: "AMLFeatureView", @@ -76,19 +76,19 @@ extension _MGLMapViewWrapper.Coordinator { )! style.setImage(defaultImage, forName: "aml_feature") - let featureLayer = featureLayer(for: locationSource) + let featureLayer = makeFeatureLayer(for: locationSource) style.addLayer(featureLayer) - let clusterCircleLayer = clusterCircleLayer(for: locationSource) + let clusterCircleLayer = makeClusterCircleLayer(for: locationSource) style.addLayer(clusterCircleLayer) - let clusterNumberLayer = clusterNumberLayer(for: locationSource) + let clusterNumberLayer = makeClusterNumberLayer(for: locationSource) style.addLayer(clusterNumberLayer) } /// Create the location source used to source features in the subsequent layers. /// - Returns: A `MGLShapeSource` with defined clustering options. - private func locationSource() -> MGLShapeSource { + private func makeLocationSource() -> MGLShapeSource { MGLShapeSource.init( identifier: "aml_location_source", shape: nil, @@ -104,7 +104,7 @@ extension _MGLMapViewWrapper.Coordinator { /// Create the layer that renders features on the map. /// - Parameter source: The layer's source. /// - Returns: A `MGLSymbolStyleLayer` that will render features provided through the `source`. - private func featureLayer(for source: MGLSource) -> MGLSymbolStyleLayer { + private func makeFeatureLayer(for source: MGLSource) -> MGLSymbolStyleLayer { let featureLayer = MGLSymbolStyleLayer(identifier: "aml_feature_style_layer", source: source) featureLayer.iconImageName = NSExpression(forConstantValue: "aml_feature") featureLayer.iconIgnoresPlacement = NSExpression(forConstantValue: true) @@ -117,7 +117,7 @@ extension _MGLMapViewWrapper.Coordinator { /// - Parameter source: The layer's source. Generally the same as the feature layer's `source`. /// - Returns: A `MGLCircleStyleLayer` that will render feature clusters provided through the `source`. /// Clustering behavior defined through `ClusteringBehavior`. - private func clusterCircleLayer(for source: MGLSource) -> MGLCircleStyleLayer { + private func makeClusterCircleLayer(for source: MGLSource) -> MGLCircleStyleLayer { let clusterCircleLayer = MGLCircleStyleLayer(identifier: "aml_cluster_circle_layer", source: source) clusterCircleLayer.circleRadius = NSExpression( @@ -145,7 +145,7 @@ extension _MGLMapViewWrapper.Coordinator { /// Create the layer that renders numbers on the feature clusters on the map. /// - Parameter source: The layer's source. Generally the same as the cluster circle layer's `source`. /// - Returns: A `MGLSymbolStyleLayer` that renders numbers on feature clusters provided through the `source`. - private func clusterNumberLayer(for source: MGLSource) -> MGLSymbolStyleLayer { + private func makeClusterNumberLayer(for source: MGLSource) -> MGLSymbolStyleLayer { let clusterNumberLayer = MGLSymbolStyleLayer(identifier: "aml_cluster_number_layer", source: source) clusterNumberLayer.text = NSExpression(format: "CAST(point_count, 'NSString')") clusterNumberLayer.textColor = NSExpression(forConstantValue: control.clusteringBehavior.clusterNumberColor) diff --git a/Sources/AmplifyMapLibreUI/SupportingViews/AMLPlaceCellView.swift b/Sources/AmplifyMapLibreUI/SupportingViews/AMLPlaceCellView.swift index 4fa7924..9c407f0 100644 --- a/Sources/AmplifyMapLibreUI/SupportingViews/AMLPlaceCellView.swift +++ b/Sources/AmplifyMapLibreUI/SupportingViews/AMLPlaceCellView.swift @@ -24,10 +24,10 @@ public struct AMLPlaceCellView: View { VStack(alignment: .leading) { HStack { Text(place.labelLine ?? "") - .font(.headline.weight(.semibold)) + .font(Font.headline.weight(Font.Weight.semibold)) Spacer() Text(place.neighborhood?.uppercased() ?? "") - .font(.footnote.weight(.light)) + .font(Font.footnote.weight(Font.Weight.light)) .foregroundColor(.secondary) } Text(addressLine(for: place)) diff --git a/Sources/AmplifyMapLibreUI/SupportingViews/AMLSearchBar.swift b/Sources/AmplifyMapLibreUI/SupportingViews/AMLSearchBar.swift index 6245480..e1439fc 100644 --- a/Sources/AmplifyMapLibreUI/SupportingViews/AMLSearchBar.swift +++ b/Sources/AmplifyMapLibreUI/SupportingViews/AMLSearchBar.swift @@ -149,7 +149,7 @@ private struct AMLSearchBarIconOverlay: View { endEditing() }, label: { Image(systemName: "multiply") - .font(.body.weight(.medium)) + .font(Font.body.weight(.medium)) .foregroundColor(.primary) .padding(.trailing, 8) }) @@ -162,7 +162,7 @@ private struct AMLSearchBarIconOverlay: View { endEditing() } label: { Image(systemName: displayState.imageName) - .font(.body.weight(.medium)) + .font(Font.body.weight(.medium)) .foregroundColor(.primary) .padding(.trailing, 8) }