Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Offline: Disallow deletion in metadata view when map is selected #872

Merged
merged 2 commits into from
Sep 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct PreplannedListItemView: View {
}
.sheet(isPresented: $metadataViewIsPresented) {
NavigationStack {
PreplannedMetadataView(model: model)
PreplannedMetadataView(model: model, isSelected: isSelected)
}
}
.task {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ struct PreplannedMetadataView: View {
/// The action to dismiss the view.
@Environment(\.dismiss) private var dismiss

/// A Boolean value indicating whether the current map area is selected.
let isSelected: Bool

var body: some View {
Form {
Section {
Expand Down Expand Up @@ -62,15 +65,17 @@ struct PreplannedMetadataView: View {
.font(.subheadline)
}
}
Section {
HStack {
Image(systemName: "trash.circle.fill")
.symbolRenderingMode(.palette)
.foregroundStyle(.red, .gray.opacity(0.1))
.font(.title)
Button("Delete Map Area", role: .destructive) {
dismiss()
model.removeDownloadedPreplannedMapArea()
if !isSelected {
Section {
HStack {
Image(systemName: "trash.circle.fill")
.symbolRenderingMode(.palette)
.foregroundStyle(.red, .gray.opacity(0.1))
.font(.title)
Button("Delete Map Area", role: .destructive) {
dismiss()
model.removeDownloadedPreplannedMapArea()
}
}
}
}
Expand Down Expand Up @@ -104,6 +109,7 @@ struct PreplannedMetadataView: View {
mapArea: MockPreplannedMapArea(),
portalItemID: .init("preview")!,
preplannedMapAreaID: .init("preview")!
)
),
isSelected: false
)
}