accept list controllers as params in ui package listviews
This commit is contained in:
@@ -89,6 +89,7 @@ class ChannelListView extends StatefulWidget {
|
|||||||
this.onMoreDetailsPressed,
|
this.onMoreDetailsPressed,
|
||||||
this.onDeletePressed,
|
this.onDeletePressed,
|
||||||
this.swipeActions,
|
this.swipeActions,
|
||||||
|
this.channelListController,
|
||||||
}) : 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
|
||||||
@@ -187,6 +188,12 @@ class ChannelListView extends StatefulWidget {
|
|||||||
/// List of actions for slidable
|
/// List of actions for slidable
|
||||||
final List<SwipeAction>? swipeActions;
|
final List<SwipeAction>? swipeActions;
|
||||||
|
|
||||||
|
/// A [ChannelListController] allows reloading and pagination.
|
||||||
|
/// Use [ChannelListController.loadData] and
|
||||||
|
/// [ChannelListController.paginateData] respectively for reloading and
|
||||||
|
/// pagination.
|
||||||
|
final ChannelListController? channelListController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ChannelListViewState createState() => _ChannelListViewState();
|
_ChannelListViewState createState() => _ChannelListViewState();
|
||||||
}
|
}
|
||||||
@@ -194,7 +201,8 @@ class ChannelListView extends StatefulWidget {
|
|||||||
class _ChannelListViewState extends State<ChannelListView> {
|
class _ChannelListViewState extends State<ChannelListView> {
|
||||||
final _slideController = SlidableController();
|
final _slideController = SlidableController();
|
||||||
|
|
||||||
final _channelListController = ChannelListController();
|
late final _channelListController =
|
||||||
|
widget.channelListController ?? ChannelListController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|||||||
@@ -172,6 +172,7 @@ class MessageListView extends StatefulWidget {
|
|||||||
this.usernameBuilder,
|
this.usernameBuilder,
|
||||||
this.showFloatingDateDivider = true,
|
this.showFloatingDateDivider = true,
|
||||||
this.threadSeparatorBuilder,
|
this.threadSeparatorBuilder,
|
||||||
|
this.messageListController,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Function used to build a custom message widget
|
/// Function used to build a custom message widget
|
||||||
@@ -296,6 +297,10 @@ class MessageListView extends StatefulWidget {
|
|||||||
/// Builder used to build the thread separator in case it's a thread view
|
/// Builder used to build the thread separator in case it's a thread view
|
||||||
final WidgetBuilder? threadSeparatorBuilder;
|
final WidgetBuilder? threadSeparatorBuilder;
|
||||||
|
|
||||||
|
/// A [MessageListController] allows pagination.
|
||||||
|
/// Use [ChannelListController.paginateData] pagination.
|
||||||
|
final MessageListController? messageListController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MessageListViewState createState() => _MessageListViewState();
|
_MessageListViewState createState() => _MessageListViewState();
|
||||||
}
|
}
|
||||||
@@ -347,7 +352,8 @@ class _MessageListViewState extends State<MessageListView> {
|
|||||||
|
|
||||||
bool _inBetweenList = false;
|
bool _inBetweenList = false;
|
||||||
|
|
||||||
final MessageListController _messageListController = MessageListController();
|
late final MessageListController _messageListController =
|
||||||
|
widget.messageListController ?? MessageListController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => MessageListCore(
|
Widget build(BuildContext context) => MessageListCore(
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class MessageSearchListView extends StatefulWidget {
|
|||||||
this.errorBuilder,
|
this.errorBuilder,
|
||||||
this.loadingBuilder,
|
this.loadingBuilder,
|
||||||
this.childBuilder,
|
this.childBuilder,
|
||||||
|
this.messageSearchListController,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
|
|
||||||
/// Message String to search on
|
/// Message String to search on
|
||||||
@@ -127,13 +128,19 @@ class MessageSearchListView extends StatefulWidget {
|
|||||||
/// The builder that will be used in case of loading
|
/// The builder that will be used in case of loading
|
||||||
final WidgetBuilder? loadingBuilder;
|
final WidgetBuilder? loadingBuilder;
|
||||||
|
|
||||||
|
/// A [MessageSearchListController] allows reloading and pagination.
|
||||||
|
/// Use [MessageSearchListController.loadData] and
|
||||||
|
/// [MessageSearchListController.paginateData] respectively for reloading and
|
||||||
|
/// pagination.
|
||||||
|
final MessageSearchListController? messageSearchListController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_MessageSearchListViewState createState() => _MessageSearchListViewState();
|
_MessageSearchListViewState createState() => _MessageSearchListViewState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _MessageSearchListViewState extends State<MessageSearchListView> {
|
class _MessageSearchListViewState extends State<MessageSearchListView> {
|
||||||
final MessageSearchListController _messageSearchListController =
|
late final MessageSearchListController _messageSearchListController =
|
||||||
MessageSearchListController();
|
widget.messageSearchListController ?? MessageSearchListController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => MessageSearchListCore(
|
Widget build(BuildContext context) => MessageSearchListCore(
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class UserListView extends StatefulWidget {
|
|||||||
this.emptyBuilder,
|
this.emptyBuilder,
|
||||||
this.loadingBuilder,
|
this.loadingBuilder,
|
||||||
this.listBuilder,
|
this.listBuilder,
|
||||||
|
this.userListController,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
crossAxisCount == 1 || groupAlphabetically == false,
|
crossAxisCount == 1 || groupAlphabetically == false,
|
||||||
'Cannot group alphabetically when crossAxisCount > 1',
|
'Cannot group alphabetically when crossAxisCount > 1',
|
||||||
@@ -140,6 +141,11 @@ class UserListView extends StatefulWidget {
|
|||||||
/// The builder used when the channel list is empty.
|
/// The builder used when the channel list is empty.
|
||||||
final WidgetBuilder? emptyBuilder;
|
final WidgetBuilder? emptyBuilder;
|
||||||
|
|
||||||
|
/// A [UserListController] allows reloading and pagination.
|
||||||
|
/// Use [UserListController.loadData] and [UserListController.paginateData]
|
||||||
|
/// respectively for reloading and pagination.
|
||||||
|
final UserListController? userListController;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_UserListViewState createState() => _UserListViewState();
|
_UserListViewState createState() => _UserListViewState();
|
||||||
}
|
}
|
||||||
@@ -148,7 +154,8 @@ class _UserListViewState extends State<UserListView>
|
|||||||
with WidgetsBindingObserver {
|
with WidgetsBindingObserver {
|
||||||
bool get _isListView => widget.crossAxisCount == 1;
|
bool get _isListView => widget.crossAxisCount == 1;
|
||||||
|
|
||||||
final UserListController _userListController = UserListController();
|
late final UserListController _userListController =
|
||||||
|
widget.userListController ?? UserListController();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user