diff --git a/packages/flutter_availability/lib/src/config/availability_options.dart b/packages/flutter_availability/lib/src/config/availability_options.dart index 1f78b88..90000c6 100644 --- a/packages/flutter_availability/lib/src/config/availability_options.dart +++ b/packages/flutter_availability/lib/src/config/availability_options.dart @@ -81,6 +81,11 @@ class AvailabilityOptions { /// If not provided the [CircularProgressIndicator.adaptive()] will be used /// which shows a platform adaptive loading indicator final WidgetBuilder loadingIndicatorBuilder; + + final _borderRadius = BorderRadius.circular(5); + + /// + BorderRadius get borderRadius => _borderRadius; } /// All configurable paddings and whitespaces withing the userstory diff --git a/packages/flutter_availability/lib/src/ui/screens/availability_modification.dart b/packages/flutter_availability/lib/src/ui/screens/availability_modification.dart index de63178..1920b14 100644 --- a/packages/flutter_availability/lib/src/ui/screens/availability_modification.dart +++ b/packages/flutter_availability/lib/src/ui/screens/availability_modification.dart @@ -1,3 +1,5 @@ +import "dart:collection"; + import "package:flutter/material.dart"; import "package:flutter_availability/src/service/availability_service.dart"; import "package:flutter_availability/src/ui/view_models/break_view_model.dart"; diff --git a/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart b/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart index 50764a6..1e1102d 100644 --- a/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart +++ b/packages/flutter_availability/lib/src/ui/screens/availability_overview.dart @@ -116,7 +116,6 @@ class _AvailabilityOverviewState extends State { title: translations.clearAvailabilityConfirmTitle, description: translations.clearAvailabilityConfirmDescription, ); - // TODO(Joey): Expect a non nullable if (confirmed ?? false) { await service .clearAvailabilities(selectedAvailabilities.getAvailabilities()); diff --git a/packages/flutter_availability/lib/src/ui/screens/template_overview.dart b/packages/flutter_availability/lib/src/ui/screens/template_overview.dart index 3179ce2..903eec9 100644 --- a/packages/flutter_availability/lib/src/ui/screens/template_overview.dart +++ b/packages/flutter_availability/lib/src/ui/screens/template_overview.dart @@ -162,14 +162,14 @@ class _TemplateListSection extends StatelessWidget { margin: const EdgeInsets.only(top: 8), decoration: BoxDecoration( border: Border.all(color: theme.dividerColor, width: 1), - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, ), child: Row( children: [ Container( decoration: BoxDecoration( color: Color(template.color), - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, ), height: 20, width: 20, diff --git a/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart b/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart index 6eae0e0..a1a43e1 100644 --- a/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart +++ b/packages/flutter_availability/lib/src/ui/screens/template_week_modification.dart @@ -1,6 +1,7 @@ import "package:flutter/material.dart"; import "package:flutter_availability/src/ui/view_models/template_daydata_view_model.dart"; import "package:flutter_availability/src/ui/view_models/week_template_view_models.dart"; +import "package:flutter_availability/src/ui/widgets/base_page.dart"; import "package:flutter_availability/src/ui/widgets/color_selection.dart"; import "package:flutter_availability/src/ui/widgets/template_name_input.dart"; import "package:flutter_availability/src/ui/widgets/template_time_break.dart"; @@ -191,14 +192,14 @@ class _WeekTemplateModificationScreenState color: theme.colorScheme.primary, width: 1, ), - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, ), child: Row( children: [ Container( decoration: BoxDecoration( color: Color(_viewModel.color ?? 0), - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, ), width: 20, height: 20, @@ -216,55 +217,34 @@ class _WeekTemplateModificationScreenState ), ); - var body = CustomScrollView( - slivers: [ - SliverList.list( - children: [ - const SizedBox(height: 40), - _WeekTemplateSidePadding(child: title), - const SizedBox(height: 24), - if (_editing) ...[ - ...editPage, - ] else ...[ - overviewPage, - ], - const SizedBox(height: 32), + return options.baseScreenBuilder( + context, + onBackPressed, + BasePage( + body: [ + _WeekTemplateSidePadding(child: title), + const SizedBox(height: 24), + if (_editing) ...[ + ...editPage, + ] else ...[ + overviewPage, ], - ), - SliverFillRemaining( - fillOverscroll: false, - hasScrollBody: false, - child: Padding( - padding: EdgeInsets.symmetric( - horizontal: spacing.sidePadding, - ).copyWith( - bottom: spacing.bottomButtonPadding, - ), - child: Align( - alignment: Alignment.bottomCenter, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - if (_editing) ...[ - nextButton, - ] else ...[ - saveButton, - const SizedBox(height: 8), - previousButton, - ], - if (widget.template != null) ...[ - const SizedBox(height: 8), - deleteButton, - ], - ], - ), - ), - ), - ), - ], + ], + buttons: [ + if (_editing) ...[ + nextButton, + ] else ...[ + saveButton, + const SizedBox(height: 8), + previousButton, + ], + if (widget.template != null) ...[ + const SizedBox(height: 8), + deleteButton, + ], + ], + ), ); - - return options.baseScreenBuilder(context, onBackPressed, body); } } diff --git a/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart b/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart index 7cc294d..768a573 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/availability_template_selection.dart @@ -74,7 +74,7 @@ class AvailabilityTemplateSelection extends StatelessWidget { // TODO(Joey): This seems like a repeating borderRadius. I can // understand if these are not configurable, but I do think that // they should be defined only once. - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, ), child: Row( crossAxisAlignment: CrossAxisAlignment.center, @@ -90,7 +90,7 @@ class AvailabilityTemplateSelection extends StatelessWidget { Container( decoration: BoxDecoration( color: Color(template.color), - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, ), width: 20, height: 20, diff --git a/packages/flutter_availability/lib/src/ui/widgets/color_selection.dart b/packages/flutter_availability/lib/src/ui/widgets/color_selection.dart index 9b14da3..af6ced9 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/color_selection.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/color_selection.dart @@ -46,7 +46,7 @@ class TemplateColorSelection extends StatelessWidget { height: 40, decoration: BoxDecoration( color: color, - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, border: Border.all( color: color.value == selectedColor ? Colors.black 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 8e7d4fd..2fac5ce 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/pause_selection.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/pause_selection.dart @@ -152,7 +152,7 @@ class BreakDisplay extends StatelessWidget { decoration: BoxDecoration( color: colors.selectedDayColor, border: Border.all(color: theme.colorScheme.primary, width: 1), - borderRadius: BorderRadius.circular(5), + borderRadius: options.borderRadius, ), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), child: Row( diff --git a/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart b/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart index 3e98379..5d49baf 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/template_legend.dart @@ -71,6 +71,7 @@ class _TemplateLegendState extends State { ), ), ); + return Column( children: [ // a button to open/close a drawer with all the templates @@ -137,20 +138,33 @@ class _TemplateLegendState extends State { // TODO(Joey): Extract this as a widget return Column( children: [ - _TemplateLegendItem( - name: translations.templateSelectionLabel, - backgroundColor: - colors.selectedDayColor ?? - colorScheme.primaryFixedDim, - borderColor: colorScheme.primary, + Padding( + padding: const EdgeInsets.only( + top: 10, + left: 12, + ), + child: _TemplateLegendItem( + name: + translations.templateSelectionLabel, + backgroundColor: + colors.selectedDayColor ?? + colorScheme.primaryFixedDim, + borderColor: colorScheme.primary, + ), ), if (existAvailabilitiesWithoutTemplate) ...[ - _TemplateLegendItem( - name: translations - .availabilityWithoutTemplateLabel, - backgroundColor: - colors.customAvailabilityColor ?? - colorScheme.secondary, + Padding( + padding: const EdgeInsets.only( + top: 10, + left: 12, + ), + child: _TemplateLegendItem( + name: translations + .availabilityWithoutTemplateLabel, + backgroundColor: + colors.customAvailabilityColor ?? + colorScheme.secondary, + ), ), ], ], @@ -213,29 +227,27 @@ class _TemplateLegendItem extends StatelessWidget { final Color? borderColor; @override - Widget build(BuildContext context) => Padding( - padding: const EdgeInsets.only( - top: 10, - left: 12, - ), - child: Row( - children: [ - Container( - decoration: BoxDecoration( - color: backgroundColor, - // TODO(Joey): Use a global borderRadius - borderRadius: BorderRadius.circular(5), - border: Border.all( - color: borderColor ?? Colors.transparent, - ), - ), - width: 20, - height: 20, + Widget build(BuildContext context) { + var theme = Theme.of(context); + var availabilityScope = AvailabilityScope.of(context); + var options = availabilityScope.options; + + return Row( + children: [ + Container( + decoration: BoxDecoration( + color: backgroundColor, + borderRadius: options.borderRadius, + border: Border.all( + color: borderColor ?? Colors.transparent, ), - // TODO(Joey): Not divisible by 4 - const SizedBox(width: 6), - Text(name, style: Theme.of(context).textTheme.bodyLarge), - ], + ), + width: 20, + height: 20, ), - ); + const SizedBox(width: 8), + Text(name, style: theme.textTheme.bodyLarge), + ], + ); + } } diff --git a/packages/flutter_availability/lib/src/ui/widgets/template_week_day_selection.dart b/packages/flutter_availability/lib/src/ui/widgets/template_week_day_selection.dart index 0aedb5d..be5d25f 100644 --- a/packages/flutter_availability/lib/src/ui/widgets/template_week_day_selection.dart +++ b/packages/flutter_availability/lib/src/ui/widgets/template_week_day_selection.dart @@ -116,6 +116,8 @@ class _DaySelectionCardLayout extends StatelessWidget { var theme = Theme.of(context); var textTheme = theme.textTheme; var abbreviationTextStyle = textTheme.headlineMedium; + var availabilityScope = AvailabilityScope.of(context); + var options = availabilityScope.options; abbreviationTextStyle = isSelected ? abbreviationTextStyle?.copyWith( @@ -130,9 +132,7 @@ class _DaySelectionCardLayout extends StatelessWidget { height: isSelected ? 72 : 64, width: isSelected ? 72 : 64, child: ChoiceChip( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - ), + shape: RoundedRectangleBorder(borderRadius: options.borderRadius), padding: EdgeInsets.zero, label: Center( child: Text(