mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Add RTE formatting buttons (#1614)
* Add RTE formatting buttons * Update UUID as stored properties * Disable autocorrection on URL fields * Alert ids to let * Add ComposerToolbar_Previews * Cleanup * Cleanup * Refactor FormatItem colors * Fix composer layout issue * Fix ui tests * Nest ComposerToolbar A11y ids under RoomScreen * Add composer reply ui tests * Add UTs --------- Co-authored-by: Alfonso Grillo <alfogrillo@gmail.com>
This commit is contained in:
@@ -52,12 +52,21 @@ extension View {
|
||||
/// .alert(item: $context.alertInfo)
|
||||
/// ```
|
||||
struct AlertInfo<T: Hashable>: Identifiable, AlertProtocol {
|
||||
struct AlertButton {
|
||||
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<String>
|
||||
let autoCapitalization: TextInputAutocapitalization
|
||||
let autoCorrectionDisabled: Bool
|
||||
}
|
||||
|
||||
/// An identifier that can be used to distinguish one error from another.
|
||||
let id: T
|
||||
/// The alert's title.
|
||||
@@ -68,6 +77,10 @@ struct AlertInfo<T: Hashable>: Identifiable, AlertProtocol {
|
||||
var primaryButton = AlertButton(title: L10n.actionOk, action: nil)
|
||||
/// The alert's secondary button title and action.
|
||||
var secondaryButton: AlertButton?
|
||||
/// The alert's displayed text fields.
|
||||
var textFields: [AlertTextField]?
|
||||
/// The alert's additional buttons displayed vertically above the primary button.
|
||||
var verticalButtons: [AlertButton]?
|
||||
}
|
||||
|
||||
extension AlertInfo {
|
||||
@@ -95,9 +108,28 @@ extension AlertInfo {
|
||||
extension View {
|
||||
func alert<T: Hashable>(item: Binding<AlertInfo<T>?>) -> some View {
|
||||
alert(item: item) { item in
|
||||
if let verticalButtons = item.verticalButtons {
|
||||
ForEach(verticalButtons) { button in
|
||||
Button(button.title, role: button.role) {
|
||||
button.action?()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let textFields = item.textFields {
|
||||
VStack(spacing: 24) {
|
||||
ForEach(textFields) { textField in
|
||||
TextField(textField.placeholder, text: textField.text)
|
||||
.textInputAutocapitalization(textField.autoCapitalization)
|
||||
.autocorrectionDisabled(textField.autoCorrectionDisabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Button(item.primaryButton.title, role: item.primaryButton.role) {
|
||||
item.primaryButton.action?()
|
||||
}
|
||||
|
||||
if let secondaryButton = item.secondaryButton {
|
||||
Button(secondaryButton.title, role: secondaryButton.role) {
|
||||
secondaryButton.action?()
|
||||
|
||||
Reference in New Issue
Block a user