JoshHalvorson / calendar-date-range-picker

Open source android library for date range selection
https://github.com/JoshHalvorson/calendar-date-range-picker/wiki
GNU General Public License v3.0
15 stars 3 forks source link

Refactor code for a better testability #21

Open ouattararomuald opened 2 years ago

ouattararomuald commented 2 years ago

Is your feature request related to a problem? Please describe.

  1. I think CalendarPicker is doing too much things. This makes it hard to test and it will be hard maintain in the future.
  2. Each event is represented by a pair of key-value Pair<String, Calendar>. I think calendar is a very consuming object.
  3. fun addEvents(vararg events: Pair<String, Calendar>) should propose an overload that take a Collection

Describe the solution you'd like

  1. I think we should have clear separation between widgets:
    • CalendarCellView : to represent a day cell
    • CalendarRowView : to represent a row with 7 day cells
  2. Create a class data class Event(eventName: String, eventDescription: String, date: Date)
  3. Generally people will retrieve the list of events from a data source as a Collection. It will be a good alternative

Describe alternatives you've considered I'm open to any other alternative and discussion

JoshHalvorson commented 2 years ago

Yeah I think everything you mentioned is valid and would make things a lot better for the codebase!

JoshHalvorson commented 2 years ago

One thing ive been thinking of is a viewmodel to store the current month/year and the selection data so there's a bit more persistence on config changes, would you wanna do that in this or in another pr?

Also thank you so much for all the contributions!

ouattararomuald commented 2 years ago

I'll do it in another PR. And thank you too

JoshHalvorson commented 2 years ago

Awesome!