Move MapLibre into the Components folder

Continue grouping the standalone modules under Components. The MapLibre
frameworks were nested inside the app folder even though they are separate
targets, so move them alongside the other components and update the
XcodeGen includes.
This commit is contained in:
Stefan Ceriu
2026-08-12 15:03:47 +03:00
parent f73285db3e
commit d595e4fd83
11 changed files with 70 additions and 70 deletions
@@ -0,0 +1,19 @@
//
// Copyright 2026 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import SwiftUI
/// Implemented by MapLibreShim's entry point, which the app instantiates after
/// `dlopen`-ing the framework.
public protocol MapLibreShimProtocol {
/// Routes MapLibre's logs into the app's logger. Call once after loading the shim.
func configureLogging(_ handler: @escaping @Sendable (MapLogSeverity, String) -> Void)
/// Builds the interactive map view. The app-side `MapLibreMapView` forwards every
/// body evaluation here so SwiftUI updates flow through to the underlying map.
func makeMapView(configuration: MapViewConfiguration) -> AnyView
}
@@ -0,0 +1,56 @@
//
// Copyright 2026 Element Creations Ltd.
// Copyright 2023-2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import CoreLocation
import Foundation
/**
Behavior mode of the current user's location, can be hidden, only shown and shown following the user
*/
public enum ShowUserLocationMode: Equatable {
/// this mode will show the user pin in map
case show
/// this mode will show the user pin in map and track him, panning the map automatically
case showAndFollow
/// this mode will not show the user pin in map
case hide
/// this mode will not show the user pin in map and will follow the marker with the given id,
/// panning the map automatically.
case hideAndFollowMarker(id: String)
/// The id of the marker the map should follow when in the `hideAndFollowMarker` mode, nil otherwise.
public var followedMarkerID: String? {
guard case .hideAndFollowMarker(let id) = self else { return nil }
return id
}
}
public enum MapLibreError: Error, Hashable {
case failedLoadingMap
case failedLocatingUser
}
/// The severity of a map log message forwarded to the app.
public enum MapLogSeverity {
case error
case warning
case info
case debug
case verbose
}
/// A marker shown on the map, identified so that it can be moved in place when its coordinate changes.
public struct MapAnnotation {
public let id: String
public let coordinate: CLLocationCoordinate2D
public init(id: String, coordinate: CLLocationCoordinate2D) {
self.id = id
self.coordinate = coordinate
}
}
@@ -0,0 +1,76 @@
//
// Copyright 2026 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import CoreLocation
import SwiftUI
/// Everything the map implementation needs in order to render, expressed without app
/// types so that the implementation framework can be loaded on demand.
public struct MapViewConfiguration {
/// the final zoom level used when the first user location emit
public let zoomLevel: Double
/// The initial zoom level used when the map it firstly loaded and the user location is not yet available, in case of annotations this property is not being used
public let initialZoomLevel: Double
/// The initial map center
public let mapCenter: CLLocationCoordinate2D
/// Map annotations
public let annotations: [MapAnnotation]
/// The style to load the map with, for either the dark or the light appearance.
public let styleURL: (_ isDark: Bool) -> URL?
public let tintColor: UIColor
/// The content of the marker representing the annotation with the given id.
public let markerView: (_ annotationID: String) -> AnyView?
/// Behavior mode of the current user's location, can be hidden, only shown and shown following the user
public let showsUserLocationMode: Binding<ShowUserLocationMode>
/// Bind view errors if any
public let error: Binding<MapLibreError?>
/// Coordinate of the center of the map
public let mapCenterCoordinate: Binding<CLLocationCoordinate2D?>
public let hasLoadedUserLocation: Binding<Bool>
public let isLocationAuthorized: Binding<Bool?>
/// The radius of uncertainty for the location, measured in meters.
public let geolocationUncertainty: Binding<CLLocationAccuracy?>
/// Called when the user pan on the map
public let userDidPan: (() -> Void)?
public init(zoomLevel: Double,
initialZoomLevel: Double,
mapCenter: CLLocationCoordinate2D,
annotations: [MapAnnotation] = [],
styleURL: @escaping (_ isDark: Bool) -> URL?,
tintColor: UIColor,
markerView: @escaping (_ annotationID: String) -> AnyView?,
showsUserLocationMode: Binding<ShowUserLocationMode>,
error: Binding<MapLibreError?>,
mapCenterCoordinate: Binding<CLLocationCoordinate2D?>,
hasLoadedUserLocation: Binding<Bool>,
isLocationAuthorized: Binding<Bool?>,
geolocationUncertainty: Binding<CLLocationAccuracy?>,
userDidPan: (() -> Void)? = nil) {
self.zoomLevel = zoomLevel
self.initialZoomLevel = initialZoomLevel
self.mapCenter = mapCenter
self.annotations = annotations
self.styleURL = styleURL
self.tintColor = tintColor
self.markerView = markerView
self.showsUserLocationMode = showsUserLocationMode
self.error = error
self.mapCenterCoordinate = mapCenterCoordinate
self.hasLoadedUserLocation = hasLoadedUserLocation
self.isLocationAuthorized = isLocationAuthorized
self.geolocationUncertainty = geolocationUncertainty
self.userDidPan = userDidPan
}
}
@@ -0,0 +1,19 @@
# The types shared between the app and the MapLibreShim framework. The app links this
# (tiny, initialiser-free) framework instead of MapLibre, see MapLibreShim's target.yml.
name: MapLibreInterface
targets:
MapLibreInterface:
type: framework
platform: iOS
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: $(BASE_BUNDLE_IDENTIFIER).maplibre-interface
GENERATE_INFOPLIST_FILE: YES
SWIFT_VERSION: 6.2
SWIFT_APPROACHABLE_CONCURRENCY: YES
SWIFT_DEFAULT_ACTOR_ISOLATION: MainActor
sources:
- path: ../Sources