DateRangePicker
public struct DateRangePicker
extension DateRangePicker: View
extension DateRangePicker: _ViewEmptyChecking
DateRangePicker provides a title and value label with Fiori styling and a MultiDatePicker.
Usage
@State var isRequired = false
@State var selectedRange1: ClosedRange<Date>? = Date.now...Date.init(timeIntervalSinceNow: 24 * 60 * 60 * 2)
@State var selectedRange2: ClosedRange<Date>? = Date.now...Date.init(timeIntervalSinceNow: 24 * 60 * 60 * 2)
@State var selectedRange3: ClosedRange<Date>? = Date.now...Date.init(timeIntervalSinceNow: 24 * 60 * 60 * 2)
@State var pickerVisible1 = false
@State var pickerVisible2 = false
@State var pickerVisible3 = false
@State var showsErrorMessage = false
@State var showAINotice: Bool = false
let customizedDateFormatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "dd-MM-yyyy"
return formatter
}()
DateRangePicker(title: "Range Selection1", isRequired: isRequired, selectedRange: $selectedRange1, pickerVisible: $pickerVisible1)
.informationView(isPresented: self.$showsErrorMessage, description: AttributedString("This is information hint message."))
.informationViewStyle(.informational)
.aiNoticeView(isPresented: self.$showAINotice, description: "AI Notice")
DateRangePicker(title: "Customized Date Formatter", mandatoryFieldIndicator: self.mandatoryFieldIndicator(), isRequired: self.isRequired, selectedRange: self.$selectedRange2, rangeFormatter: self.customizedDateFormatter, pickerVisible: self.$pickerVisible2)
.informationView(isPresented: self.$showsErrorMessage, description: AttributedString("This is information success message."))
.informationViewStyle(.success)
.aiNoticeView(isPresented: self.$showAINotice, description: "AI Notice")
DateRangePicker(title: "Custom Locale & Calendar", mandatoryFieldIndicator: self.mandatoryFieldIndicator(), isRequired: self.isRequired, selectedRange: self.$selectedRange3, pickerVisible: self.$pickerVisible3)
.informationView(isPresented: self.$showsErrorMessage, description: AttributedString("This is information hint message."))
.informationViewStyle(.informational)
.aiNoticeView(isPresented: self.$showAINotice, description: "AI Notice")
.environment(\.locale, Locale(identifier: "zh-Hans"))
.environment(\.calendar, Calendar(identifier: .gregorian))
-
init(title:valueLabel: controlState: errorMessage: range: selectedRange: rangeFormatter: noRangeSelectedString: pickerVisible: showsClearAction: clearAction: componentIdentifier: ) Undocumented
Declaration
Swift
public init(@ViewBuilder title: () -> any View, @ViewBuilder valueLabel: () -> any View = { EmptyView() }, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, range: Range<Date>? = nil, selectedRange: Binding<ClosedRange<Date>?> = .constant(nil), rangeFormatter: DateFormatter? = nil, noRangeSelectedString: String? = nil, pickerVisible: Binding<Bool>, showsClearAction: Bool = false, @ViewBuilder clearAction: () -> any View = { FioriIcon.actions.sysCancel.foregroundColor(.gray) }, componentIdentifier: String? = DateRangePicker.identifier) -
init(title:valueLabel: controlState: errorMessage: range: selectedRange: rangeFormatter: noRangeSelectedString: pickerVisible: ) Convenience initializer for
DateRangePickerDeclaration
Swift
init(@ViewBuilder title: () -> any View, @ViewBuilder valueLabel: () -> any View = { EmptyView() }, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, range: Range<Date>? = nil, selectedRange: Binding<ClosedRange<Date>?> = .constant(nil), rangeFormatter: DateFormatter? = nil, noRangeSelectedString: String? = nil, pickerVisible: Binding<Bool>)Parameters
titleThe title view for the date range picker.
valueLabelThe value view for the date range picker.
controlStateThe
ControlStateof the form view. The default isnormal.errorMessageThe error message of the form view.
rangeThe inclusive range of selectable dates.
selectedRangeThe range of selected dates. Default is nil. It’s continuous in ascending order.
rangeFormatterRange date formatter. The default date formatter conforms system setting, it uses short date type in compact screen and uses long date type in regular screen.
noRangeSelectedStringThe text to be displayed when no range is selected. If this property is
nil, the localized string “No range selected” will be used.pickerVisibleThis property indicates whether the picker is to be displayed or not.
-
init(title:valueLabel: mandatoryFieldIndicator: isRequired: controlState: errorMessage: range: selectedRange: rangeFormatter: noRangeSelectedString: pickerVisible: ) Convenience initializer for
DateRangePickerDeclaration
Swift
init(title: AttributedString, valueLabel: AttributedString? = nil, mandatoryFieldIndicator: TextOrIcon? = .text("*"), isRequired: Bool = false, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, range: Range<Date>? = nil, selectedRange: Binding<ClosedRange<Date>?>, rangeFormatter: DateFormatter? = nil, noRangeSelectedString: String? = nil, pickerVisible: Binding<Bool>)Parameters
titleThe title string for the date range picker.
valueLabelThe value string for the date range picker.
mandatoryFieldIndicatorThe mandatory field indicator for the date range picker.
isRequiredThis property indicates whether the mandatory field indicator is to be displayed.
controlStateThe
ControlStateof the form view. The default isnormal.errorMessageThe error message of the form view.
rangeThe inclusive range of selectable dates.
selectedRangeThe range of selected dates. Default is nil. It’s continuous in ascending order.
rangeFormatterRange date formatter. The default date formatter conforms system setting, it uses short date type in compact screen and uses long date type in regular screen.
noRangeSelectedStringThe text to be displayed when no range is selected. If this property is
nil, the localized string “No range selected” will be used.pickerVisibleThis property indicates whether the picker is to be displayed or not.
-
Undocumented
Declaration
Swift
static let identifier: String -
init(title:valueLabel: mandatoryFieldIndicator: isRequired: controlState: errorMessage: range: selectedRange: rangeFormatter: noRangeSelectedString: pickerVisible: showsClearAction: clearAction: ) Undocumented
Declaration
Swift
init(title: AttributedString, valueLabel: AttributedString? = nil, mandatoryFieldIndicator: TextOrIcon? = .text("*"), isRequired: Bool = false, controlState: ControlState = .normal, errorMessage: AttributedString? = nil, range: Range<Date>? = nil, selectedRange: Binding<ClosedRange<Date>?>, rangeFormatter: DateFormatter? = nil, noRangeSelectedString: String? = nil, pickerVisible: Binding<Bool>, showsClearAction: Bool = false, @ViewBuilder clearAction: () -> any View = { FioriIcon.actions.sysCancel.foregroundColor(.gray) }) -
Undocumented
Declaration
Swift
init(_ configuration: DateRangePickerConfiguration) -
Declaration
Swift
@MainActor public var body: some View { get } -
Undocumented
Declaration
Swift
public var isEmpty: Bool { get }