I have a date picker inside a bottom sheet view.
When the bottom sheet opens, the first time I choose a day, the date picker height changes. P.S: If I set a custom height for the picker using .frame, the date picker just becomes smooshed inside the frame.
var body: some View {
VStack {
HStack {
Text("date_picker_title".ld())
.font(.custom(Font.rRegular, size: 12))
.padding()
Spacer()
}
HStack {
Text(date.prettyDate)
.font(.custom(Font.rMedium, size: 28))
Spacer()
Text(date.prettyHour)
.font(.custom(Font.rMedium, size: 28))
}.padding(.horizontal)
Seperator(cellHeight: 0).frame(height: 2)
Spacer().frame(height: 6)
DatePicker("", selection: $date, in: Date()..., displayedComponents: .date)
.datePickerStyle(.graphical)
.labelsHidden()
.tint(Color.appPurple)
.padding(.horizontal)
.padding(.bottom, -10)
Seperator(cellHeight: 0).frame(height: 2)
HStack {
Text("date_picker_enter_time".ld())
.font(.custom(Font.rRegular, size: 12))
DatePicker("", selection: $date, displayedComponents: .hourAndMinute)
.labelsHidden()
.tint(Color.appPurple)
Spacer()
}.padding()
HStack {
Button {
completion(nil)
} label: {
Text("date_picker_cancel".ld())
.font(.custom(Font.rRegular, size: 14))
.foregroundColor(Color.appPurple)
}
Spacer()
Button {
completion(date)
} label: {
Text("date_picker_ok".ld())
.font(.custom(Font.rRegular, size: 14))
.foregroundColor(Color.appPurple)
}
}.padding(.horizontal)
Spacer().frame(height: 50)
}
.frame(maxWidth: .infinity)
.background(Color.appLightPurple)
.padding(.bottom, -50)
}