From 986d6a8d3f5719aaaec70c6a7651d2cfa14bdf37 Mon Sep 17 00:00:00 2001 From: Freek van de Ven Date: Wed, 24 Jul 2024 14:49:38 +0200 Subject: [PATCH] feat: add close button for pause selection dialog --- .../lib/src/ui/widgets/pause_selection.dart | 109 ++++++++++-------- 1 file changed, 61 insertions(+), 48 deletions(-) diff --git a/packages/flutter_availability/lib/src/ui/widgets/pause_selection.dart b/packages/flutter_availability/lib/src/ui/widgets/pause_selection.dart index 73621ad..b41c2aa 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/pause_selection.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/pause_selection.dart @@ -296,59 +296,72 @@ class _AvailabilityBreakSelectionDialogState ? translations.pauseDialogDescriptionTemplate : translations.pauseDialogDescriptionAvailability; - return Container( - margin: EdgeInsets.symmetric( - horizontal: spacing.sidePadding, - ), - child: SingleChildScrollView( - child: Column( - children: [ - const SizedBox(height: 44), - Text( - translations.pauseDialogTitle, - style: textTheme.titleMedium, - textAlign: TextAlign.center, - ), - const SizedBox(height: 4), - Text( - descriptionText, - style: textTheme.bodyMedium, - textAlign: TextAlign.center, - ), - const SizedBox(height: 16), - Row( + return Stack( + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: spacing.sidePadding, + ), + child: SingleChildScrollView( + child: Column( children: [ - const Spacer(), - Expanded( - flex: 2, - child: DurationInputField( - initialValue: _breakViewModel.submittedDuration, - onDurationChanged: onUpdateDuration, - ), + const SizedBox(height: 44), + Text( + translations.pauseDialogTitle, + style: textTheme.titleMedium, + textAlign: TextAlign.center, ), - const Spacer(), + const SizedBox(height: 4), + Text( + descriptionText, + style: textTheme.bodyMedium, + textAlign: TextAlign.center, + ), + const SizedBox(height: 16), + Row( + children: [ + const Spacer(), + Expanded( + flex: 2, + child: DurationInputField( + initialValue: _breakViewModel.submittedDuration, + onDurationChanged: onUpdateDuration, + ), + ), + const Spacer(), + ], + ), + const SizedBox(height: 24), + TimeSelection( + key: ValueKey( + [_breakViewModel.startTime, _breakViewModel.endTime], + ), + // rebuild the widget when the start or end time changes + title: translations.pauseDialogPeriodTitle, + description: translations.pauseDialogPeriodDescription, + crossAxisAlignment: CrossAxisAlignment.center, + startTime: _breakViewModel.startTime, + endTime: _breakViewModel.endTime, + onStartChanged: onUpdateStart, + onEndChanged: onUpdateEnd, + ), + const SizedBox(height: 36), + saveButton, + SizedBox(height: spacing.bottomButtonPadding), ], ), - const SizedBox(height: 24), - TimeSelection( - key: ValueKey( - [_breakViewModel.startTime, _breakViewModel.endTime], - ), - // rebuild the widget when the start or end time changes - title: translations.pauseDialogPeriodTitle, - description: translations.pauseDialogPeriodDescription, - crossAxisAlignment: CrossAxisAlignment.center, - startTime: _breakViewModel.startTime, - endTime: _breakViewModel.endTime, - onStartChanged: onUpdateStart, - onEndChanged: onUpdateEnd, - ), - const SizedBox(height: 36), - saveButton, - SizedBox(height: spacing.bottomButtonPadding), - ], + ), ), - ), + Positioned( + right: 0, + top: 0, + child: IconButton( + padding: const EdgeInsets.all(16), + icon: const Icon(Icons.close), + onPressed: () => Navigator.of(context).pop(), + ), + ), + ], ); } }