Skip to content

Commit 0a4e9be

Browse files
authored
fix: Displaying label when provided in a Custom Sign Up fields (#32)
1 parent e6cca20 commit 0a4e9be

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.0.4 (2023-08-22)
4+
### Bug Fixes
5+
- Adding missing label when displaying a `.custom()` Sign Up field.
6+
37
## 1.0.3 (2023-08-17)
48

59
### Bug Fixes
@@ -25,4 +29,4 @@
2529

2630
Amplify Authenticator provides a complete drop-in implementation of an authentication flow for your application using [Amplify Authentication](https://docs.amplify.aws/lib/auth/getting-started/q/platform/ios/).
2731

28-
More information on setting up and using the component is in the [documentation](https://ui.docs.amplify.aws/swift/connected-components/authenticator).
32+
More information on setting up and using the component is in the [documentation](https://ui.docs.amplify.aws/swift/connected-components/authenticator).

Sources/Authenticator/Constants/ComponentInformation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
import Foundation
99

1010
public class ComponentInformation {
11-
public static let version = "1.0.3"
11+
public static let version = "1.0.4"
1212
public static let name = "amplify-ui-swift-authenticator"
1313
}

Sources/Authenticator/Views/Internal/SignUpInputField.swift

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,16 @@ struct SignUpInputField: View {
7171
}
7272

7373
@ViewBuilder func customView(for field: CustomSignUpField) -> some View {
74-
VStack(alignment: .leading) {
74+
VStack(alignment: .leading, spacing: theme.components.field.spacing.vertical) {
75+
if let label = field.label {
76+
HStack {
77+
SwiftUI.Text(label)
78+
.foregroundColor(foregroundColor)
79+
.font(theme.fonts.body)
80+
.accessibilityHidden(true)
81+
Spacer()
82+
}
83+
}
7584
AnyView(
7685
field.content($field.value)
7786
)
@@ -86,11 +95,20 @@ struct SignUpInputField: View {
8695
field.errorContent(errorMessage)
8796
.font(theme.fonts.subheadline)
8897
)
89-
.foregroundColor(borderColor)
90-
.transition(options.contentTransition)
98+
.foregroundColor(borderColor)
99+
.transition(options.contentTransition)
91100
}
92101
}
93102
}
103+
104+
private var foregroundColor: Color {
105+
switch validator.state {
106+
case .normal:
107+
return theme.colors.foreground.secondary
108+
case .error:
109+
return theme.colors.foreground.error
110+
}
111+
}
94112

95113
private var borderColor: Color {
96114
switch validator.state {

0 commit comments

Comments
 (0)