Skip to content

Commit 30ac3e2

Browse files
Allow moving between images in detail, gallery
Co-authored-by: Morris Richman <mcrich23@icloud.com>
1 parent 8b83dde commit 30ac3e2

File tree

4 files changed

+20
-9
lines changed

4 files changed

+20
-9
lines changed

MCMaps/Red Window/Views/Detail/Cells/RedWindowPinGalleryCell.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ struct RedWindowPinGalleryCell: RedWindowDetailCell {
2727

2828
@State private var imageToPreview: URL?
2929

30+
private var imageURLs: [URL] {
31+
pin.images?.compactMap { filename in
32+
getUrl(forImageNamed: filename)
33+
} ?? []
34+
}
35+
3036
var body: some View {
3137
Group {
3238
Text("Gallery")
@@ -57,7 +63,7 @@ struct RedWindowPinGalleryCell: RedWindowDetailCell {
5763
ContentUnavailableView("No Photos Uploaded", systemImage: "photo.stack")
5864
}
5965
}
60-
.quickLookPreview($imageToPreview)
66+
.quickLookPreview($imageToPreview, in: imageURLs)
6167
}
6268

6369
private func getImage(named name: String) -> Data? {

MCMaps/Resources/Credits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ Alidade was made possible thanks to the following open-source projects:
2525
- femialiu
2626
- Jon Reid
2727
- Joe Graf (joeisanerd)
28-
28+
- Morris Richman
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"Credits" = "Credits";
2-
"credit_text"="Alidade is free and open-source software licensed under the Mozilla Public License, v2.0. For more information on your rights, you can visit https://www.mozilla.org/en-US/MPL/2.0/.\n\nOPEN SOURCE LIBRARIES\nAlidade was made possible thanks to the following open-source projects:\n\n- Adaptable Sidebar Sheet: Mozilla Public License, v2 (https://github.com/AlidadeMC/adaptablesidebarsheetview)\n- Caching MapKit Tile Overlay: BSD 3-Clause License (https://github.com/stadiamaps/mapkit-caching-tile-overlay)\n- Cubiomes: MIT License (https://github.com/Cubitect/cubiomes)\n- CubiomesKit: Mozilla Public License, v2 (https://github.com/AlidadeMC/cubiomeskit)\n- VersionedCodable: MIT License (https://github.com/jrothwell/VersionedCodable)\n\n\nSPECIAL THANKS\n- Christine Kearney-Kurt\n- Michael Kurt\n- Jo Kurt\n- Em Belkowitz\n- Paul Straw\n- Zack Snyder (The3DPrintist)\n- rae\n- Zel\n- Kiwi\n- 2DArray\n- Grant Neufeld\n- femialiu\n- Jon Reid\n- Joe Graf (joeisanerd)\n";
2+
"credit_text"="Alidade is free and open-source software licensed under the Mozilla Public License, v2.0. For more information on your rights, you can visit https://www.mozilla.org/en-US/MPL/2.0/.\n\nOPEN SOURCE LIBRARIES\nAlidade was made possible thanks to the following open-source projects:\n\n- Adaptable Sidebar Sheet: Mozilla Public License, v2 (https://github.com/AlidadeMC/adaptablesidebarsheetview)\n- Caching MapKit Tile Overlay: BSD 3-Clause License (https://github.com/stadiamaps/mapkit-caching-tile-overlay)\n- Cubiomes: MIT License (https://github.com/Cubitect/cubiomes)\n- CubiomesKit: Mozilla Public License, v2 (https://github.com/AlidadeMC/cubiomeskit)\n- VersionedCodable: MIT License (https://github.com/jrothwell/VersionedCodable)\n\n\nSPECIAL THANKS\n- Christine Kearney-Kurt\n- Michael Kurt\n- Jo Kurt\n- Em Belkowitz\n- Paul Straw\n- Zack Snyder (The3DPrintist)\n- rae\n- Zel\n- Kiwi\n- 2DArray\n- Grant Neufeld\n- femialiu\n- Jon Reid\n- Joe Graf (joeisanerd)\n- Morris Richman";

MCMaps/Shared/Views/Gallery/CartographyGalleryView.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ struct CartographyGalleryView: View {
2929
@State private var scaledToFill = true
3030
@State private var currentPhotoURL: URL?
3131

32+
private var imageURLs: [URL] {
33+
context.imageCollection.compactMap { (key, _) in
34+
getURL(forImageNamed: key)
35+
}
36+
}
37+
3238
var body: some View {
3339
Group {
3440
if context.imageCollection.isEmpty {
@@ -40,15 +46,15 @@ struct CartographyGalleryView: View {
4046
LazyVGrid(columns: columns, spacing: 2) {
4147
ForEach(RandomAccessDictionary(context.imageCollection)) { element in
4248
Button {
43-
prepareQuickLook(forImageNamed: element.key)
49+
currentPhotoURL = getURL(forImageNamed: element.key)
4450
} label: {
4551
cell(for: element.value)
4652
.frame(maxWidth: .infinity, maxHeight: .infinity)
4753
}
4854
.buttonStyle(.plain)
4955
.contextMenu {
5056
Button("Preview Image") {
51-
prepareQuickLook(forImageNamed: element.key)
57+
currentPhotoURL = getURL(forImageNamed: element.key)
5258
}
5359
ShareLink(
5460
item: element.value,
@@ -66,7 +72,7 @@ struct CartographyGalleryView: View {
6672
}
6773
}
6874
}
69-
.quickLookPreview($currentPhotoURL)
75+
.quickLookPreview($currentPhotoURL, in: imageURLs)
7076
.navigationTitle("Gallery")
7177
#if os(macOS)
7278
.navigationSubtitle(context.documentBaseURL?.lastPathComponent ?? "Untitled Map")
@@ -96,8 +102,7 @@ struct CartographyGalleryView: View {
96102
.aspectRatio(1, contentMode: .fit)
97103
}
98104

99-
private func prepareQuickLook(forImageNamed imageName: String) {
100-
guard let baseURL = context.documentBaseURL else { return }
101-
currentPhotoURL = baseURL.appending(components: CartographyMapFile.Keys.images, imageName)
105+
private func getURL(forImageNamed name: String) -> URL? {
106+
context.documentBaseURL?.appending(components: CartographyMapFile.Keys.images, name)
102107
}
103108
}

0 commit comments

Comments
 (0)