Giter Site home page Giter Site logo

nilsmango / watch-date-picker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from freysie/watch-date-picker

0.0 0.0 0.0 2.6 MB

A customizable date picker for watchOS and SwiftUI.

Home Page: https://freyaalminde.github.io/documentation/watchdatepicker/

License: MIT License

Shell 0.39% Swift 99.31% Makefile 0.31%

watch-date-picker's Introduction

Watch Date Picker

A customizable date picker for watchOS and SwiftUI.

Installation

Add the https://github.com/freyaalminde/watch-date-picker package, then add the WatchDatePicker product to your app’s WatchKit extension target.

Documentation

Online documentation is available at freyaalminde.github.io/documentation/watchdatepicker.

Overview

The DatePicker view displays a button with a title and the selected value. When pressed, it presents a user interface for selecting date, time, or both.

The date picker is designed to look and feel similar to the system’s date and time pickers, as seen in Safari, Alarms, Calendar, Reminders, and Sleep, with an API matching SwiftUI’s built-in DatePicker.

Selecting Date and Time

DatePicker(
    "Date & Time",
    selection: $value
)

Selecting a Date

DatePicker(
    "Date",
    selection: $value,
    displayedComponents: .date
)

Selecting a Time

DatePicker(
    "Time",
    selection: $value,
    displayedComponents: .hourAndMinute
)

Customization

DateInputView and TimeInputView, the two views which DatePicker is primarily composed of, can be used on their own.

Date Input View

The date input view displays three pickers for selecting day, month, and year.

DateInputView(selection: $value)

The date input view uses the current locale for labeling, ordering, and populating the day-month-year pickers.

DateInputView(selection: $value)
    .environment(\.locale, Locale(identifier: "fr"))

Time Input View

The time input view displays a clock dial for selecting hour and minute. In locales with AM/PM-based time, AM/PM buttons will be displayed, otherwise 24-hour mode is used.

TimeInputView(selection: $value)

24-hour mode can be explicitly enabled or disabled regardless of locale.

TimeInputView(selection: $value)
    .timeInputViewTwentyFourHourMode()

The 24-hour mode indicator can be hidden.

TimeInputView(selection: $value)
    .timeInputViewTwentyFourHourMode()
    .timeInputViewTwentyFourHourIndicator(.hidden)

Setting the tint will affect the selection indicator and AM/PM buttons.

TimeInputView(selection: $value)
    .tint(.pink)

The font of the value labels can be digit-monospaced.

TimeInputView(selection: $value)
    .timeInputViewMonospacedDigitFont()

See the documentation for more options.

watch-date-picker's People

Contributors

freysie avatar nilsmango avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.