Show titles and set destructive on confirmation

Fixes #683
This commit is contained in:
Davide 2024-10-30 14:53:35 +01:00
parent d12590387a
commit 9e7860d390
5 changed files with 24 additions and 8 deletions

View File

@ -510,8 +510,10 @@ public enum Strings {
}
public enum Theme {
public enum Confirmation {
/// Are you sure?
public static let message = Strings.tr("Localizable", "theme.confirmation.message", fallback: "Are you sure?")
/// Are you sure you want to proceed with this operation?
public static let message = Strings.tr("Localizable", "theme.confirmation.message", fallback: "Are you sure you want to proceed with this operation?")
/// Confirm
public static let ok = Strings.tr("Localizable", "theme.confirmation.ok", fallback: "Confirm")
}
}
public enum Ui {

View File

@ -114,7 +114,8 @@
// MARK: - Theme
"theme.confirmation.message" = "Are you sure?";
"theme.confirmation.ok" = "Confirm";
"theme.confirmation.message" = "Are you sure you want to proceed with this operation?";
// MARK: - Views

View File

@ -148,12 +148,14 @@ struct ThemeConfirmationModifier: ViewModifier {
let title: String
let isDestructive: Bool
let action: () -> Void
func body(content: Content) -> some View {
content
.confirmationDialog(title, isPresented: $isPresented) {
Button(Strings.Global.ok, action: action)
.confirmationDialog(title, isPresented: $isPresented, titleVisibility: .visible) {
Button(Strings.Theme.Confirmation.ok, role: isDestructive ? .destructive : nil, action: action)
Text(Strings.Global.cancel)
} message: {
Text(Strings.Theme.Confirmation.message)

View File

@ -137,8 +137,18 @@ extension View {
))
}
public func themeConfirmation(isPresented: Binding<Bool>, title: String, action: @escaping () -> Void) -> some View {
modifier(ThemeConfirmationModifier(isPresented: isPresented, title: title, action: action))
public func themeConfirmation(
isPresented: Binding<Bool>,
title: String,
isDestructive: Bool = false,
action: @escaping () -> Void
) -> some View {
modifier(ThemeConfirmationModifier(
isPresented: isPresented,
title: title,
isDestructive: isDestructive,
action: action
))
}
public func themeNavigationStack(if condition: Bool, closable: Bool = false, path: Binding<NavigationPath>) -> some View {

View File

@ -80,7 +80,8 @@ private extension SettingsSectionGroup {
}
.themeConfirmation(
isPresented: $isConfirmingEraseiCloud,
title: Strings.Views.Settings.Rows.eraseIcloud
title: Strings.Views.Settings.Rows.eraseIcloud,
isDestructive: true
) {
isErasingiCloud = true
Task {