configurable slot duration: UI picker + genRanges stepMinutes

- Fix TimeOfDayExtension.add() to handle minute overflow via total-minutes math
- genRanges() now takes stepMinutes param (default 30, clamp 5-480)
- Profesional model: slotDurationMinutes field (parsed from slot_duration_minutes)
- ProfessionalFormProvider: saves slot duration alongside schedules on Guardar
- schedule_view: _SlotDurationPicker chip selector (15/20/30/45/60/90/120 min)
- ProfessionalCalendarView + CalendarView: pass slotDurationMinutes to genRanges

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Lizandro Guarnizo
2026-07-12 19:25:08 -05:00
co-authored by Claude Sonnet 4.6
parent 46acad0b55
commit 920ae7144d
7 changed files with 105 additions and 20 deletions
+7 -5
View File
@@ -79,7 +79,7 @@ class _ProfessionalCalendarViewState extends State<ProfessionalCalendarView> {
final pro = fp.profesional!;
final sp = Provider.of<ServicesProvider>(context, listen: false);
final schedule = _scheduleFor(_selected.weekday, pro);
final slots = _buildSlots(schedule);
final slots = _buildSlots(schedule, pro.slotDurationMinutes);
final occupied = slots.where((t) => _isOccupied(t, _services, _selected)).length;
final blocked = slots.where((t) => _isSelfBooked(t, _services, _selected)).length;
@@ -386,13 +386,15 @@ class _ProfessionalCalendarViewState extends State<ProfessionalCalendarView> {
_ => pro.schedules.sunday,
};
List<TimeOfDay> _buildSlots(ScheduleEntity? s) {
List<TimeOfDay> _buildSlots(ScheduleEntity? s, int stepMinutes) {
if (s == null || !s.enabled || s.range1Hour1 == null || s.range2Hour2 == null) return [];
if (s.continuousDay) return TimeOfDayUtils.genRanges(s.range1Hour1!, s.range2Hour2!);
if (s.continuousDay) {
return TimeOfDayUtils.genRanges(s.range1Hour1!, s.range2Hour2!, stepMinutes: stepMinutes);
}
if (s.range1Hour2 == null || s.range2Hour1 == null) return [];
return [
...TimeOfDayUtils.genRanges(s.range1Hour1!, s.range1Hour2!),
...TimeOfDayUtils.genRanges(s.range2Hour1!, s.range2Hour2!),
...TimeOfDayUtils.genRanges(s.range1Hour1!, s.range1Hour2!, stepMinutes: stepMinutes),
...TimeOfDayUtils.genRanges(s.range2Hour1!, s.range2Hour2!, stepMinutes: stepMinutes),
];
}