diff --git a/ElementX/Sources/Other/Extensions/Alert.swift b/ElementX/Sources/Other/Extensions/Alert.swift index 94e6355e7..8d53adddb 100644 --- a/ElementX/Sources/Other/Extensions/Alert.swift +++ b/ElementX/Sources/Other/Extensions/Alert.swift @@ -45,20 +45,10 @@ extension View { /// .alert(item: $context.alertInfo) /// ``` struct AlertInfo: Identifiable, AlertProtocol { - struct AlertButton: Identifiable { - let id = UUID() - let title: String - var role: ButtonRole? - let action: (() -> Void)? - } - - struct AlertTextField: Identifiable { - let id = UUID() - let placeholder: String - let text: Binding - let autoCapitalization: TextInputAutocapitalization - let autoCorrectionDisabled: Bool - } + // The button types live outside this generic type, otherwise the default + // primaryButton would need T's (possibly isolated) Hashable conformance. + typealias AlertButton = AlertInfoButton + typealias AlertTextField = AlertInfoTextField /// An identifier that can be used to distinguish one error from another. let id: T @@ -99,6 +89,21 @@ extension AlertInfo { } } +struct AlertInfoButton: Identifiable { + let id = UUID() + let title: String + var role: ButtonRole? + let action: (() -> Void)? +} + +struct AlertInfoTextField: Identifiable { + let id = UUID() + let placeholder: String + let text: Binding + let autoCapitalization: TextInputAutocapitalization + let autoCorrectionDisabled: Bool +} + extension View { func alert(item: Binding?>) -> some View { alert(item: item) { item in