A customizable date picker for watchOS and SwiftUI.
🚧 | The next version of Watch Date Picker is under development. It will align the API to that of the standard SwiftUI date picker, and it will update the visual appearance to more closely match the system’s date picker. | VIEW BRANCH |
---|
Add the https://github.com/freyaalminde/watch-date-picker package, then add the WatchDatePicker product to your app’s WatchKit extension target.
Online documentation is available at freyaalminde.github.io/documentation/watchdatepicker.
The DatePicker
view displays a button with a title and the selected value. When pressed, it presents a sheet with user interfaces for selecting date and time.
DatePicker("Date & Time", selection: $value)
DatePicker("Date", selection: $value, mode: .date, maximumDate: Date())
DatePicker("Time", selection: $value, mode: .time, twentyFourHours: true)
Both DatePickerView
and TimePickerView
can be used independently of DatePicker
.
DatePickerView(selection: $value)
DatePickerView(selection: $value)
.environment(\.locale, Locale(identifier: "fr"))
TimePickerView(selection: $value)
TimePickerView(
selection: $value,
selectionIndicatorRadius: 7,
selectionIndicatorColor: .mint,
focusColor: .purple,
amPMHighlightColor: .yellow,
markSize: CGSize(width: 5.5, height: 3),
markFill: AnyShapeStyle(Color.white.opacity(0.75)),
emphasizedMarkSize: CGSize(width: 2, height: 7),
emphasizedMarkFill: AnyShapeStyle(Color.pink)
)