Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 0 additions & 19 deletions ios/RNMBX/CustomHttpHeaders.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ struct CustomHttpHeadersMapValue {
}

class CustomHttpHeaders : HttpServiceInterceptorInterface {
#if RNMBX_11
func onRequest(for request: HttpRequest, continuation: @escaping HttpServiceInterceptorRequestContinuation) {
let request = onRequest(for: request)
continuation(HttpRequestOrResponse.fromHttpRequest(request))
Expand All @@ -19,7 +18,6 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
func onResponse(for response: HttpResponse, continuation: @escaping HttpServiceInterceptorResponseContinuation) {
continuation(response)
}
#endif

static var shared : CustomHttpHeaders = {
let headers = CustomHttpHeaders()
Expand All @@ -30,20 +28,11 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
var customHeaders : [String:CustomHttpHeadersMapValue] = [:]

func install() {
#if RNMBX_11
HttpServiceFactory.setHttpServiceInterceptorForInterceptor(self)
#else
HttpServiceFactory.getInstance().setInterceptorForInterceptor(self)
#endif
}

func reset() {
#if RNMBX_11
HttpServiceFactory.setHttpServiceInterceptorForInterceptor(nil)
#else
HttpServiceFactory.getInstance().setInterceptorForInterceptor(nil)

#endif
}

// MARK: - HttpServiceInterceptorInterface
Expand Down Expand Up @@ -76,14 +65,6 @@ class CustomHttpHeaders : HttpServiceInterceptorInterface {
return request
}

#if !RNMBX_11
func onDownload(forDownload download: DownloadOptions) -> DownloadOptions {
let customHeaders = getCustomRequestHeaders(for: download.request, with: customHeaders)
download.request.headers.merge(customHeaders) { (_, new) in new }
return download
}
#endif

func onResponse(for response: HttpResponse) -> HttpResponse {
return response
}
Expand Down
29 changes: 1 addition & 28 deletions ios/RNMBX/Offline/RNMBXOfflineModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,11 @@ class RNMBXOfflineModule: RCTEventEmitter {
}

lazy var offlineManager : OfflineManager = {
#if RNMBX_11
return OfflineManager()
#else
return OfflineManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!))
#endif
}()

lazy var offlineRegionManager: OfflineRegionManager = {
#if RNMBX_11
return OfflineRegionManager()
#else
return OfflineRegionManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!))
#endif
}()

