File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 88import Foundation
99
1010public class ComponentInformation {
11- public static let version = " 1.0.0-dev-preview "
11+ public static let version = " 1.0.1 "
1212 public static let name = " amplify-ui-swift-authenticator "
1313}
Original file line number Diff line number Diff line change @@ -89,7 +89,18 @@ public class SignUpState: AuthenticatorBaseState {
8989
9090 setBusy ( true )
9191 let cognitoConfiguration = authenticatorState. configuration
92- var inputs = signUpFields. map { Field ( field: $0) }
92+
93+ var existingFields : Set < String > = [ ]
94+ var inputs = signUpFields. compactMap { field -> Field ? in
95+ guard !existingFields. contains ( field. rawValue) else {
96+ log. warn ( " Skipping configuring field of type ' \( field. rawValue) ' because it was already present. " )
97+ return nil
98+ }
99+
100+ existingFields. insert ( field. rawValue)
101+ return Field ( field: field)
102+ }
103+
93104 for attribute in cognitoConfiguration. verificationMechanisms {
94105 if let index = inputs. firstIndex ( where: { $0. field. attributeType == attribute. asSignUpAttribute } ) {
95106 if !inputs[ index] . field. isRequired {
@@ -160,3 +171,18 @@ public extension SignUpState {
160171 }
161172 }
162173}
174+
175+ private extension SignUpField {
176+ var rawValue : String {
177+ switch attributeType {
178+ case . username:
179+ return " username "
180+ case . password:
181+ return " password "
182+ case . passwordConfirmation:
183+ return " passwordConfirmation "
184+ default :
185+ return attributeType. attributeKey? . rawValue ?? " unknown "
186+ }
187+ }
188+ }
Original file line number Diff line number Diff line change @@ -59,8 +59,10 @@ struct PhoneNumberField: View {
5959 CallingCodeField ( callingCode: $callingCode)
6060 . foregroundColor ( foregroundColor)
6161 . focused ( $focusedField, equals: . callingCode)
62- . onChange ( of: callingCode) { text in
63- self . text = " \( text) \( phoneNumber) "
62+ . onChange ( of: callingCode) { code in
63+ if !phoneNumber. isEmpty {
64+ text = " \( code) \( phoneNumber) "
65+ }
6466 }
6567
6668 Divider ( )
You can’t perform that action at this time.
0 commit comments