Date picker


A date picker is an efficient interface for selecting a specific date or a range of dates.



import SwiftUI

struct ExampleView: View {

    @StateObject var xelaDateManager:XelaDateManager = XelaDateManager(
        calendar: Calendar.current,
        minimumDate: Date().addingTimeInterval(60*60*24*(-365)),
        maximumDate: Date().addingTimeInterval(60*60*24*365),
        disabledDates: [Date().addingTimeInterval(60*60*24*(-3)), Date().addingTimeInterval(60*60*24*(10)), Date().addingTimeInterval(60*60*24*(-2))],
        selectedDate: Date().addingTimeInterval(60*60*24*3),
        mode: 0,
        colors: XelaColorSettings(),
        cellWidth: 40

    var body: some View {
        XelaDatePicker(xelaDateManager: xelaDateManager, monthOffset: 12)

Properties XelaDatePicker

Name Type Default Value Required Description
xelaDateManager XelaDateManager - YES Date manager for Date Picker
monthOffset Int 0 NO Month Offset, used for change current display Month in Date Picker

Properties XelaDateManager

Name Type Default Value Required Description
calendar Calendar - YES Calendar component for Date Picker
minimumDate Date - YES Minimum date for Date Picker
maximumDate Date - YES Maximum date for Date Picker
disabledDates [Date] [] NO Array for disabled Dates in Date Picker
selectedDate Date? nil NO Selected date
selectedDates [Date] [] NO Array of selected dates
mode Int - YES Date Picker Mode: 0 - to select a single date, 1 - to select a contiguous range of dates, from a start date to an end date, 2 - is automatically toggled internally and the end date must be greater than the start date, 3 - for selecting a number of dates
colors XelaColorSettings XelaColorSettings() NO Colors for Date Picker
cellWidth CGFloat 40 NO Date Cell Width

Properties XelaColorSettings

Name Type Default Value Required Description
textColor Color Color(xelaColor: .Gray3) NO Default text color
todayColor Color Color(xelaColor: .Blue3) NO Today text color
selectedColor Color Color(.white) NO Selected text color
disabledColor Color Color(xelaColor: .Gray9) NO Disabled text color
betweenStartAndEndColor Color Color(xelaColor: .Gray3) NO Between start and end selected text color
textBackgroundColor Color Color.clear NO Default background color
todayBackgroundColor Color Color(.white) NO Today background color
selectedBackgroundColor Color Color(xelaColor: .Blue3) NO Selected background color
disabledBackgroundColor Color Color.clear NO Disabled background color
betweenStartAndEndBackgroundColor Color Color(xelaColor: .Blue8) NO Between start and end selected background color
weekdayHeaderColor Color Color(xelaColor: .Gray7) NO Weekday text color
monthHeaderColor Color Color(xelaColor: .Gray2) NO Month text color
yearHeaderColor Color Color(xelaColor: .Gray9) NO Year text color
weekdayHeaderBackgroundColor Color Color.clear NO Weekday background color
monthBackgroundColor Color Color.clear NO Month background color
changeMonthButtonBackground Color Color(.white) NO Change month button background color
changeMonthButtonForeground Color Color(xelaColor: .Gray3) NO Change month button foreground color
dividerColor Color Color(xelaColor: .Gray9) NO Divider color