diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 6e281d4..5c8adbf 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -745,5 +745,6 @@ "to": "To: {to}", "selectStartTime": "Select start time", "selectEndTime": "Select end time", - "startTimeBeforeEndTime": "Start time must be before end time." + "startTimeBeforeEndTime": "Start time must be before end time.", + "noBlockingScheduleThisDevice": "There's no blocking schedule for this device." } \ No newline at end of file diff --git a/lib/l10n/app_es.arb b/lib/l10n/app_es.arb index 55f8237..6185a8f 100644 --- a/lib/l10n/app_es.arb +++ b/lib/l10n/app_es.arb @@ -745,5 +745,6 @@ "to": "Hasta: {to}", "selectStartTime": "Seleccionar hora de inicio", "selectEndTime": "Seleccionar hora de fin", - "startTimeBeforeEndTime": "La hora de inicio debe ser anterior a la hora de fin." + "startTimeBeforeEndTime": "La hora de inicio debe ser anterior a la hora de fin.", + "noBlockingScheduleThisDevice": "No hay programación de bloqueo para este dispositivo." } \ No newline at end of file diff --git a/lib/screens/clients/client/blocking_schedule.dart b/lib/screens/clients/client/blocking_schedule.dart index 0bcb21c..f17bd4d 100644 --- a/lib/screens/clients/client/blocking_schedule.dart +++ b/lib/screens/clients/client/blocking_schedule.dart @@ -69,6 +69,12 @@ class BlockingSchedule extends StatelessWidget { ); } + void onDeleteSchedule(String weekday) { + final scheduleJson = blockedServicesSchedule.toJson(); + scheduleJson[weekday] = null; + setBlockedServicesSchedule(BlockedServicesSchedule.fromJson(scheduleJson)); + } + String formatTime(int time) { final formatted = Duration(milliseconds: time); final hours = formatted.inHours; @@ -92,47 +98,66 @@ class BlockingSchedule extends StatelessWidget { ], ), const SizedBox(height: 2), + if ( + blockedServicesSchedule.mon == null && + blockedServicesSchedule.tue == null && + blockedServicesSchedule.wed == null && + blockedServicesSchedule.thu == null && + blockedServicesSchedule.fri == null && + blockedServicesSchedule.sat == null && + blockedServicesSchedule.sun == null + ) Padding( + padding: const EdgeInsets.all(16), + child: Text( + AppLocalizations.of(context)!.noBlockingScheduleThisDevice, + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 18, + color: Theme.of(context).colorScheme.onSurfaceVariant + ), + ), + ), if (blockedServicesSchedule.mon != null) _ScheduleTile( weekday: AppLocalizations.of(context)!.monday, schedule: "${formatTime(blockedServicesSchedule.mon!.start!)} - ${formatTime(blockedServicesSchedule.mon!.end!)}", onEdit: () => openEditScheduleModal("mon"), - onDelete: () => {} + onDelete: () => onDeleteSchedule("mon") ), if (blockedServicesSchedule.tue != null) _ScheduleTile( weekday: AppLocalizations.of(context)!.tuesday, schedule: "${formatTime(blockedServicesSchedule.tue!.start!)} - ${formatTime(blockedServicesSchedule.tue!.end!)}", onEdit: () => openEditScheduleModal("tue"), - onDelete: () => {} + onDelete: () => onDeleteSchedule("tue") ), if (blockedServicesSchedule.wed != null) _ScheduleTile( weekday: AppLocalizations.of(context)!.wednesday, schedule: "${formatTime(blockedServicesSchedule.wed!.start!)} - ${formatTime(blockedServicesSchedule.wed!.end!)}", onEdit: () => openEditScheduleModal("wed"), - onDelete: () => {} + onDelete: () => onDeleteSchedule("wed") ), if (blockedServicesSchedule.thu != null) _ScheduleTile( weekday: AppLocalizations.of(context)!.thursday, schedule: "${formatTime(blockedServicesSchedule.thu!.start!)} - ${formatTime(blockedServicesSchedule.thu!.end!)}", onEdit: () => openEditScheduleModal("thu"), - onDelete: () => {} + onDelete: () => onDeleteSchedule("thu") ), if (blockedServicesSchedule.fri != null) _ScheduleTile( weekday: AppLocalizations.of(context)!.friday, schedule: "${formatTime(blockedServicesSchedule.fri!.start!)} - ${formatTime(blockedServicesSchedule.fri!.end!)}", onEdit: () => openEditScheduleModal("fri"), - onDelete: () => {} + onDelete: () => onDeleteSchedule("fri") ), if (blockedServicesSchedule.sat != null) _ScheduleTile( weekday: AppLocalizations.of(context)!.saturday, schedule: "${formatTime(blockedServicesSchedule.sat!.start!)} - ${formatTime(blockedServicesSchedule.sat!.end!)}", onEdit: () => openEditScheduleModal("sat"), - onDelete: () => {} + onDelete: () => onDeleteSchedule("sat") ), if (blockedServicesSchedule.sun != null) _ScheduleTile( weekday: AppLocalizations.of(context)!.sunday, schedule: "${formatTime(blockedServicesSchedule.sun!.start!)} - ${formatTime(blockedServicesSchedule.sun!.end!)}", onEdit: () => openEditScheduleModal("sun"), - onDelete: () => {} + onDelete: () => onDeleteSchedule("sun") ), ], );