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))
  • 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)
  • Convenience initializer for DateRangePicker

    Declaration

    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

    title

    The title view for the date range picker.

    valueLabel

    The value view for the date range picker.

    controlState

    The ControlState of the form view. The default is normal.

    errorMessage

    The error message of the form view.

    range

    The inclusive range of selectable dates.

    selectedRange

    The range of selected dates. Default is nil. It’s continuous in ascending order.

    rangeFormatter

    Range 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.

    noRangeSelectedString

    The text to be displayed when no range is selected. If this property is nil, the localized string “No range selected” will be used.

    pickerVisible

    This property indicates whether the picker is to be displayed or not.

  • Convenience initializer for DateRangePicker

    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>)

    Parameters

    title

    The title string for the date range picker.

    valueLabel

    The value string for the date range picker.

    mandatoryFieldIndicator

    The mandatory field indicator for the date range picker.

    isRequired

    This property indicates whether the mandatory field indicator is to be displayed.

    controlState

    The ControlState of the form view. The default is normal.

    errorMessage

    The error message of the form view.

    range

    The inclusive range of selectable dates.

    selectedRange

    The range of selected dates. Default is nil. It’s continuous in ascending order.

    rangeFormatter

    Range 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.

    noRangeSelectedString

    The text to be displayed when no range is selected. If this property is nil, the localized string “No range selected” will be used.

    pickerVisible

    This property indicates whether the picker is to be displayed or not.

  • Undocumented

    Declaration

    Swift

    static let identifier: String
  • 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 }