fix: get BorderRadius from a common variable rather than redefining it everywhere

This commit is contained in:
Bart Ribbers 2024-07-18 14:17:03 +02:00 committed by Freek van de Ven
parent a9f744d626
commit f5962acf7a
10 changed files with 92 additions and 94 deletions

View file

@ -81,6 +81,11 @@ class AvailabilityOptions {
/// If not provided the [CircularProgressIndicator.adaptive()] will be used /// If not provided the [CircularProgressIndicator.adaptive()] will be used
/// which shows a platform adaptive loading indicator /// which shows a platform adaptive loading indicator
final WidgetBuilder loadingIndicatorBuilder; final WidgetBuilder loadingIndicatorBuilder;
final _borderRadius = BorderRadius.circular(5);
///
BorderRadius get borderRadius => _borderRadius;
} }
/// All configurable paddings and whitespaces withing the userstory /// All configurable paddings and whitespaces withing the userstory

View file

@ -1,3 +1,5 @@
import "dart:collection";
import "package:flutter/material.dart"; import "package:flutter/material.dart";
import "package:flutter_availability/src/service/availability_service.dart"; import "package:flutter_availability/src/service/availability_service.dart";
import "package:flutter_availability/src/ui/view_models/break_view_model.dart"; import "package:flutter_availability/src/ui/view_models/break_view_model.dart";

View file

@ -116,7 +116,6 @@ class _AvailabilityOverviewState extends State<AvailabilityOverview> {
title: translations.clearAvailabilityConfirmTitle, title: translations.clearAvailabilityConfirmTitle,
description: translations.clearAvailabilityConfirmDescription, description: translations.clearAvailabilityConfirmDescription,
); );
// TODO(Joey): Expect a non nullable
if (confirmed ?? false) { if (confirmed ?? false) {
await service await service
.clearAvailabilities(selectedAvailabilities.getAvailabilities()); .clearAvailabilities(selectedAvailabilities.getAvailabilities());

View file

@ -162,14 +162,14 @@ class _TemplateListSection extends StatelessWidget {
margin: const EdgeInsets.only(top: 8), margin: const EdgeInsets.only(top: 8),
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border.all(color: theme.dividerColor, width: 1), border: Border.all(color: theme.dividerColor, width: 1),
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
), ),
child: Row( child: Row(
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(template.color), color: Color(template.color),
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
), ),
height: 20, height: 20,
width: 20, width: 20,

View file

@ -1,6 +1,7 @@
import "package:flutter/material.dart"; 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/template_daydata_view_model.dart";
import "package:flutter_availability/src/ui/view_models/week_template_view_models.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/color_selection.dart";
import "package:flutter_availability/src/ui/widgets/template_name_input.dart"; import "package:flutter_availability/src/ui/widgets/template_name_input.dart";
import "package:flutter_availability/src/ui/widgets/template_time_break.dart"; import "package:flutter_availability/src/ui/widgets/template_time_break.dart";
@ -191,14 +192,14 @@ class _WeekTemplateModificationScreenState
color: theme.colorScheme.primary, color: theme.colorScheme.primary,
width: 1, width: 1,
), ),
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
), ),
child: Row( child: Row(
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(_viewModel.color ?? 0), color: Color(_viewModel.color ?? 0),
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
), ),
width: 20, width: 20,
height: 20, height: 20,
@ -216,55 +217,34 @@ class _WeekTemplateModificationScreenState
), ),
); );
var body = CustomScrollView( return options.baseScreenBuilder(
slivers: [ context,
SliverList.list( onBackPressed,
children: [ BasePage(
const SizedBox(height: 40), body: [
_WeekTemplateSidePadding(child: title), _WeekTemplateSidePadding(child: title),
const SizedBox(height: 24), const SizedBox(height: 24),
if (_editing) ...[ if (_editing) ...[
...editPage, ...editPage,
] else ...[ ] else ...[
overviewPage, overviewPage,
],
const SizedBox(height: 32),
], ],
), ],
SliverFillRemaining( buttons: [
fillOverscroll: false, if (_editing) ...[
hasScrollBody: false, nextButton,
child: Padding( ] else ...[
padding: EdgeInsets.symmetric( saveButton,
horizontal: spacing.sidePadding, const SizedBox(height: 8),
).copyWith( previousButton,
bottom: spacing.bottomButtonPadding, ],
), if (widget.template != null) ...[
child: Align( const SizedBox(height: 8),
alignment: Alignment.bottomCenter, deleteButton,
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,
],
],
),
),
),
),
],
); );
return options.baseScreenBuilder(context, onBackPressed, body);
} }
} }

View file

