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
parent 749ba712a4
commit f54ba29c0e
2 changed files with 24 additions and 1 deletions

View file

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

View file

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