added swipe actions list
This commit is contained in:
@@ -80,6 +80,7 @@ class ChannelListView extends StatefulWidget {
|
|||||||
this.listBuilder,
|
this.listBuilder,
|
||||||
this.onMoreDetailsPressed,
|
this.onMoreDetailsPressed,
|
||||||
this.onDeletePressed,
|
this.onDeletePressed,
|
||||||
|
this.swipeActions,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// If true a default swipe to action behaviour will be added to this widget
|
/// If true a default swipe to action behaviour will be added to this widget
|
||||||
@@ -166,6 +167,9 @@ class ChannelListView extends StatefulWidget {
|
|||||||
/// Callback used when the delete slidable option is pressed
|
/// Callback used when the delete slidable option is pressed
|
||||||
final VoidCallback? onDeletePressed;
|
final VoidCallback? onDeletePressed;
|
||||||
|
|
||||||
|
/// List of actions for slidable
|
||||||
|
final List<SwipeAction>? swipeActions;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ChannelListViewState createState() => _ChannelListViewState();
|
_ChannelListViewState createState() => _ChannelListViewState();
|
||||||
}
|
}
|
||||||
@@ -473,7 +477,14 @@ class _ChannelListViewState extends State<ChannelListView> {
|
|||||||
enabled: widget.swipeToAction,
|
enabled: widget.swipeToAction,
|
||||||
actionPane: const SlidableBehindActionPane(),
|
actionPane: const SlidableBehindActionPane(),
|
||||||
actionExtentRatio: 0.12,
|
actionExtentRatio: 0.12,
|
||||||
secondaryActions: <Widget>[
|
secondaryActions: widget.swipeActions
|
||||||
|
?.map((e) => IconSlideAction(
|
||||||
|
color: e.color,
|
||||||
|
iconWidget: e.iconWidget,
|
||||||
|
onTap: e.onTap,
|
||||||
|
))
|
||||||
|
.toList() ??
|
||||||
|
<Widget>[
|
||||||
IconSlideAction(
|
IconSlideAction(
|
||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
icon: Icons.more_horiz,
|
icon: Icons.more_horiz,
|
||||||
@@ -650,3 +661,15 @@ class _ChannelListViewState extends State<ChannelListView> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class SwipeAction {
|
||||||
|
Color? color;
|
||||||
|
Widget iconWidget;
|
||||||
|
VoidCallback? onTap;
|
||||||
|
|
||||||
|
SwipeAction({
|
||||||
|
this.color,
|
||||||
|
required this.iconWidget,
|
||||||
|
this.onTap,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user