mirror of
https://github.com/Iconica-Development/flutter_availability.git
synced 2025-05-19 13:13:44 +02:00
feat: split the textButtonBuilder into a big and small variant
This commit is contained in:
parent
5bfac2f4e3
commit
0b286d1267
6 changed files with 77 additions and 17 deletions
|
@ -16,7 +16,8 @@ class AvailabilityOptions {
|
||||||
this.baseScreenBuilder = DefaultBaseScreen.builder,
|
this.baseScreenBuilder = DefaultBaseScreen.builder,
|
||||||
this.primaryButtonBuilder = DefaultPrimaryButton.builder,
|
this.primaryButtonBuilder = DefaultPrimaryButton.builder,
|
||||||
this.secondaryButtonBuilder = DefaultSecondaryButton.builder,
|
this.secondaryButtonBuilder = DefaultSecondaryButton.builder,
|
||||||
this.textButtonBuilder = DefaultTextButton.builder,
|
this.bigTextButtonBuilder = DefaultBigTextButton.builder,
|
||||||
|
this.smallTextButtonBuilder = DefaultSmallTextButton.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(),
|
||||||
|
@ -45,8 +46,13 @@ class AvailabilityOptions {
|
||||||
/// A way to provide your own secondary button implementation
|
/// A way to provide your own secondary button implementation
|
||||||
final ButtonBuilder secondaryButtonBuilder;
|
final ButtonBuilder secondaryButtonBuilder;
|
||||||
|
|
||||||
/// A way to provide your own text button implementation
|
/// A way to provide your own big text button implementation
|
||||||
final ButtonBuilder textButtonBuilder;
|
/// This is used as a tertiary button
|
||||||
|
final ButtonBuilder bigTextButtonBuilder;
|
||||||
|
|
||||||
|
/// A way to provide your own small text button implementation
|
||||||
|
/// This is used as a tertiary button smaller variant
|
||||||
|
final ButtonBuilder smallTextButtonBuilder;
|
||||||
|
|
||||||
/// The spacing between elements
|
/// The spacing between elements
|
||||||
final AvailabilitySpacing spacing;
|
final AvailabilitySpacing spacing;
|
||||||
|
|
|
@ -120,7 +120,7 @@ class _AvailabilityOverviewState extends State<AvailabilityOverview> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var clearSelectedButton = options.textButtonBuilder(
|
var clearSelectedButton = options.bigTextButtonBuilder(
|
||||||
context,
|
context,
|
||||||
onClearButtonClicked,
|
onClearButtonClicked,
|
||||||
Text(translations.clearAvailabilityButton),
|
Text(translations.clearAvailabilityButton),
|
||||||
|
|
|
@ -80,7 +80,7 @@ class _AvailabilityDayTemplateEditState
|
||||||
Text(translations.saveButton),
|
Text(translations.saveButton),
|
||||||
);
|
);
|
||||||
|
|
||||||
var deleteButton = options.textButtonBuilder(
|
var deleteButton = options.bigTextButtonBuilder(
|
||||||
context,
|
context,
|
||||||
onDeletePressed,
|
onDeletePressed,
|
||||||
Text(translations.deleteTemplateButton),
|
Text(translations.deleteTemplateButton),
|
||||||
|
|
|
@ -104,7 +104,8 @@ class _TemplateListSection extends StatelessWidget {
|
||||||
var availabilityScope = AvailabilityScope.of(context);
|
var availabilityScope = AvailabilityScope.of(context);
|
||||||
var options = availabilityScope.options;
|
var options = availabilityScope.options;
|
||||||
|
|
||||||
var templateCreationButton = GestureDetector(
|
var templateCreationButton = InkWell(
|
||||||
|
hoverColor: Colors.transparent,
|
||||||
onTap: onAddTemplate,
|
onTap: onAddTemplate,
|
||||||
child: Container(
|
child: Container(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
|
@ -115,10 +116,11 @@ class _TemplateListSection extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.add),
|
const Icon(Icons.add),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
|
options.smallTextButtonBuilder(
|
||||||
|
context,
|
||||||
|
onAddTemplate,
|
||||||
Text(
|
Text(
|
||||||
createButtonText,
|
createButtonText,
|
||||||
style: textTheme.bodyLarge?.copyWith(
|
|
||||||
decoration: TextDecoration.underline,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
@ -64,10 +64,11 @@ class DefaultSecondaryButton extends StatelessWidget {
|
||||||
OutlinedButton(onPressed: onPressed, child: child);
|
OutlinedButton(onPressed: onPressed, child: child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The default big text button used in the component when no custom
|
||||||
|
/// button is provided. This button is used as a teritary button
|
||||||
|
class DefaultBigTextButton extends StatelessWidget {
|
||||||
///
|
///
|
||||||
class DefaultTextButton extends StatelessWidget {
|
const DefaultBigTextButton({
|
||||||
///
|
|
||||||
const DefaultTextButton({
|
|
||||||
required this.child,
|
required this.child,
|
||||||
required this.onPressed,
|
required this.onPressed,
|
||||||
super.key,
|
super.key,
|
||||||
|
@ -79,7 +80,7 @@ class DefaultTextButton extends StatelessWidget {
|
||||||
FutureOr<void> Function()? onPressed,
|
FutureOr<void> Function()? onPressed,
|
||||||
Widget child,
|
Widget child,
|
||||||
) =>
|
) =>
|
||||||
DefaultTextButton(
|
DefaultBigTextButton(
|
||||||
onPressed: onPressed,
|
onPressed: onPressed,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
|
@ -91,6 +92,57 @@ class DefaultTextButton extends StatelessWidget {
|
||||||
final FutureOr<void> Function()? onPressed;
|
final FutureOr<void> Function()? onPressed;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) =>
|
Widget build(BuildContext context) => TextButton(
|
||||||
TextButton(onPressed: onPressed, child: child);
|
onPressed: onPressed,
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
textStyle: const TextStyle(
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
fontSize: 16,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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
|
||||||
|
/// tertiary button
|
||||||
|
class DefaultSmallTextButton extends StatelessWidget {
|
||||||
|
///
|
||||||
|
const DefaultSmallTextButton({
|
||||||
|
required this.child,
|
||||||
|
required this.onPressed,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
///
|
||||||
|
static Widget builder(
|
||||||
|
BuildContext context,
|
||||||
|
FutureOr<void> Function()? onPressed,
|
||||||
|
Widget child,
|
||||||
|
) =>
|
||||||
|
DefaultSmallTextButton(
|
||||||
|
onPressed: onPressed,
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
|
|
||||||
|
///
|
||||||
|
final Widget child;
|
||||||
|
|
||||||
|
///
|
||||||
|
final FutureOr<void> Function()? onPressed;
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) => TextButton(
|
||||||
|
onPressed: onPressed,
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
textStyle: const TextStyle(
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
overlayColor: Colors.transparent,
|
||||||
|
backgroundColor: Colors.transparent,
|
||||||
|
),
|
||||||
|
child: child,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ class PauseSelection extends StatelessWidget {
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
),
|
),
|
||||||
child: options.textButtonBuilder(
|
child: options.bigTextButtonBuilder(
|
||||||
context,
|
context,
|
||||||
onClickAddBreak,
|
onClickAddBreak,
|
||||||
Text(translations.addButton),
|
Text(translations.addButton),
|
||||||
|
|
Loading…
Reference in a new issue