Skip to content

Commit

Permalink
Merge pull request #278 from johnstef99/master
Browse files Browse the repository at this point in the history
Add custom padding and border radius to SlidableAction
  • Loading branch information
letsar authored May 22, 2022
2 parents b3e80b6 + b71fe8a commit 9035955
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lib/src/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class CustomSlidableAction extends StatelessWidget {
this.backgroundColor = _kBackgroundColor,
this.foregroundColor,
this.autoClose = _kAutoClose,
this.borderRadius = BorderRadius.zero,
this.padding,
required this.onPressed,
required this.child,
}) : assert(flex > 0),
Expand Down Expand Up @@ -66,6 +68,18 @@ class CustomSlidableAction extends StatelessWidget {
/// {@endtemplate}
final SlidableActionCallback? onPressed;

/// {@template slidable.actions.borderRadius}
/// The borderRadius of this action
///
/// Defaults to [BorderRadius.zero].
/// {@endtemplate}
final BorderRadius borderRadius;

/// {@template slidable.actions.padding}
/// The padding of the OutlinedButton
/// {@endtemplate}
final EdgeInsets? padding;

/// Typically the action's icon or label.
final Widget child;

Expand All @@ -83,10 +97,13 @@ class CustomSlidableAction extends StatelessWidget {
child: OutlinedButton(
onPressed: () => _handleTap(context),
style: OutlinedButton.styleFrom(
padding: padding,
backgroundColor: backgroundColor,
primary: effectiveForegroundColor,
onSurface: effectiveForegroundColor,
shape: const RoundedRectangleBorder(),
shape: RoundedRectangleBorder(
borderRadius: borderRadius,
),
side: BorderSide.none,
),
child: child,
Expand Down Expand Up @@ -123,6 +140,8 @@ class SlidableAction extends StatelessWidget {
this.icon,
this.spacing = 4,
this.label,
this.borderRadius = BorderRadius.zero,
this.padding,
}) : assert(flex > 0),
assert(icon != null || label != null),
super(key: key);
Expand Down Expand Up @@ -153,6 +172,12 @@ class SlidableAction extends StatelessWidget {
/// A label to display below the [icon].
final String? label;

/// Padding of the OutlinedButton
final BorderRadius borderRadius;

/// Padding of the OutlinedButton
final EdgeInsets? padding;

@override
Widget build(BuildContext context) {
final children = <Widget>[];
Expand Down Expand Up @@ -192,6 +217,8 @@ class SlidableAction extends StatelessWidget {
);

return CustomSlidableAction(
borderRadius: borderRadius,
padding: padding,
onPressed: onPressed,
autoClose: autoClose,
backgroundColor: backgroundColor,
Expand Down

0 comments on commit 9035955

Please sign in to comment.