From d375b1f973198b2c60095170d97dcdfc2405cb8a Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Fri, 21 Feb 2025 23:22:42 +0900 Subject: [PATCH 1/2] fix: set cancel role to No button --- Sources/AlertPresentable/AlertController.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/AlertPresentable/AlertController.swift b/Sources/AlertPresentable/AlertController.swift index a86cbc7..a81702b 100644 --- a/Sources/AlertPresentable/AlertController.swift +++ b/Sources/AlertPresentable/AlertController.swift @@ -94,7 +94,7 @@ public class AlertController { /// On tap, close the alert. /// public static var no: Self { - .init(label: String(localized: String.LocalizationValue("no"), bundle: .module)) + .init(label: String(localized: String.LocalizationValue("no"), bundle: .module), role: .cancel) } /// @@ -103,7 +103,7 @@ public class AlertController { /// - parameter action: The custom action which is fired when the button was tapped just before close the alert. /// public static func no(action: @escaping () -> Void) -> Self { - .init(label: String(localized: String.LocalizationValue("no"), bundle: .module), action: action) + .init(label: String(localized: String.LocalizationValue("no"), bundle: .module), role: .cancel, action: action) } /// From 1954800b0b7ad749c2242b3fdf7d6010131e620d Mon Sep 17 00:00:00 2001 From: taka-2120 Date: Fri, 21 Feb 2025 23:23:04 +0900 Subject: [PATCH 2/2] fix: apply localized label --- Sources/AlertPresentable/View+Alert.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/AlertPresentable/View+Alert.swift b/Sources/AlertPresentable/View+Alert.swift index 3c6f922..cf21454 100644 --- a/Sources/AlertPresentable/View+Alert.swift +++ b/Sources/AlertPresentable/View+Alert.swift @@ -34,12 +34,14 @@ private struct CommonAlert: ViewModifier { content .alert(alertController.title, isPresented: $alertController.isPresented) { ForEach(alertController.actions) { action in - Button(action.label, role: action.role) { + Button(role: action.role) { if let action = action.action { action() return } alertController.isPresented = false + } label: { + Text(action.label) } } } message: {