diff --git a/Apps/Examples/Examples/All Examples/SnapshotterExample.swift b/Apps/Examples/Examples/All Examples/SnapshotterExample.swift index 94d43036978e..d46598d94610 100644 --- a/Apps/Examples/Examples/All Examples/SnapshotterExample.swift +++ b/Apps/Examples/Examples/All Examples/SnapshotterExample.swift @@ -61,6 +61,7 @@ public class SnapshotterExample: UIViewController, ExampleProtocol { // Set the camera of the snapshotter mapView.mapboxMap.onEvery(.mapIdle) { [weak self] _ in + // Allow the previous snapshot to complete before starting a new one. guard let self = self, !self.snapshotting else { return } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a1cba4d900c..3e3b5eefcde1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Mapbox welcomes participation and contributions from everyone. ### Features ✨ and improvements 🏁 * Added support for building with Xcode 13b3. ([#564](https://github.com/mapbox/mapbox-maps-ios/pull/564)) +* Added attribution to snapshots generated by `Snapshotter`. ([567](https://github.com/mapbox/mapbox-maps-ios/pull/567)) ## 10.0.0-rc.5 - July 28, 2021 diff --git a/Sources/MapboxMaps/Foundation/Attribution/AttributionView.swift b/Sources/MapboxMaps/Foundation/Attribution/AttributionView.swift index 1c7dac6c89a3..090cae770a91 100644 --- a/Sources/MapboxMaps/Foundation/Attribution/AttributionView.swift +++ b/Sources/MapboxMaps/Foundation/Attribution/AttributionView.swift @@ -10,7 +10,6 @@ internal final class AttributionView: UIView { internal static let padding = CGPoint(x: 10, y: 5) internal init(text: NSAttributedString) { - // Label let label = UILabel() label.attributedText = text var labelSize = label.sizeThatFits(.zero) diff --git a/Sources/MapboxMaps/Foundation/Extensions/UIView.swift b/Sources/MapboxMaps/Foundation/Extensions/UIView.swift new file mode 100644 index 000000000000..c489116aec6e --- /dev/null +++ b/Sources/MapboxMaps/Foundation/Extensions/UIView.swift @@ -0,0 +1,12 @@ +internal extension UIView { + var parentViewController: UIViewController? { + var parentResponder: UIResponder? = self + while parentResponder != nil { + parentResponder = parentResponder?.next + if let viewController = parentResponder as? UIViewController { + return viewController + } + } + return nil + } +} diff --git a/Sources/MapboxMaps/Ornaments/MapboxInfoButtonOrnament.swift b/Sources/MapboxMaps/Ornaments/MapboxInfoButtonOrnament.swift index 09e2f16a1dc9..56b3b57c757b 100644 --- a/Sources/MapboxMaps/Ornaments/MapboxInfoButtonOrnament.swift +++ b/Sources/MapboxMaps/Ornaments/MapboxInfoButtonOrnament.swift @@ -1,6 +1,7 @@ import UIKit @_implementationOnly import MapboxCommon_Private +@available(iOSApplicationExtension, unavailable) internal class MapboxInfoButtonOrnament: UIView { internal weak var attributionDataSource: AttributionDataSource? diff --git a/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift b/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift index 1bbf5824fe0c..7338db557f41 100644 --- a/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift +++ b/Sources/MapboxMaps/Ornaments/OrnamentsManager.swift @@ -20,6 +20,7 @@ internal struct Ornaments { static let telemetryURL = "https://www.mapbox.com/telemetry/" } +@available(iOSApplicationExtension, unavailable) public class OrnamentsManager: NSObject { /// The `OrnamentOptions` object that is used to set up and update the required ornaments on the map. diff --git a/Sources/MapboxMaps/Style/AttributionDialogManager.swift b/Sources/MapboxMaps/Style/AttributionDialogManager.swift index d6b4652d3cdb..1f72efe88739 100644 --- a/Sources/MapboxMaps/Style/AttributionDialogManager.swift +++ b/Sources/MapboxMaps/Style/AttributionDialogManager.swift @@ -1,28 +1,16 @@ -// WIP @_implementationOnly import MapboxCommon_Private internal protocol AttributionDataSource: AnyObject { func attributions() -> [Attribution] } +@available(iOSApplicationExtension, unavailable) internal protocol AttributionDialogManagerDelegate: AnyObject { func attributionDialogManager(_ attributionDialogManager: AttributionDialogManager, viewControllerForPresentingFromView view: UIView) -> UIViewController func triggerAction(for attribution: Attribution) } -internal extension UIView { - var parentViewController: UIViewController? { - var parentResponder: UIResponder? = self - while parentResponder != nil { - parentResponder = parentResponder?.next - if let viewController = parentResponder as? UIViewController { - return viewController - } - } - return nil - } -} - +@available(iOSApplicationExtension, unavailable) internal class AttributionDialogManager { init() { delegate = self @@ -173,6 +161,7 @@ internal class AttributionDialogManager { } } +@available(iOSApplicationExtension, unavailable) extension AttributionDialogManager: AttributionDialogManagerDelegate { func triggerAction(for attribution: Attribution) { diff --git a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-100.imageset/Contents.json b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-100.imageset/Contents.json index eb9b7e162576..db2cc17687f7 100644 --- a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-100.imageset/Contents.json +++ b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-100.imageset/Contents.json @@ -1,17 +1,8 @@ { "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, { "filename" : "testSnapshotAttribution-100_1_232D6148-268F-4BCC-B87A-A78007EF9688.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" + "idiom" : "universal" } ], "info" : { diff --git a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-150.imageset/Contents.json b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-150.imageset/Contents.json index 516b30d46cb1..4f2e68333f71 100644 --- a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-150.imageset/Contents.json +++ b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-150.imageset/Contents.json @@ -1,17 +1,8 @@ { "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, { "filename" : "testSnapshotAttribution-150_1_E8430267-DD22-4AA8-9727-BD94B2F99DF6.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" + "idiom" : "universal" } ], "info" : { diff --git a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-200.imageset/Contents.json b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-200.imageset/Contents.json index 494cea5addca..2b93296207bd 100644 --- a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-200.imageset/Contents.json +++ b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-200.imageset/Contents.json @@ -1,17 +1,8 @@ { "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, { "filename" : "testSnapshotAttribution-200_1_11E08884-1F2F-4150-A662-909115267E7D.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" + "idiom" : "universal" } ], "info" : { diff --git a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-250.imageset/Contents.json b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-250.imageset/Contents.json index 1431be947e52..3e3de2cf94ae 100644 --- a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-250.imageset/Contents.json +++ b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-250.imageset/Contents.json @@ -1,17 +1,8 @@ { "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, { "filename" : "testSnapshotAttribution-250_1_8468A877-E93E-4EEE-BD0B-5D858260AF05.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" + "idiom" : "universal" } ], "info" : { diff --git a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-300.imageset/Contents.json b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-300.imageset/Contents.json index 6251655c226d..883fe6f60c5c 100644 --- a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-300.imageset/Contents.json +++ b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-300.imageset/Contents.json @@ -1,17 +1,8 @@ { "images" : [ - { - "idiom" : "universal", - "scale" : "1x" - }, { "filename" : "testSnapshotAttribution-300_1_BD9DE994-7E29-433D-895A-6A0A92C85D9A.png", - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" + "idiom" : "universal" } ], "info" : { diff --git a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-50.imageset/Contents.json b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-50.imageset/Contents.json index a276c298c7f9..8c59d2950552 100644 --- a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-50.imageset/Contents.json +++ b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotAttribution-50.imageset/Contents.json @@ -2,16 +2,7 @@ "images" : [ { "filename" : "testSnapshotAttribution-50_1_CD1F7DDD-002E-42F6-A6EF-6BFE78A46E06.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" + "idiom" : "universal" } ], "info" : { diff --git a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotLogoVisibility.imageset/Contents.json b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotLogoVisibility.imageset/Contents.json index 6aeba0c7f2cf..ccca13ae3c88 100644 --- a/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotLogoVisibility.imageset/Contents.json +++ b/Tests/MapboxMapsTests/Snapshot/Snapshot.xcassets/testSnapshotLogoVisibility.imageset/Contents.json @@ -2,16 +2,7 @@ "images" : [ { "filename" : "testSnapshotLogoVisibility.png", - "idiom" : "universal", - "scale" : "1x" - }, - { - "idiom" : "universal", - "scale" : "2x" - }, - { - "idiom" : "universal", - "scale" : "3x" + "idiom" : "universal" } ], "info" : {