Skip to content

Commit 3a7360c

Browse files
Provide alternate IDs in legacy pin creator (#50)
1 parent de12418 commit 3a7360c

File tree

7 files changed

+14
-10
lines changed

7 files changed

+14
-10
lines changed

MCMaps/Legacy/View Models/CartographyRoute.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ enum CartographyRoute: Equatable, Hashable, Identifiable {
2424
case recent(CGPoint)
2525

2626
/// The player is requesting to create a pin from a location.
27-
case createPin(CGPoint)
27+
case createPin(CGPoint, Set<String>?)
2828

2929
/// The player is requesting to make changes to the world.
3030
case editWorld

MCMaps/Legacy/Views/ContentViewToolbar.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ struct ContentViewToolbar: ToolbarContent {
5353
}
5454
ToolbarItem {
5555
Button {
56-
viewModel.currentRoute = .createPin(.zero)
56+
viewModel.currentRoute = .createPin(.zero, nil)
5757
} label: {
5858
Label("Create Pin", image: "mappin.circle.badge.plus")
5959
}

MCMaps/Legacy/Views/LegacyContentView.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ struct LegacyContentView: View {
5555
.sheet(isPresented: viewModel.displayCurrentRouteModally) {
5656
Group {
5757
switch viewModel.currentRoute {
58-
case .createPin(let cgPoint):
58+
case .createPin(let cgPoint, let alternateIDs):
5959
NavigationStack {
6060
PinCreatorForm(location: cgPoint) { pin in
61-
file.pins.append(pin)
61+
var transformedPin = pin
62+
transformedPin.alternateIDs = alternateIDs
63+
file.pins.append(transformedPin)
6264
}
6365
.formStyle(.grouped)
6466
}

MCMaps/Legacy/Views/Sidebar/CartographyMapSidebarSheet.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ struct CartographyMapSidebarSheet<T: ToolbarContent>: View {
7272
.task {
7373
viewModel.go(to: pin.position, relativeTo: file)
7474
}
75-
case let .createPin(location):
75+
case let .createPin(location, alternateIDs):
7676
PinCreatorForm(location: location) { newPin in
77-
file.pins.append(newPin)
77+
var transformedPin = newPin
78+
transformedPin.alternateIDs = alternateIDs
79+
file.pins.append(transformedPin)
7880
}
7981
case .editWorld:
8082
MapCreatorForm(

MCMaps/Legacy/Views/Sidebar/GroupedPinsSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct GroupedPinsSection: View {
5757
Label("Go Here", systemImage: "location")
5858
}
5959
Button {
60-
viewModel.currentRoute = .createPin(pin.position)
60+
viewModel.currentRoute = .createPin(pin.position, pin.alternateIDs)
6161
} label: {
6262
Label("Pin...", systemImage: "mappin")
6363
}

MCMaps/Legacy/Views/Sidebar/RecentLocationsListSection.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ struct RecentLocationsListSection: View {
8686
}
8787
#else
8888
Button {
89-
viewModel.currentRoute = .createPin(position)
89+
viewModel.currentRoute = .createPin(position, nil)
9090
} label: {
9191
Label("Pin...", systemImage: "mappin")
9292
}

MCMapsTests/View Models/CartographyRouteTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ struct CartographyRouteTests {
1818
@Test func requiresModalDisplay() async throws {
1919
let routes = [
2020
CartographyRoute.editWorld,
21-
CartographyRoute.createPin(.zero),
21+
CartographyRoute.createPin(.zero, nil),
2222

2323
CartographyRoute.pin(0, pin: CartographyMapPin(named: "Spawn", at: .zero)),
2424
CartographyRoute.recent(.init(x: 1, y: 1)),
@@ -37,7 +37,7 @@ struct CartographyRouteTests {
3737
@Test func requiresInspectorDisplay() async throws {
3838
let routes = [
3939
CartographyRoute.editWorld,
40-
CartographyRoute.createPin(.zero),
40+
CartographyRoute.createPin(.zero, nil),
4141
CartographyRoute.pin(0, pin: CartographyMapPin(named: "Spawn", at: .zero)),
4242
CartographyRoute.recent(.init(x: 1, y: 1)),
4343
]

0 commit comments

Comments
 (0)