mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 21:23:44 +02:00
feat: add a builder for around the bigtextbutton
This allows apps to use a custom decoration around that element, for instance a dotted border.
This commit is contained in:
parent
e6e80fba28
commit
66fed84083
3 changed files with 49 additions and 9 deletions
|
@ -18,6 +18,7 @@ class AvailabilityOptions {
|
||||||
this.secondaryButtonBuilder = DefaultSecondaryButton.builder,
|
this.secondaryButtonBuilder = DefaultSecondaryButton.builder,
|
||||||
this.bigTextButtonBuilder = DefaultBigTextButton.builder,
|
this.bigTextButtonBuilder = DefaultBigTextButton.builder,
|
||||||
this.smallTextButtonBuilder = DefaultSmallTextButton.builder,
|
this.smallTextButtonBuilder = DefaultSmallTextButton.builder,
|
||||||
|
this.bigTextButtonWrapperBuilder = DefaultBigTextButtonWrapper.builder,
|
||||||
this.spacing = const AvailabilitySpacing(),
|
this.spacing = const AvailabilitySpacing(),
|
||||||
this.textStyles = const AvailabilityTextStyles(),
|
this.textStyles = const AvailabilityTextStyles(),
|
||||||
this.colors = const AvailabilityColors(),
|
this.colors = const AvailabilityColors(),
|
||||||
|
@ -54,6 +55,10 @@ class AvailabilityOptions {
|
||||||
/// This is used as a tertiary button smaller variant
|
/// This is used as a tertiary button smaller variant
|
||||||
final ButtonBuilder smallTextButtonBuilder;
|
final ButtonBuilder smallTextButtonBuilder;
|
||||||
|
|
||||||
|
/// A way to provide your own element wrapper for the [bigTextButtonBuilder]
|
||||||
|
/// On some screens this button is wrapped in a container with a padding
|
||||||
|
final ButtonBuilder bigTextButtonWrapperBuilder;
|
||||||
|
|
||||||
/// The spacing between elements
|
/// The spacing between elements
|
||||||
final AvailabilitySpacing spacing;
|
final AvailabilitySpacing spacing;
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,46 @@ class DefaultBigTextButton extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
class DefaultBigTextButtonWrapper extends StatelessWidget {
|
||||||
|
///
|
||||||
|
const DefaultBigTextButtonWrapper({
|
||||||
|
required this.child,
|
||||||
|
required this.onPressed,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
///
|
||||||
|
final Widget? child;
|
||||||
|
|
||||||
|
///
|
||||||
|
final FutureOr<void> Function()? onPressed;
|
||||||
|
|
||||||
|
///
|
||||||
|
static Widget builder(
|
||||||
|
BuildContext context,
|
||||||
|
FutureOr<void> Function()? onPressed,
|
||||||
|
Widget? child,
|
||||||
|
) =>
|
||||||
|
DefaultBigTextButtonWrapper(onPressed: onPressed, child: child);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => InkWell(
|
||||||
|
onTap: onPressed,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
border: Border.all(
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
width: 1,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
width: double.infinity,
|
||||||
|
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||||
|
child: child,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// The default small text button used in the component when no custom
|
/// The default small text button used in the component when no custom
|
||||||
/// button is provided. This button is used as a smaller variant of the
|
/// button is provided. This button is used as a smaller variant of the
|
||||||
/// tertiary button
|
/// tertiary button
|
||||||
|
|
|
@ -63,15 +63,10 @@ class PauseSelection extends StatelessWidget {
|
||||||
var sortedBreaks = breaks.toList()
|
var sortedBreaks = breaks.toList()
|
||||||
..sort((a, b) => a.startTime.compareTo(b.startTime));
|
..sort((a, b) => a.startTime.compareTo(b.startTime));
|
||||||
|
|
||||||
var addButton = DecoratedBox(
|
var addButton = options.bigTextButtonWrapperBuilder(
|
||||||
decoration: BoxDecoration(
|
context,
|
||||||
border: Border.all(
|
onClickAddBreak,
|
||||||
color: theme.colorScheme.primary,
|
options.bigTextButtonBuilder(
|
||||||
width: 1,
|
|
||||||
),
|
|
||||||
borderRadius: BorderRadius.circular(4),
|
|
||||||
),
|
|
||||||
child: options.bigTextButtonBuilder(
|
|
||||||
context,
|
context,
|
||||||
onClickAddBreak,
|
onClickAddBreak,
|
||||||
Text(translations.addButton),
|
Text(translations.addButton),
|
||||||
|
|
Loading…
Reference in a new issue