Skip to content

Commit 51886b0

Browse files
authored
Refactor the MapTiler configuration into a single place. (#3944)
* Refactor the MapTiler configuration into a single place. * Merge the MapAssets catalog into the normal one.
1 parent e0edafc commit 51886b0

31 files changed

+190
-220
lines changed

ElementX.xcodeproj/project.pbxproj

Lines changed: 12 additions & 36 deletions
Large diffs are not rendered by default.

ElementX/Sources/Application/AppSettings.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ final class AppSettings {
9797
copyrightURL: URL,
9898
acceptableUseURL: URL,
9999
privacyURL: URL,
100-
supportEmailAddress: String) {
100+
supportEmailAddress: String,
101+
mapTilerConfiguration: MapTilerConfiguration) {
101102
self.defaultHomeserverAddress = defaultHomeserverAddress
102103
self.oidcRedirectURL = oidcRedirectURL
103104
self.websiteURL = websiteURL
@@ -106,6 +107,7 @@ final class AppSettings {
106107
self.acceptableUseURL = acceptableUseURL
107108
self.privacyURL = privacyURL
108109
self.supportEmailAddress = supportEmailAddress
110+
self.mapTilerConfiguration = mapTilerConfiguration
109111
}
110112

111113
// MARK: - Application
@@ -290,10 +292,10 @@ final class AppSettings {
290292
// MARK: - Maps
291293

292294
// maptiler base url
293-
let mapTilerBaseURL: URL = "https://api.maptiler.com/maps"
294-
295-
// maptiler api key
296-
let mapTilerApiKey = Secrets.mapLibreAPIKey
295+
private(set) var mapTilerConfiguration = MapTilerConfiguration(baseURL: "https://api.maptiler.com/maps",
296+
apiKey: Secrets.mapLibreAPIKey,
297+
lightStyleID: "9bc819c8-e627-474a-a348-ec144fe3d810",
298+
darkStyleID: "dea61faf-292b-4774-9660-58fcef89a7f3")
297299

298300
// MARK: - Presence
299301

ElementX/Sources/FlowCoordinators/PinnedEventsTimelineFlowCoordinator.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
2121
private let timelineControllerFactory: TimelineControllerFactoryProtocol
2222
private let roomProxy: JoinedRoomProxyProtocol
2323
private let userIndicatorController: UserIndicatorControllerProtocol
24+
private let appSettings: AppSettings
2425
private let appMediator: AppMediatorProtocol
2526
private let emojiProvider: EmojiProviderProtocol
2627

@@ -36,13 +37,15 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
3637
timelineControllerFactory: TimelineControllerFactoryProtocol,
3738
roomProxy: JoinedRoomProxyProtocol,
3839
userIndicatorController: UserIndicatorControllerProtocol,
40+
appSettings: AppSettings,
3941
appMediator: AppMediatorProtocol,
4042
emojiProvider: EmojiProviderProtocol) {
4143
self.navigationStackCoordinator = navigationStackCoordinator
4244
self.userSession = userSession
4345
self.timelineControllerFactory = timelineControllerFactory
4446
self.roomProxy = roomProxy
4547
self.userIndicatorController = userIndicatorController
48+
self.appSettings = appSettings
4649
self.appMediator = appMediator
4750
self.emojiProvider = emojiProvider
4851
}
@@ -106,7 +109,9 @@ class PinnedEventsTimelineFlowCoordinator: FlowCoordinatorProtocol {
106109
private func presentMapNavigator(geoURI: GeoURI, description: String?) {
107110
let stackCoordinator = NavigationStackCoordinator()
108111

109-
let params = StaticLocationScreenCoordinatorParameters(interactionMode: .viewOnly(geoURI: geoURI, description: description), appMediator: appMediator)
112+
let params = StaticLocationScreenCoordinatorParameters(interactionMode: .viewOnly(geoURI: geoURI, description: description),
113+
mapURLBuilder: appSettings.mapTilerConfiguration,
114+
appMediator: appMediator)
110115
let coordinator = StaticLocationScreenCoordinator(parameters: params)
111116

112117
coordinator.actions.sink { [weak self] action in

ElementX/Sources/FlowCoordinators/RoomFlowCoordinator.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,9 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
10761076
private func presentMapNavigator(interactionMode: StaticLocationInteractionMode) {
10771077
let stackCoordinator = NavigationStackCoordinator()
10781078

1079-
let params = StaticLocationScreenCoordinatorParameters(interactionMode: interactionMode, appMediator: appMediator)
1079+
let params = StaticLocationScreenCoordinatorParameters(interactionMode: interactionMode,
1080+
mapURLBuilder: appSettings.mapTilerConfiguration,
1081+
appMediator: appMediator)
10801082
let coordinator = StaticLocationScreenCoordinator(parameters: params)
10811083

10821084
coordinator.actions.sink { [weak self] action in
@@ -1563,6 +1565,7 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
15631565
timelineControllerFactory: timelineControllerFactory,
15641566
roomProxy: roomProxy,
15651567
userIndicatorController: userIndicatorController,
1568+
appSettings: appSettings,
15661569
appMediator: appMediator,
15671570
emojiProvider: emojiProvider)
15681571

ElementX/Sources/Generated/Assets.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ internal enum Asset {
3737
internal static let stopRecording = ImageAsset(name: "images/stop-recording")
3838
internal static let launchBackground = ImageAsset(name: "images/launch-background")
3939
internal static let locationMarkerShape = ImageAsset(name: "images/location-marker-shape")
40+
internal static let mapBlurred = ImageAsset(name: "images/mapBlurred")
4041
internal static let mediaPause = ImageAsset(name: "images/media-pause")
4142
internal static let mediaPlay = ImageAsset(name: "images/media-play")
4243
internal static let notificationsPromptGraphic = ImageAsset(name: "images/notifications-prompt-graphic")

ElementX/Sources/Other/Extensions/MapTiler.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

ElementX/Sources/Other/MapLibre/MapAssets.xcassets/Contents.json

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)