Skip to content

Commit

Permalink
Added delete alert to theme details sheet.
Browse files Browse the repository at this point in the history
  • Loading branch information
austincondiff committed Oct 26, 2024
1 parent 7fccb9b commit 25c0107
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ struct ThemeSettingsThemeDetails: View {

@State private var duplicatingTheme: Theme?

@State private var deleteConfirmationIsPresented = false

var isActive: Bool {
themeModel.getThemeActive(theme)
}
Expand Down Expand Up @@ -174,10 +176,9 @@ struct ThemeSettingsThemeDetails: View {
.accessibilityLabel("Warning: Duplicate this theme to make changes.")
} else if !themeModel.isAdding {
Button(role: .destructive) {
themeModel.delete(theme)
dismiss()
deleteConfirmationIsPresented = true
} label: {
Text("Delete")
Text("Delete...")
.foregroundStyle(.red)
.frame(minWidth: 56)
}
Expand All @@ -187,7 +188,7 @@ struct ThemeSettingsThemeDetails: View {
themeModel.duplicate(fileURL)
}
} label: {
Text("Duplicate")
Text("Duplicate...")
.frame(minWidth: 56)
}
}
Expand Down Expand Up @@ -247,5 +248,19 @@ struct ThemeSettingsThemeDetails: View {
.padding()
}
.constrainHeightToWindow()
.alert(
Text("Are you sure you want to delete the theme “\(theme.displayName)”?"),
isPresented: $deleteConfirmationIsPresented
) {
Button("Delete Theme") {
themeModel.delete(theme)
dismiss()
}
Button("Cancel") {
deleteConfirmationIsPresented = false
}
} message: {
Text("This action cannot be undone.")
}
}
}

0 comments on commit 25c0107

Please sign in to comment.