Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mac-gallagher/durationpicker
⏰ A customizable picker for selecting time values with hours, minutes, and/or seconds
https://github.com/mac-gallagher/durationpicker
datepicker ios picker timepicker ui-components uikit
Last synced: 2 months ago
JSON representation
⏰ A customizable picker for selecting time values with hours, minutes, and/or seconds
- Host: GitHub
- URL: https://github.com/mac-gallagher/durationpicker
- Owner: mac-gallagher
- License: mit
- Created: 2024-02-19T07:48:30.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-03-19T17:59:32.000Z (10 months ago)
- Last Synced: 2024-10-30T17:25:26.424Z (2 months ago)
- Topics: datepicker, ios, picker, timepicker, ui-components, uikit
- Language: Swift
- Homepage: https://mac-gallagher.github.io/DurationPicker/
- Size: 98.6 KB
- Stars: 27
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DurationPicker
[![CI](https://github.com/mac-gallagher/DurationPicker/actions/workflows/ci.yml/badge.svg)](https://github.com/mac-gallagher/DurationPicker/actions/workflows/ci.yml)
[![Documentation](https://github.com/mac-gallagher/DurationPicker/actions/workflows/documentation.yml/badge.svg)](https://github.com/mac-gallagher/DurationPicker/actions/workflows/documentation.yml)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmac-gallagher%2FDurationPicker%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/mac-gallagher/DurationPicker)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fmac-gallagher%2FDurationPicker%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/mac-gallagher/DurationPicker)DurationPicker is an iOS library that provides a customizable control for inputting time values ranging between 0 and 24 hours. It serves as a drop-in replacement of [UIDatePicker](https://developer.apple.com/documentation/uikit/uidatepicker) with [countDownTimer](https://developer.apple.com/documentation/uikit/uidatepicker/mode/countdowntimer) mode with additional functionality for time input.
## Features
- [x] Styled to match `UIDatePicker` with `countDownTimer` mode
- [x] Multiple modes for selection of hours, minutes, and/or seconds
- [x] Option to specify intervals for hour, minute, and/or seconds
- [x] Support for minimum and maximum durations
- [x] Localization in [26+ languages](https://mac-gallagher.github.io/DurationPicker/documentation/durationpicker/localization)
- [x] Built-in support for accessibility and VoiceOver## Usage
To use DurationPicker, simply create an instance of `DurationPicker` and add it to your view hierarchy. You can customize your picker using the following properties:
- `pickerMode`: The mode of the picker, determines whether the duration picker allows selection of hours, minutes, and/or seconds
- `{hour|minute|second}Interval`: The intervals at which the duration picker should display
- `{minimum|maximum}Duration`: The minimum/maximum duration that the picker can showThe code below will produce the following duration picker.
```swift
import DurationPickerlet picker = DurationPicker()
addSubview(picker)picker.pickerMode = .minuteSecond
picker.minuteInterval = 5
picker.secondInterval = 30
picker.minimumDuration = (15 * 60) // 15 minutes
picker.maximumDuration = (45 * 60) + 30 // 45 minutes, 30 seconds
```The selected duration can also be set programmatically through the `duration` property.
```swift
picker.duration = (30 * 60) + 30 // 30 minutes, 30 seconds
```You can react to changes in the duration's picker value using [UIActions](https://developer.apple.com/documentation/uikit/uiaction).
```swift
let action = UIAction { [weak picker] _ in
guard let picker else { return }
print(picker.duration) // 1830
},
for: .primaryAction)
picker.addAction(action)
```## Demo
To see `DurationPicker` in action, clone the repository and open the `DurationPickerDemo` project.
In addition to demonstrating the features of `DurationPicker`, the demo app serves as an example of how a `DurationPicker` can be used in a [modern collection view](https://developer.apple.com/documentation/uikit/views_and_controls/collection_views/implementing_modern_collection_views).
## Documentation
Full documentation available on [Github Pages](https://mac-gallagher.github.io/DurationPicker/documentation/durationpicker).## Installation
### Swift Package Manager
DurationPicker is available through [Swift PM](). To install it, simply add the package as a dependency in `Package.swift`:```swift
dependencies: [
.package(url: "https://github.com/mac-gallagher/DurationPicker.git", from: "1.0.0"),
]
```### Manual
Download and drop the `Sources` directory into your project.## Requirements
- iOS 15.0+
- XCode 15.0+
- Swift 5.9+## License
DurationPicker is available under the MIT license. See [LICENSE](LICENSE) for more information.
## Contributing
Contributions are welcome! Fork the repo, make your changes, and submit a pull request.