feat: add template deviation marking on availability overview

This commit is contained in:
Freek van de Ven 2024-07-12 10:54:13 +02:00 committed by Bart Ribbers
parent 04b843d2fd
commit bc32462c16
2 changed files with 24 additions and 1 deletions

View file

@ -16,6 +16,7 @@ class AvailabilityTranslations {
required this.templateLegendTitle,
required this.templateSelectionLabel,
required this.availabilityWithoutTemplateLabel,
required this.availabilityTemplateDeviation,
required this.overviewScreenTitle,
required this.createTemplateButton,
required this.clearAvailabilityButton,
@ -69,6 +70,7 @@ class AvailabilityTranslations {
this.templateLegendTitle = "Templates",
this.templateSelectionLabel = "Selected day(s)",
this.availabilityWithoutTemplateLabel = "Availabilty without template",
this.availabilityTemplateDeviation = "Template deviation",
this.createTemplateButton = "Create a new template",
this.clearAvailabilityButton = "Not available on these days",
this.clearAvailabilityConfirmTitle = "Are you sure you want to clear?",
@ -135,6 +137,9 @@ class AvailabilityTranslations {
/// The label for the availabilities without a template in the template legend
final String availabilityWithoutTemplateLabel;
/// The hint text for the availability template deviation
final String availabilityTemplateDeviation;
/// The title on the overview screen
final String overviewScreenTitle;

View file

@ -63,11 +63,15 @@ class CalendarView extends StatelessWidget {
@override
Widget build(BuildContext context) {
var theme = Theme.of(context);
var textTheme = theme.textTheme;
var availabilityScope = AvailabilityScope.of(context);
var options = availabilityScope.options;
var translations = options.translations;
var mappedCalendarDays = _mapAvailabilitiesToCalendarDays(availabilities);
var existsTemplateDeviations = mappedCalendarDays.any(
(element) => element.templateDeviation,
);
var monthDateSelector = Row(
mainAxisAlignment: MainAxisAlignment.center,
@ -86,7 +90,7 @@ class CalendarView extends StatelessWidget {
width: _calculateTextWidthOfLongestMonth(context, translations),
child: Text(
translations.monthYearFormatter(context, month),
style: theme.textTheme.titleMedium,
style: textTheme.titleMedium,
textAlign: TextAlign.center,
),
),
@ -110,12 +114,26 @@ class CalendarView extends StatelessWidget {
selectedRange: selectedRange,
);
var templateDeviationMarking = Row(
children: [
Text("* ", style: textTheme.bodySmall),
Text(
translations.availabilityTemplateDeviation,
style: textTheme.bodySmall,
),
],
);
return Column(
children: [
monthDateSelector,
const Divider(height: 1),
const SizedBox(height: 20),
calendarGrid,
if (existsTemplateDeviations) ...[
const SizedBox(height: 24),
templateDeviationMarking,
],
],
);
}