vikramkakkar / SublimePicker

A material-styled android view that provisions picking of a date, time & recurrence option, all from a single user-interface.
Apache License 2.0
2.31k stars 409 forks source link

Added an alternate range selection mode #91

Open adriancoman opened 5 years ago

adriancoman commented 5 years ago

Added a new way to select date ranges, similar to the one Airbnb uses.

After the user selects the first date and chooses a second date, it will automatically create a range between those two dates. Ex: I first select 2nd of March and then select 10th of March it will select this date range without the need to long press and drag.

If you want to select another date, just chose a date and you can go through the process of range selection again.

matthewkrueger commented 5 years ago

This is exactly what I'm looking for - tap once to pick the start date, tap again to pick the end date. Any way you can merge this pull request in to the project would be appreciated!

jimmyleonardo commented 5 years ago

@vikramkakkar Hi Man, We need this feature, can you merge this PR? Thank you. CC: @hengkiardo

enmanuelmartinez commented 5 years ago

@vikramkakkar this feature that is missing, I have been searching on Internet several days and this is the Best but only missing that feature because is more naturally for the user select de date ranges by single tounch with the finger and not keeping press. I have implemented in an app and I was to force back, because users feel losing when they need to select a range of days and they dont know what is supose to do.

achatina commented 5 years ago

You have 2 bugs. Reset button not working If you select dates in different months, scroll start working badly. (e.g. you pick 1 of September -> wipe to November -> select 1st of November -> make swipe back. It will returns you to august, not October)

adriancoman commented 5 years ago

Hey @achatina, are the bugs that you mentioned present only in this pull request or is it in master as well? Will try and fix them next week, thx.

achatina commented 5 years ago

@adriancoman Yes, only in your PR. I was a little bit inattentive. The second bug a little bit different.} you pick 1 of September -> wipe to November -> select 1st of November -> you will be scrolled to September. So the previous is August. I have fixed it (import your fork).

First bug fixing by: ivHeaderDateReset in SublimeDatePicker edit switchToDateRangeView

if (isAlternateDatePicker) {
            tvHeaderDateStart.setActivated(true);
            tvHeaderDateEnd.setActivated(true);
            ivHeaderDateReset.setVisibility(View.GONE);
        } else {
            ivHeaderDateReset.setVisibility(View.VISIBLE);
            tvHeaderDateStart.setActivated(mCurrentlyActivatedRangeItem == RANGE_ACTIVATED_START);
            tvHeaderDateEnd.setActivated(mCurrentlyActivatedRangeItem == RANGE_ACTIVATED_END);
        }

For the second one modify onDaySelected in DayPickerView.ProxyDaySelectionEventListener mProxyDaySelectionEventListener: remove goToPosition field and at the end do: onDateChanged(true, false, !isAlternateDatePicker);