Skip to content

Commit

Permalink
🐛 Update text input component to handle label horizontalAlignment
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaatttt committed Jan 3, 2023
1 parent 64c2bd7 commit eb0df9d
Showing 1 changed file with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@ internal struct AppcuesTextInput: View {
let errorTintColor = stepState.shouldShowError(for: model.id) ? Color(dynamicColor: model.errorLabel?.style?.foregroundColor) : nil

VStack(alignment: style.horizontalAlignment, spacing: 0) {
TintedTextView(model: model.label, tintColor: errorTintColor)
HStack {
// nil-coalesce to .leading so a non-specified value defaults to leading-aligned
if HorizontalAlignment(string: model.label.style?.horizontalAlignment) ?? .leading != .leading {
Spacer()
}
TintedTextView(model: model.label, tintColor: errorTintColor)
if HorizontalAlignment(string: model.label.style?.horizontalAlignment) != .trailing {
Spacer()
}
}

let binding = stepState.formBinding(for: model.id)

Expand All @@ -38,7 +47,15 @@ internal struct AppcuesTextInput: View {
.overlay(errorBorder(errorTintColor, textFieldStyle))

if stepState.shouldShowError(for: model.id), let errorLabel = model.errorLabel {
AppcuesText(model: errorLabel)
HStack {
if HorizontalAlignment(string: errorLabel.style?.horizontalAlignment) ?? .leading != .leading {
Spacer()
}
AppcuesText(model: errorLabel)
if HorizontalAlignment(string: errorLabel.style?.horizontalAlignment) != .trailing {
Spacer()
}
}
}
}
.setupActions(on: viewModel, for: model)
Expand Down

0 comments on commit eb0df9d

Please sign in to comment.