miraan / CalendarDateRangePickerViewController

A calendar date range picker view controller in Swift for iOS.
MIT License
139 stars 79 forks source link

Single date selection added. #27

Open ajoykarmakar459 opened 4 years ago

ajoykarmakar459 commented 4 years ago

Previously I have found that we can select multiple dates with these awesome plugins but faced issues while selecting a single date. So I have changed some code in this swift file so the user can select single or multiple both dates. Please merge this code so I can directly fetch the updated code with "pod install" and I hope many users like me still facing the same issues. Best Regards, Ajoy Karmakar

osmantufekci commented 4 years ago

if you need to use like dd.MM.yyyy-dd.MM.yyyy.

inside the CalendarDateRangePickerViewController.Swift file, navigate didTapDone() function and edit like this:

@objc func didTapDone() {
        if selectedStartDate != nil && selectedEndDate == nil{
            delegate.didTapDoneWithDateRange(startDate: selectedStartDate!, endDate: selectedStartDate!)
        }else if selectedStartDate == nil || selectedEndDate == nil {
            return
        }else{
            delegate.didTapDoneWithDateRange(startDate: selectedStartDate!, endDate: selectedEndDate!)
        }
    }

much easier and cleaner. just select a date, if user won't select second date, it will send both selectedStartDate