mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 05:03: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
|
||||
/// 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
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -116,7 +116,6 @@ class _AvailabilityOverviewState extends State<AvailabilityOverview> {
|
|||
title: translations.clearAvailabilityConfirmTitle,
|
||||
description: translations.clearAvailabilityConfirmDescription,
|
||||
);
|
||||
// TODO(Joey): Expect a non nullable
|
||||
if (confirmed ?? false) {
|
||||
await service
|
||||
.clearAvailabilities(selectedAvailabilities.getAvailabilities());
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -71,6 +71,7 @@ class _TemplateLegendState extends State<TemplateLegend> {
|
|||
),
|
||||
),
|
||||
);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// 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
|
||||
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),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue