CreationKit Documentation

Class Date​Picker

public final class DatePicker: UIView, JTACMonthViewDataSource, JTACMonthViewDelegate,
                               UIPickerViewDelegate, UIPickerViewDataSource  

Date pickers let users select a date, or a range of dates. DatePickers are created with a configuration.

Prefer to use make(configuration:didSelectDates:) to create a DatePicker.

The configuration allows you to configure some parts of how the DatePicker works. The most useful options are startDate, endDate, startAtDate, allowsMultipleSelection and useRangeSelection. You can generally ignore any others and leave them set to their defaults.

You can put the DatePicker almost anywhere as it is just a UIView. Adding it as a Card's content section may be useful if you need a header or actions.

DatePicker DatePicker UIView UIView DatePicker->UIView JTACMonthViewDelegate JTACMonthViewDelegate DatePicker->JTACMonthViewDelegate UIPickerViewDataSource UIPickerViewDataSource DatePicker->UIPickerViewDataSource JTACMonthViewDataSource JTACMonthViewDataSource DatePicker->JTACMonthViewDataSource UIPickerViewDelegate UIPickerViewDelegate DatePicker->UIPickerViewDelegate

Conforms To

JTACMonthViewDataSource
JTACMonthViewDelegate
UIPickerViewDataSource
UIPickerViewDelegate
UIView

Initializers

init(configuration:​did​Select​Dates:​)

public init(configuration: DatePickerConfiguration, didSelectDates: @escaping ([Date]) -> Void)  

Creates a new DatePicker with a configuration.

Prefer to use make(configuration:didSelectDates:) instead of this method.

Depending on the configuration, the didSelectDates closure may contain one date, or multiple dates.

In the case where only single selection is allowed, the closure can be called multiple times, where the user may have made a selection, updated their selection, or deselected a date (this will return an empty array).

In the case where allowsMultipleSelection is true, but useRangeSelection is false, this closure will be called multiple times, once for each selection/deselection, and will return all the current selected dates.

In the case where useRangeSelection is true, all dates in the range will be returned.

Parameters

configuration Date​Picker​Configuration

The configuration object to initialize the DatePicker.

did​Select​Dates @escaping ([Date]) -> Void

A closure that will be called when the user selects a date.

Methods

make(configuration:​did​Select​Dates:​)

public static func make(configuration: DatePickerConfiguration, didSelectDates: @escaping ([Date]) -> Void) -> DatePicker  

Creates a new DatePicker with a configuration.

Depending on the configuration, the didSelectDates closure may contain one date, or multiple dates.

In the case where only single selection is allowed, the closure can be called multiple times, where the user may have made a selection, updated their selection, or deselected a date (this will return an empty array).

In the case where allowsMultipleSelection is true, but useRangeSelection is false, this closure will be called multiple times, once for each selection/deselection, and will return all the current selected dates.

In the case where useRangeSelection is true, all dates in the range will be returned.

Parameters

configuration Date​Picker​Configuration

The configuration object to initialize the DatePicker.

did​Select​Dates @escaping ([Date]) -> Void

A closure that will be called when the user selects a date.

configure​Calendar(_:​)

public func configureCalendar(_ calendar: JTACMonthView) -> ConfigurationParameters  

calendar(_:​cell​For​Item​At:​cell​State:​index​Path:​)

public func calendar(_ calendar: JTACMonthView, cellForItemAt date: Date,
                       cellState: CellState, indexPath: IndexPath) -> JTACDayCell  

calendar(_:​will​Display:​for​Item​At:​cell​State:​index​Path:​)

public func calendar(_ calendar: JTACMonthView, willDisplay cell: JTACDayCell,
                       forItemAt date: Date, cellState: CellState, indexPath: IndexPath)  

calendar(_:​will​Scroll​ToDate​Segment​With:​)

public func calendar(_ calendar: JTACMonthView, willScrollToDateSegmentWith visibleDates: DateSegmentInfo)  

calendar(_:​did​Scroll​ToDate​Segment​With:​)

public func calendar(_ calendar: JTACMonthView, didScrollToDateSegmentWith visibleDates: DateSegmentInfo)  

calendar(_:​did​Select​Date:​cell:​cell​State:​index​Path:​)

public func calendar(_ calendar: JTACMonthView, didSelectDate date: Date,
                       cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath)  

calendar(_:​did​Deselect​Date:​cell:​cell​State:​index​Path:​)

public func calendar(_ calendar: JTACMonthView, didDeselectDate date: Date,
                       cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath)  

calendar(_:​should​Select​Date:​cell:​cell​State:​index​Path:​)

public func calendar(_ calendar: JTACMonthView, shouldSelectDate date: Date,
                       cell: JTACDayCell?, cellState: CellState,
                       indexPath: IndexPath) -> Bool  

calendar(_:​should​Deselect​Date:​cell:​cell​State:​index​Path:​)

public func calendar(_ calendar: JTACMonthView, shouldDeselectDate date: Date,
                       cell: JTACDayCell?, cellState: CellState, indexPath: IndexPath) -> Bool  

number​OfComponents(in:​)

func numberOfComponents(in pickerView: UIPickerView) -> Int  

picker​View(_:​number​OfRows​InComponent:​)

func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int  

picker​View(_:​title​For​Row:​for​Component:​)

func pickerView(_ pickerView: UIPickerView, titleForRow row: Int,
                  forComponent component: Int) -> String?  

picker​View(_:​did​Select​Row:​in​Component:​)

func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int,
                  inComponent component: Int)