DateTimePicker
public struct DateTimePicker
extension DateTimePicker: View
extension DateTimePicker: _ViewEmptyChecking
DateTimePicker
provides a title and value label with Fiori styling and a DatePicker
.
Usage
@State var customizedDate: Date = .init(timeIntervalSince1970: 0.0)
@State var isRequired = false
@State var showsErrorMessage = false
@State var customizedPickerVisible = false
let customizedDateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "MM/dd/yyyy HH:mm:ss"
return formatter
}()
func mandatoryFieldIndicator() -> TextOrIcon {
var indicator = AttributedString("*")
indicator.font = .fiori(forTextStyle: .title3)
indicator.foregroundColor = Color.preferredColor(.indigo7)
return .text(indicator)
}
@State var customizedPickerVisible = false
DateTimePicker(title: "Customized Date Formatter, locale and calendar", mandatoryFieldIndicator: self.mandatoryFieldIndicator(), isRequired: self.isRequired, selectedDate: self.$customizedDate, dateFormatter: self.customizedDateFormatter, pickerVisible: self.$customizedPickerVisible)
.environment(\.locale, Locale(identifier: "zh-Hans"))
.environment(\.calendar, Calendar(identifier: .gregorian))
-
init(title:
valueLabel: controlState: errorMessage: range: selectedDate: dateFormatter: pickerComponents: dateStyle: timeStyle: noDateSelectedString: pickerVisible: componentIdentifier: ) Undocumented
Declaration
Swift
public init(@ViewBuilder title: () -> any View, @ViewBuilder valueLabel: () -> any View = { EmptyView() }, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, range: ClosedRange<Date>? = nil, selectedDate: Binding<Date>, dateFormatter: DateFormatter? = nil, pickerComponents: DatePicker.Components = [.date, .hourAndMinute], dateStyle: Date.FormatStyle.DateStyle = .abbreviated, timeStyle: Date.FormatStyle.TimeStyle = .shortened, noDateSelectedString: String? = nil, pickerVisible: Binding<Bool>, componentIdentifier: String? = DateTimePicker.identifier)
-
Undocumented
Declaration
Swift
static let identifier: String
-
init(title:
valueLabel: mandatoryFieldIndicator: isRequired: controlState: errorMessage: range: selectedDate: dateFormatter: pickerComponents: dateStyle: timeStyle: noDateSelectedString: pickerVisible: ) Undocumented
Declaration
Swift
init(title: AttributedString, valueLabel: AttributedString? = nil, mandatoryFieldIndicator: TextOrIcon? = .text("*"), isRequired: Bool = false, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, range: ClosedRange<Date>? = nil, selectedDate: Binding<Date>, dateFormatter: DateFormatter? = nil, pickerComponents: DatePicker.Components = [.date, .hourAndMinute], dateStyle: Date.FormatStyle.DateStyle = .abbreviated, timeStyle: Date.FormatStyle.TimeStyle = .shortened, noDateSelectedString: String? = nil, pickerVisible: Binding<Bool>)
-
Undocumented
Declaration
Swift
init(_ configuration: DateTimePickerConfiguration)
-
Declaration
Swift
@MainActor public var body: some View { get }
-
Undocumented
Declaration
Swift
public var isEmpty: Bool { get }