Skip to content

Commit 1e13280

Browse files
authored
fix: Fixing DatePicker and SignUpContent issues (#37)
1 parent 0a4e9be commit 1e13280

File tree

4 files changed

+32
-8
lines changed

4 files changed

+32
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.0.5 (2023-08-31)
4+
5+
### Bug Fixes
6+
- Fixing required Sign Up attributes being displayed as optionals
7+
- Fixing Sign Up fields not being populated when providing a `signUpContent`
8+
- Fixing DatePicker being interactable while invisible, plus not displaying previous dates.
9+
310
## 1.0.4 (2023-08-22)
411
### Bug Fixes
512
- Adding missing label when displaying a `.custom()` Sign Up field.

Sources/Authenticator/Authenticator.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ public struct Authenticator<LoadingContent: View,
310310
confirmResetPasswordContent
311311
case .signUp:
312312
signUpContent
313+
.onAppear {
314+
guard let state = signUpState, state.fields.isEmpty else { return }
315+
state.configure(with: viewModifiers.signUpFields)
316+
}
313317
case .confirmSignUp:
314318
confirmSignUpContent
315319
case .verifyUser:
@@ -337,6 +341,10 @@ public struct Authenticator<LoadingContent: View,
337341
contentState.configure(with: state)
338342
}
339343
}
344+
345+
private var signUpState: SignUpState? {
346+
contentStates.allObjects.compactMap({ $0 as? SignUpState }).first
347+
}
340348
}
341349

342350
extension 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.4"
11+
public static let version = "1.0.5"
1212
public static let name = "amplify-ui-swift-authenticator"
1313
}

Sources/Authenticator/Views/Primitives/DatePicker.swift

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ struct DatePicker: View {
3939
using: FieldValidators.none
4040
)
4141
self.validator.value = text
42+
if let selectedDate = formatter.date(from: text.wrappedValue) {
43+
self._selectedDate = .init(wrappedValue: selectedDate)
44+
self._actualDate = .init(wrappedValue: selectedDate)
45+
}
4246
}
4347

4448
#if os(iOS)
@@ -88,6 +92,7 @@ struct DatePicker: View {
8892

8993
createDatePicker(style: .graphical)
9094
.frame(height: isShowingDatePicker ? nil : 0, alignment: .top)
95+
.disabled(!isShowingDatePicker)
9196
.clipped()
9297
}
9398
}
@@ -149,6 +154,7 @@ struct DatePicker: View {
149154
.onChange(of: selectedDate) { date in
150155
updateDate(date)
151156
}
157+
.environment(\.timeZone, timeZone)
152158
.padding([.top, .bottom], theme.components.field.padding)
153159
}
154160

@@ -203,13 +209,12 @@ struct DatePicker: View {
203209
guard let date = actualDate else {
204210
return placeholder
205211
}
206-
207-
return date.formatted(
208-
.dateTime
209-
.day()
210-
.month()
211-
.year()
212-
)
212+
213+
return date.formatted(Date.FormatStyle(
214+
date: .abbreviated,
215+
time: .omitted,
216+
timeZone: timeZone
217+
))
213218
}
214219

215220
private var placeholderColor: Color {
@@ -227,4 +232,8 @@ struct DatePicker: View {
227232
return theme.colors.border.error
228233
}
229234
}
235+
236+
private var timeZone: TimeZone {
237+
TimeZone(secondsFromGMT: 0) ?? TimeZone.current
238+
}
230239
}

0 commit comments

Comments
 (0)