lazy var tileStore : TileStore = {
Expand Down Expand Up @@ -363,7 +355,6 @@ class RNMBXOfflineModule: RCTEventEmitter {

let stylePackLoadOptions = StylePackLoadOptions(glyphsRasterizationMode: .ideographsRasterizedLocally, metadata: pack.metadata)!

#if RNMBX_11
let threadedOfflineManager = OfflineManager()
taskGroup.enter()
let stylePackTask = threadedOfflineManager.loadStylePack(for: styleURI, loadOptions: stylePackLoadOptions) { progress in
Expand Down Expand Up @@ -391,20 +382,6 @@ class RNMBXOfflineModule: RCTEventEmitter {
)
let tilesetDescriptor = threadedOfflineManager.createTilesetDescriptor(for: descriptorOptions)
let descriptors = [tilesetDescriptor]
#else
let descriptorOptions = TilesetDescriptorOptions(
styleURI: styleURI,
zoomRange: zoomRange,
stylePackOptions: stylePackLoadOptions
)
let descriptor = self.offlineManager.createTilesetDescriptor(for: descriptorOptions)
let tilesetDescriptorOptions = TilesetDescriptorOptionsForTilesets(tilesets: pack.tilesets, zoomRange: zoomRange)
let tilesetDescriptor = self.offlineManager.createTilesetDescriptorForTilesetDescriptorOptions(tilesetDescriptorOptions)
var descriptors = [descriptor]
if (!pack.tilesets.isEmpty) {
descriptors.append(tilesetDescriptor)
}
#endif

let loadOptions = TileRegionLoadOptions(
geometry: bounds, // RNMBXFeatureUtils.geometryToGeometry(bounds),
Expand Down Expand Up @@ -452,11 +429,7 @@ class RNMBXOfflineModule: RCTEventEmitter {
self.tileRegionPacks[id]!.state = downloadError ? .inactive : .complete
}

#if RNMBX_11
self.tileRegionPacks[id]!.cancelables = [task, stylePackTask]
#else
self.tileRegionPacks[id]!.cancelables = [task]
#endif
}

func convertRegionsToJSON(regions: [TileRegion], resolve: @escaping RCTPromiseResolveBlock, rejecter: @escaping RCTPromiseRejectBlock) {
Expand Down
4 changes: 0 additions & 4 deletions ios/RNMBX/Offline/RNMBXOfflineModuleLegacy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ class RNMBXOfflineModuleLegacy: RCTEventEmitter {
final let CompleteRegionDownloadState = 2

lazy var offlineRegionManager: OfflineRegionManager = {
#if RNMBX_11
return OfflineRegionManager()
#else
return OfflineRegionManager(resourceOptions: .init(accessToken: RNMBXModule.accessToken!))
#endif
}()

@objc
Expand Down
2 changes: 0 additions & 2 deletions ios/RNMBX/RNMBXAtmosphere.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import MapboxMaps

#if RNMBX_11
public typealias Style = StyleManager
#endif

@objc(RNMBXAtmosphere)
public class RNMBXAtmosphere : RNMBXSingletonLayer, RNMBXMapComponent, RNMBXSourceConsumer {
Expand Down
4 changes: 0 additions & 4 deletions ios/RNMBX/RNMBXBackgroundLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ public class RNMBXBackgroundLayer: RNMBXLayer {

override func makeLayer(style: Style) throws -> Layer {
var layer = LayerType(id: self.id!)
#if !RNMBX_11
layer.sourceLayer = self.sourceLayerID
layer.source = sourceID
#endif
return layer
}

Expand Down
9 changes: 0 additions & 9 deletions ios/RNMBX/RNMBXCamera.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import Foundation
import MapboxMaps
import Turf

#if RNMBX_11
extension NSNumber {
/// Converts an `NSNumber` to a `CGFloat` value from its `Double` representation.
internal var CGFloat: CGFloat {
CoreGraphics.CGFloat(doubleValue)
}
}
#endif

public enum RemovalReason {
case ViewRemoval, StyleChange, OnDestroy, ComponentChange, Reorder
Expand Down Expand Up @@ -368,9 +366,6 @@ open class RNMBXCamera : RNMBXMapAndMapViewComponentBase {
if let locationModule = RNMBXLocationModule.shared {
locationModule.override(for: map.location)
}
#if !RNMBX_11
map.location.locationProvider.requestWhenInUseAuthorization()
#endif
var trackingModeChanged = false
var followOptions = FollowPuckViewportStateOptions()
switch userTrackingMode {
Expand Down Expand Up @@ -518,11 +513,7 @@ open class RNMBXCamera : RNMBXMapAndMapViewComponentBase {
}

withMapView { map in
#if RNMBX_11
let bounds = [sw, ne]
#else
let bounds = CoordinateBounds(southwest: sw, northeast: ne)
#endif

camera = map.mapboxMap.camera(
for: bounds,
Expand Down
8 changes: 0 additions & 8 deletions ios/RNMBX/RNMBXCameraGestureObserver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe
private var timeoutTimer: DispatchSourceTimer? = nil
private var emittedForCurrentActivity: Bool = false

#if RNMBX_11
private var _cancelables = Set<AnyCancelable>()
#endif

private var quietMs: Double { (quietPeriodMs?.doubleValue) ?? 200.0 }
private var maxMs: Double? { maxIntervalMs?.doubleValue }
Expand All @@ -43,9 +41,7 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe
switch gestureType {
case .pan: return "pan"
case .pinch: return "pinch"
#if RNMBX_11
case .rotation: return "rotate"
#endif
case .pitch: return "pitch"
default: return "\(gestureType)"
}
Expand Down Expand Up @@ -145,7 +141,6 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe

guard hasOnMapSteady else { return }

#if RNMBX_11
let camera = map.mapView.camera!

// Camera animator lifecycle
Expand Down Expand Up @@ -175,14 +170,11 @@ public class RNMBXCameraGestureObserver: RNMBXMapComponentBase, GestureManagerDe
// Subscribe to gestures as a secondary observer (multicast from RNMBXMapView)
map.addGestureDelegate(self)
debugLog("addToMap and subscribed to gestures")
#endif
}

public override func removeFromMap(_ map: RNMBXMapView, reason: RemovalReason) -> Bool {
#if RNMBX_11
_cancelables.forEach { $0.cancel() }
_cancelables.removeAll()
#endif
map.removeGestureDelegate(self)
debugLog("removeFromMap and unsubscribed from gestures")
cancelQuietTimer()
Expand Down
6 changes: 0 additions & 6 deletions ios/RNMBX/RNMBXCircleLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ public class RNMBXCircleLayer: RNMBXVectorLayer {

override func makeLayer(style: Style) throws -> Layer {
let _ : VectorSource = try self.layerWithSourceID(in: style)
#if RNMBX_11
var layer = LayerType(id: self.id!, source: self.sourceID!)
#else
var layer = LayerType(id: self.id!)
#endif
layer.sourceLayer = self.sourceLayerID
layer.source = sourceID
return layer
Expand All @@ -26,7 +22,6 @@ public class RNMBXCircleLayer: RNMBXVectorLayer {
func setCommonOptions(_ layer: inout CircleLayer) -> Bool {
var changed = false

#if RNMBX_11
if let sourceLayerID = sourceLayerID {
layer.sourceLayer = sourceLayerID
changed = true
Expand All @@ -49,7 +44,6 @@ public class RNMBXCircleLayer: RNMBXVectorLayer {
Logger.log(level: .error, message: "parsing filters failed for layer \(optional: id): \(error.localizedDescription)")
}
}
#endif

return changed
}
Expand Down
Loading
Loading