-
-
Notifications
You must be signed in to change notification settings - Fork 625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: shape and side for SlidableAction and CustomSlidableAction #255
base: master
Are you sure you want to change the base?
Changes from 1 commit
6cbcd0a
19f231e
9027c8f
c0497a3
32213d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,9 +23,11 @@ class CustomSlidableAction extends StatelessWidget { | |
this.backgroundColor = _kBackgroundColor, | ||
this.foregroundColor, | ||
this.autoClose = _kAutoClose, | ||
this.shape = const RoundedRectangleBorder(), | ||
this.side = BorderSide.none, | ||
required this.onPressed, | ||
required this.child, | ||
}) : assert(flex > 0), | ||
}) : assert(flex > 0), | ||
super(key: key); | ||
|
||
/// {@template slidable.actions.flex} | ||
|
@@ -69,14 +71,24 @@ class CustomSlidableAction extends StatelessWidget { | |
/// Typically the action's icon or label. | ||
final Widget child; | ||
|
||
/// {@template slidable.actions.shape} | ||
/// [OutlinedBorder] of action, if is null, then [RoundedRectangleBorder] | ||
/// used by default | ||
/// {@endtemplate} | ||
final OutlinedBorder shape; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
/// {@template slidable.actions.side} | ||
/// [BorderSide] of action, if is null, then [BorderSide.none] used by default | ||
/// {@endtemplate} | ||
final BorderSide side; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should make There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final effectiveForegroundColor = foregroundColor ?? | ||
(ThemeData.estimateBrightnessForColor(backgroundColor) == | ||
Brightness.light | ||
? Colors.black | ||
: Colors.white); | ||
|
||
return Expanded( | ||
flex: flex, | ||
child: SizedBox.expand( | ||
|
@@ -86,8 +98,8 @@ class CustomSlidableAction extends StatelessWidget { | |
backgroundColor: backgroundColor, | ||
primary: effectiveForegroundColor, | ||
onSurface: effectiveForegroundColor, | ||
shape: const RoundedRectangleBorder(), | ||
side: BorderSide.none, | ||
shape: shape, | ||
side: side, | ||
Arenukvern marked this conversation as resolved.
Show resolved
Hide resolved
|
||
), | ||
child: child, | ||
), | ||
|
@@ -123,6 +135,8 @@ class SlidableAction extends StatelessWidget { | |
this.icon, | ||
this.spacing = 4, | ||
this.label, | ||
this.shape = const RoundedRectangleBorder(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By following the previous comment, we dont' need to redefine them here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
this.side = BorderSide.none, | ||
}) : assert(flex > 0), | ||
assert(icon != null || label != null), | ||
super(key: key); | ||
|
@@ -153,6 +167,12 @@ class SlidableAction extends StatelessWidget { | |
/// A label to display below the [icon]. | ||
final String? label; | ||
|
||
/// {@macro slidable.actions.shape} | ||
final OutlinedBorder shape; | ||
|
||
/// {@macro slidable.actions.side} | ||
final BorderSide side; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final children = <Widget>[]; | ||
|
@@ -197,6 +217,8 @@ class SlidableAction extends StatelessWidget { | |
backgroundColor: backgroundColor, | ||
foregroundColor: foregroundColor, | ||
flex: flex, | ||
shape: shape, | ||
side: side, | ||
child: child, | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better if we let them null by default so that we can easily extend this class and keep the default values without redefining them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, fixed