@ -74,7 +74,7 @@ class AvailabilityTemplateSelection extends StatelessWidget {
// TODO(Joey): This seems like a repeating borderRadius. I can // TODO(Joey): This seems like a repeating borderRadius. I can
// understand if these are not configurable, but I do think that // understand if these are not configurable, but I do think that
// they should be defined only once. // they should be defined only once.
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
), ),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
@ -90,7 +90,7 @@ class AvailabilityTemplateSelection extends StatelessWidget {
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(template.color), color: Color(template.color),
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
), ),
width: 20, width: 20,
height: 20, height: 20,

View file

@ -46,7 +46,7 @@ class TemplateColorSelection extends StatelessWidget {
height: 40, height: 40,
decoration: BoxDecoration( decoration: BoxDecoration(
color: color, color: color,
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
border: Border.all( border: Border.all(
color: color.value == selectedColor color: color.value == selectedColor
? Colors.black ? Colors.black

View file

@ -152,7 +152,7 @@ class BreakDisplay extends StatelessWidget {
decoration: BoxDecoration( decoration: BoxDecoration(
color: colors.selectedDayColor, color: colors.selectedDayColor,
border: Border.all(color: theme.colorScheme.primary, width: 1), border: Border.all(color: theme.colorScheme.primary, width: 1),
borderRadius: BorderRadius.circular(5), borderRadius: options.borderRadius,
), ),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
child: Row( child: Row(

View file

@ -71,6 +71,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
), ),
), ),
); );
return Column( return Column(
children: [ children: [
// a button to open/close a drawer with all the templates // a button to open/close a drawer with all the templates
@ -137,20 +138,33 @@ class _TemplateLegendState extends State<TemplateLegend> {
// TODO(Joey): Extract this as a widget // TODO(Joey): Extract this as a widget
return Column( return Column(
children: [ children: [
_TemplateLegendItem( Padding(
name: translations.templateSelectionLabel, padding: const EdgeInsets.only(
backgroundColor: top: 10,
colors.selectedDayColor ?? left: 12,
colorScheme.primaryFixedDim, ),
borderColor: colorScheme.primary, child: _TemplateLegendItem(
name:
translations.templateSelectionLabel,
backgroundColor:
colors.selectedDayColor ??
colorScheme.primaryFixedDim,
borderColor: colorScheme.primary,
),
), ),
if (existAvailabilitiesWithoutTemplate) ...[ if (existAvailabilitiesWithoutTemplate) ...[
_TemplateLegendItem( Padding(
name: translations padding: const EdgeInsets.only(
.availabilityWithoutTemplateLabel, top: 10,
backgroundColor: left: 12,
colors.customAvailabilityColor ?? ),
colorScheme.secondary, child: _TemplateLegendItem(
name: translations
.availabilityWithoutTemplateLabel,
backgroundColor:
colors.customAvailabilityColor ??
colorScheme.secondary,
),
), ),
], ],
], ],
@ -213,29 +227,27 @@ class _TemplateLegendItem extends StatelessWidget {
final Color? borderColor; final Color? borderColor;
@override @override
Widget build(BuildContext context) => Padding( Widget build(BuildContext context) {
padding: const EdgeInsets.only( var theme = Theme.of(context);
top: 10, var availabilityScope = AvailabilityScope.of(context);
left: 12, var options = availabilityScope.options;
),
child: Row( return Row(
children: [ children: [
Container( Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: backgroundColor, color: backgroundColor,
// TODO(Joey): Use a global borderRadius borderRadius: options.borderRadius,
borderRadius: BorderRadius.circular(5), border: Border.all(
border: Border.all( color: borderColor ?? Colors.transparent,
color: borderColor ?? Colors.transparent,
),
),
width: 20,
height: 20,
), ),
// TODO(Joey): Not divisible by 4 ),
const SizedBox(width: 6), width: 20,
Text(name, style: Theme.of(context).textTheme.bodyLarge), height: 20,
],
), ),
); const SizedBox(width: 8),
Text(name, style: theme.textTheme.bodyLarge),
],
);
}
} }

View file

@ -116,6 +116,8 @@ class _DaySelectionCardLayout extends StatelessWidget {
var theme = Theme.of(context); var theme = Theme.of(context);
var textTheme = theme.textTheme; var textTheme = theme.textTheme;
var abbreviationTextStyle = textTheme.headlineMedium; var abbreviationTextStyle = textTheme.headlineMedium;
var availabilityScope = AvailabilityScope.of(context);
var options = availabilityScope.options;
abbreviationTextStyle = isSelected abbreviationTextStyle = isSelected
? abbreviationTextStyle?.copyWith( ? abbreviationTextStyle?.copyWith(
@ -130,9 +132,7 @@ class _DaySelectionCardLayout extends StatelessWidget {
height: isSelected ? 72 : 64, height: isSelected ? 72 : 64,
width: isSelected ? 72 : 64, width: isSelected ? 72 : 64,
child: ChoiceChip( child: ChoiceChip(
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(borderRadius: options.borderRadius),
borderRadius: BorderRadius.circular(5),
),
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
label: Center( label: Center(
child: Text( child: Text(