mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 13:13:44 +02:00
fix: get BorderRadius from a common variable rather than redefining it everywhere
This commit is contained in:
parent
a9f744d626
commit
f5962acf7a
10 changed files with 92 additions and 94 deletions
|
@ -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
|
||||||
|
|
|
@ -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";
|
||||||
|
|
|
@ -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());
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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,11 +217,11 @@ 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) ...[
|
||||||
|
@ -228,23 +229,8 @@ class _WeekTemplateModificationScreenState
|
||||||
] else ...[
|
] else ...[
|
||||||
overviewPage,
|
overviewPage,
|
||||||
],
|
],
|
||||||
const SizedBox(height: 32),
|
|
||||||
],
|
],
|
||||||
),
|
buttons: [
|
||||||
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) ...[
|
if (_editing) ...[
|
||||||
nextButton,
|
nextButton,
|
||||||
] else ...[
|
] else ...[
|
||||||
|
@ -258,13 +244,7 @@ class _WeekTemplateModificationScreenState
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return options.baseScreenBuilder(context, onBackPressed, body);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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,21 +138,34 @@ 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(
|
||||||
|
top: 10,
|
||||||
|
left: 12,
|
||||||
|
),
|
||||||
|
child: _TemplateLegendItem(
|
||||||
|
name:
|
||||||
|
translations.templateSelectionLabel,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
colors.selectedDayColor ??
|
colors.selectedDayColor ??
|
||||||
colorScheme.primaryFixedDim,
|
colorScheme.primaryFixedDim,
|
||||||
borderColor: colorScheme.primary,
|
borderColor: colorScheme.primary,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
if (existAvailabilitiesWithoutTemplate) ...[
|
if (existAvailabilitiesWithoutTemplate) ...[
|
||||||
_TemplateLegendItem(
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
top: 10,
|
||||||
|
left: 12,
|
||||||
|
),
|
||||||
|
child: _TemplateLegendItem(
|
||||||
name: translations
|
name: translations
|
||||||
.availabilityWithoutTemplateLabel,
|
.availabilityWithoutTemplateLabel,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
colors.customAvailabilityColor ??
|
colors.customAvailabilityColor ??
|
||||||
colorScheme.secondary,
|
colorScheme.secondary,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -213,18 +227,17 @@ 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,
|
||||||
),
|
),
|
||||||
|
@ -232,10 +245,9 @@ class _TemplateLegendItem extends StatelessWidget {
|
||||||
width: 20,
|
width: 20,
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
// TODO(Joey): Not divisible by 4
|
const SizedBox(width: 8),
|
||||||
const SizedBox(width: 6),
|
Text(name, style: theme.textTheme.bodyLarge),
|
||||||
Text(name, style: Theme.of(context).textTheme.bodyLarge),
|
|
||||||
],
|
],
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -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(
|
||||||
|
|
Loading…
Reference in a new issue