diff --git a/lib/src/actions.dart b/lib/src/actions.dart index 3890de2f..226a3b14 100644 --- a/lib/src/actions.dart +++ b/lib/src/actions.dart @@ -5,9 +5,11 @@ import 'slidable.dart'; /// Signature for [CustomSlidableAction.onPressed]. typedef SlidableActionCallback = void Function(BuildContext context); -const int _kFlex = 1; -const Color _kBackgroundColor = Colors.white; -const bool _kAutoClose = true; +const _kFlex = 1; +const _kBackgroundColor = Colors.white; +const _kAutoClose = true; +const _kborderSide = BorderSide.none; +const _kshape = RoundedRectangleBorder(); /// Represents an action of an [ActionPane]. class CustomSlidableAction extends StatelessWidget { @@ -23,6 +25,8 @@ class CustomSlidableAction extends StatelessWidget { this.backgroundColor = _kBackgroundColor, this.foregroundColor, this.autoClose = _kAutoClose, + this.side, + this.shape, required this.onPressed, required this.child, }) : assert(flex > 0), @@ -69,6 +73,14 @@ class CustomSlidableAction extends StatelessWidget { /// Typically the action's icon or label. final Widget child; + /// Defaults to [BorderSide.none]. + /// {@endtemplate} + final BorderSide? side; + + /// Defaults to [RoundedRectangleBorder]. + /// {@endtemplate} + final OutlinedBorder? shape; + @override Widget build(BuildContext context) { final effectiveForegroundColor = foregroundColor ?? @@ -86,8 +98,8 @@ class CustomSlidableAction extends StatelessWidget { backgroundColor: backgroundColor, primary: effectiveForegroundColor, onSurface: effectiveForegroundColor, - shape: const RoundedRectangleBorder(), - side: BorderSide.none, + shape: shape, + side: side, ), child: child, ), @@ -123,6 +135,8 @@ class SlidableAction extends StatelessWidget { this.icon, this.spacing = 4, this.label, + this.side = _kborderSide, + this.shape = _kshape, }) : assert(flex > 0), assert(icon != null || label != null), super(key: key); @@ -133,6 +147,12 @@ class SlidableAction extends StatelessWidget { /// {@macro slidable.actions.backgroundColor} final Color backgroundColor; + /// {@macro slidable.actions.side} + final BorderSide side; + + /// {@macro slidable.actions.shape} + final OutlinedBorder shape; + /// {@macro slidable.actions.foregroundColor} final Color? foregroundColor; @@ -197,6 +217,8 @@ class SlidableAction extends StatelessWidget { backgroundColor: backgroundColor, foregroundColor: foregroundColor, flex: flex, + side: side, + shape: shape, child: child, ); } diff --git a/lib/src/slidable.dart b/lib/src/slidable.dart index 889e67a2..31697827 100644 --- a/lib/src/slidable.dart +++ b/lib/src/slidable.dart @@ -1,7 +1,6 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_slidable/src/auto_close_behavior.dart'; -import 'package:flutter_slidable/src/notifications_old.dart'; import 'action_pane_configuration.dart'; import 'controller.dart'; @@ -28,6 +27,8 @@ class Slidable extends StatefulWidget { this.dragStartBehavior = DragStartBehavior.down, this.useTextDirection = true, required this.child, + this.backgroundColor, + this.borderRadius, }) : super(key: key); /// Whether this slidable is interactive. @@ -37,6 +38,14 @@ class Slidable extends StatefulWidget { /// Defaults to true. final bool enabled; + /// Defaults to [Colors.Transparent]. + /// {@endtemplate} + final Color? backgroundColor; + + /// Defaults to [BorderRadius.zero]. + /// {@endtemplate} + final BorderRadius? borderRadius; + /// Specifies to close this [Slidable] after the closest [Scrollable]'s /// position changed. /// @@ -237,20 +246,26 @@ class _SlidableState extends State ), ); - content = Stack( - children: [ - if (actionPane != null) - Positioned.fill( - child: ClipRect( - clipper: _SlidableClipper( - axis: widget.direction, - controller: controller, + content = ClipRRect( + borderRadius: widget.borderRadius ?? BorderRadius.zero, + child: Container( + color: widget.backgroundColor, + child: Stack( + children: [ + if (actionPane != null) + Positioned.fill( + child: ClipRect( + clipper: _SlidableClipper( + axis: widget.direction, + controller: controller, + ), + child: actionPane, + ), ), - child: actionPane, - ), - ), - content, - ], + content, + ], + ), + ), ); return SlidableGestureDetector( @@ -258,9 +273,9 @@ class _SlidableState extends State controller: controller, direction: widget.direction, dragStartBehavior: widget.dragStartBehavior, - child: SlidableNotificationSender( - tag: widget.groupTag, + child: SlidableAutoCloseNotificationSender( controller: controller, + groupTag: widget.groupTag, child: SlidableScrollingBehavior( controller: controller, closeOnScroll: widget.closeOnScroll,