From 1187bc37bfe5170aa91726acf0d914d147536cd1 Mon Sep 17 00:00:00 2001 From: Julien Sagot Date: Sun, 23 Feb 2025 23:21:19 +0100 Subject: [PATCH] Support titleVisibility on UIAlertController --- .../UIKit/AlertStateUIKit.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift b/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift index 562893d48c5e..9aa7e2340132 100644 --- a/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift +++ b/Sources/ComposableArchitecture/UIKit/AlertStateUIKit.swift @@ -65,7 +65,7 @@ ) { let state = store.currentState self.init( - title: String(state: state.title), + title: state.effectiveTitle, message: state.message.map { String(state: $0) }, preferredStyle: .actionSheet ) @@ -76,6 +76,19 @@ addAction(UIAlertAction(title: "OK", style: .cancel)) } } + } + private extension ConfirmationDialogState { + var effectiveTitle: String? { + switch titleVisibility { + case .automatic: + let title = String(state: self.title) + return title.isEmpty ? nil : title + case .hidden: + return nil + case .visible: + return String(state: title) + } + } } #endif