Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rheyansh/RPicker
Simple and Easy-to-Use iOS Swift Date and Options Picker
https://github.com/rheyansh/RPicker
datepicker ios options-picker optionspicker picker pickerview swift
Last synced: about 1 month ago
JSON representation
Simple and Easy-to-Use iOS Swift Date and Options Picker
- Host: GitHub
- URL: https://github.com/rheyansh/RPicker
- Owner: rheyansh
- License: mit
- Created: 2018-04-26T06:32:38.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-04-30T09:10:00.000Z (over 2 years ago)
- Last Synced: 2024-08-02T02:11:15.897Z (4 months ago)
- Topics: datepicker, ios, options-picker, optionspicker, picker, pickerview, swift
- Language: Swift
- Homepage:
- Size: 1.66 MB
- Stars: 147
- Watchers: 5
- Forks: 23
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - RPicker - Simple and Easy-to-Use iOS Swift Date and Options Picker. (OOM-Leaks-Crash / Picker)
README
# RPicker
Elegant and Easy-to-Use Swift Date and Options Picker.
Master branch has the latest code and compatible with Swift 5. Check other branches for various Swift versions# What's New
* iOS 14 Support with various UIDatePickerStyle e.g. Wheel, Inline, Compact
* Dark Mode and Light Mode Support
* Objective C Support [See How to use in Objective C Heading of this file]![Alt text](https://github.com/rheyansh/RPicker/blob/master/Screenshots/1.png)
![Alt text](https://github.com/rheyansh/RPicker/blob/master/Screenshots/2.png)
![Alt text](https://github.com/rheyansh/RPicker/blob/master/Screenshots/3.png)
![Alt text](https://github.com/rheyansh/RPicker/blob/master/Screenshots/4.png)# How to use
Add RPicker.swift into your project.
You are ready to go!// Simple Date Picker
RPicker.selectDate {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString("MMM-dd-YYYY")
}
// Simple Date Picker with title
RPicker.selectDate(title: "Select Date", didSelectDate: {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString("MMM-dd-YYYY")
})
// Simple Time Picker
RPicker.selectDate(title: "Select Time", cancelText: "Cancel", datePickerMode: .time, didSelectDate: { [weak self](selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString("hh:mm a")
})
// Simple Date and Time Picker
RPicker.selectDate(title: "Select Date & Time", cancelText: "Cancel", datePickerMode: .dateAndTime, minDate: Date(), maxDate: Date().dateByAddingYears(5), didSelectDate: {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString()
})
//Show date picker with min and max date
RPicker.selectDate(title: "Select Date", minDate: Date(), maxDate: Date().dateByAddingYears(5), didSelectDate: {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString("MMM-dd-YYYY")
})
// Simple Option Picker
let dummyList = ["Apple", "Orange", "Banana", "Mango", "Bilberry", "Blackberry"]RPicker.selectOption(dataArray: dummyList) {[weak self] (selctedText, atIndex) in
// TODO: Your implementation for selection
self?.outputLabel.text = selctedText + " selcted at \(atIndex)"
}
// Simple Option Picker with selected index
let dummyList = ["Apple", "Orange", "Banana", "Mango"]
RPicker.selectOption(title: "Select", cancelText: "Cancel", dataArray: dummyList, selectedIndex: 2) {[weak self] (selctedText, atIndex) in
// TODO: Your implementation for selection
self?.outputLabel.text = selctedText + " selcted at \(atIndex)"
}
//Date picker with pre selected date
let selectedDate = Date().dateByAddingYears(-6)
let maxDate = Date()
let minDate = Date().dateByAddingYears(-12)
RPicker.selectDate(title: "Select", selectedDate: selectedDate, minDate: minDate, maxDate: maxDate) { [weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString("MMM-dd-YYYY")
}
//Show date picker iOS 14 -> Inline mode
RPicker.selectDate(title: "Select Date", cancelText: "Cancel", datePickerMode: .date, style: .Inline, didSelectDate: {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString("MMM-dd-YYYY")
})
//Show time picker iOS 14 -> Inline mode
RPicker.selectDate(title: "Select Time", cancelText: "Cancel", datePickerMode: .time, style: .Inline, didSelectDate: {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString("hh:mm a")
})
//Show date and time picker iOS 14 -> Inline mode
RPicker.selectDate(title: "Select Date and Time", cancelText: "Cancel", datePickerMode: .dateAndTime, style: .Inline, didSelectDate: {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString()
})
//Show date and time picker iOS 14 -> Compact mode
RPicker.selectDate(title: "Select Date and Time", cancelText: "Cancel", datePickerMode: .dateAndTime, style: .Compact, didSelectDate: {[weak self] (selectedDate) in
// TODO: Your implementation for date
self?.outputLabel.text = selectedDate.dateString()
})
# How to use in Objective C
**Date Picker**[RPicker selectDateWithTitle:@"Select" cancelText:@"Cancel" doneText:@"Done" datePickerMode:UIDatePickerModeDate selectedDate:dateValue minDate:nil maxDate:nil style: RDatePickerStyleWheel didSelectDate:^(NSDate * _Nonnull date) {
}];
**Option Picker**NSArray *list = @[@"Banana", @"Apple", @"Orange"];
[RPicker pickOptionWithTitle:@"Select" cancelText:@"Cancel" doneText:@"Done" dataArray:list selectedIndex:[NSNumber numberWithInt:2] didSelectValue:^(NSString * _Nonnull value, NSInteger index) {
}];# Author
* [Raj Sharma](https://github.com/rheyansh)
## Communication
* If you **found a bug**, open an issue.
* If you **want to contribute**, submit a pull request.# License
RPicker is available under the MIT license. See the LICENSE file for more info.## Other Libraries
* [RBiometric](https://github.com/rheyansh/RBiometric):- Elegant and Easy-to-Use library for iOS Biometric (TouchId and FaceId) authentication.
* [RFirebaseMessaging](https://github.com/rheyansh/RFirebaseMessaging):- Project provides basic idea and approach for building small social media application using firebase and implementing chat using Firebase.
* [RBeacon](https://github.com/rheyansh/RBeacon):- Sample project for turning android device into a Beacon device. App can work as both broadcaster and receiver.
* [RPdfGenerator](https://github.com/rheyansh/RPdfGenerator):- A sample project to generate PDF file from data using itextpdf/itext7 library.