-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DON-715] Whole month in single date selection #2113
Conversation
/// The `CalendarSingleSelectionState` enum represents the different states of a single selection. | ||
public enum CalendarSingleSelectionState { | ||
/// The state, with single date selection | ||
case single(Date?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should probably not be optional right? the optional would be on the enum itself, but not the date.
reasoning being:
if there's a single date selected, it makes no sense that that seleciton has no date
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, bu the nil would be on the entire selection instance, not the date itself.
@State var selection: CalendarSingleSelectionState?
// so that would either be:
selection = .single(Date())
// or
selection = .wholeMonth(...)
// or
selection = nil
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Right. I applied the change. ✅
if date == dayDate { | ||
SingleSelectedCell(calendar: calendar, date: dayDate) | ||
} else { | ||
DefaultCalendarDayCell(calendar: calendar, date: dayDate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you appliy the above comment about optionality, I think this if let would be done on the selection itself, rather than the date.
switch selection {
case single(let date): SingleSelectedCel(...)
case wholeMonth(..): ....
case nil: DefaultCalendarDayCell(...)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the optional, but we still need this statement to determine which date needs to be highlighted among other dates when a date has been selected date == dayDate
.
When the tap action happens, we change the state, and the change of state helps us to render the changes.
) | ||
), | ||
calendar: calendar, | ||
validRange: validRange, | ||
initialMonthScroll: monthScroll | ||
) | ||
.monthAccessoryAction { _ in | ||
return CalendarMonthAccessoryAction( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the accessibility setting for this should be here instead, to avoid being possible to send nil to that, when you do have an action. wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. 👍
I made this config as part whole month selection state. So if the consumer doesn't want to use the wholeMonth they don't have to provide this value. Removed this optional. ✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!!
This PR adds the whole month selection as one the single date selection mode states.
Demo
Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2024-11-26.at.07.25.20.mp4