feat: Added new docs
This commit is contained in:
@@ -2,4 +2,75 @@
|
||||
id: channels_bloc
|
||||
sidebar_position: 7
|
||||
title: Channels Bloc
|
||||
---
|
||||
---
|
||||
|
||||
`ChannelsBloc` is a widget dedicated to the management of a channel list with pagination.
|
||||
`ChannelsBloc` is used together with `ChannelListCore` to manage a list of
|
||||
Channels with pagination, re-ordering, querying and other operations
|
||||
associated with Channels.
|
||||
|
||||
`ChannelsBloc` can be accessed at anytime by using the static of method
|
||||
using Flutter's `BuildContext`.
|
||||
|
||||
```dart
|
||||
var _channelsBloc = ChannelsBloc.of(context);
|
||||
```
|
||||
|
||||
The `ChannelsBloc` widget encapsulates common functionality related to channel lists such as fetching
|
||||
the existing channels and querying new channels and also supplies them down the widget tree.
|
||||
|
||||
The widget is required for the respective core widget (`ChannelListCore`) to fetch channels and hence
|
||||
must be above the core widget in the tree.
|
||||
|
||||
Here is a basic implementation of `ChannelsBloc`:
|
||||
|
||||
```dart
|
||||
ChannelsBloc(
|
||||
child: // Further Widget Tree
|
||||
),
|
||||
```
|
||||
|
||||
The `ChannelsBloc` widget allows three customisations:
|
||||
|
||||
#### Lock Channels Order
|
||||
|
||||
ChannelsBloc may change the order of channels when new messages arrive. To lock this order, we can
|
||||
set the `lockChannelsOrder` property to true.
|
||||
|
||||
```dart
|
||||
ChannelsBloc(
|
||||
lockChannelsOrder: true,
|
||||
child: // Further Widget Tree
|
||||
),
|
||||
```
|
||||
|
||||
#### Set custom channel order
|
||||
|
||||
We can decide the order of the channels in the list by supplying a comparator to the `channelsComparator`
|
||||
parameter:
|
||||
|
||||
```dart
|
||||
ChannelsBloc(
|
||||
channelsComparator: (a, b) {
|
||||
return a.createdAt!.millisecondsSinceEpoch >
|
||||
b.createdAt!.millisecondsSinceEpoch
|
||||
? 1
|
||||
: -1;
|
||||
},
|
||||
child: // Further Widget Tree
|
||||
),
|
||||
```
|
||||
|
||||
#### Decide if channel should be added on new message event
|
||||
|
||||
When a new message arrives, a `message.new` event is created. We can decide if we want to add the channel
|
||||
to the list using the `shouldAddChannel` parameter which is a callback supplying the event data:
|
||||
|
||||
```dart
|
||||
ChannelsBloc(
|
||||
shouldAddChannel: (event) {
|
||||
return event.message!.extraData['priority'] == '1';
|
||||
},
|
||||
child: // Further Widget Tree
|
||||
),
|
||||
```
|
||||
@@ -2,4 +2,45 @@
|
||||
id: introduction
|
||||
sidebar_position: 1
|
||||
title: Introduction
|
||||
---
|
||||
---
|
||||
|
||||
This package provides business logic to fetch common things required for integrating Stream Chat into your application.
|
||||
The core package allows more customisation and hence provides business logic but no UI components.
|
||||
Please use the stream_chat_flutter package for the full fledged suite of UI components or stream_chat for the low-level client.
|
||||
|
||||
The package primarily contains three types of classes:
|
||||
|
||||
* Business Logic Components
|
||||
* Core Components
|
||||
* Core Controllers
|
||||
|
||||
### Business Logic Components
|
||||
|
||||
These components allow you to have the maximum and lower-level control of the queries being executed.
|
||||
|
||||
The BLoCs we provide are:
|
||||
|
||||
* ChannelsBloc
|
||||
* MessageSearchBloc
|
||||
* UsersBloc
|
||||
|
||||
### Core Components
|
||||
|
||||
Core components usually are an easy way to fetch data associated with Stream Chat which are decoupled from UI and often expose UI builders. Data fetching can be controlled with the controllers of the respective core components.
|
||||
|
||||
* ChannelListCore (Fetch a list of channels)
|
||||
* MessageListCore (Fetch a list of messages from a channel)
|
||||
* MessageSearchListCore (Fetch a list of search messages)
|
||||
* UserListCore (Fetch a list of users)
|
||||
* StreamChatCore (This is different from the other core components - it is a version of StreamChat decoupled from theme and initialisations.)
|
||||
|
||||
### Core Controllers
|
||||
|
||||
Core Controllers are supplied to respective CoreList widgets which allows reloading and pagination of data whenever needed.
|
||||
|
||||
* ChannelListController
|
||||
* MessageListController
|
||||
* MessageSearchListController
|
||||
* ChannelListController
|
||||
|
||||
This section goes into the individual core package widgets and their functional use.
|
||||
@@ -2,4 +2,25 @@
|
||||
id: message_search_list_block
|
||||
sidebar_position: 8
|
||||
title: Message Search List Bloc
|
||||
---
|
||||
---
|
||||
|
||||
`MessageSearchBloc` is used to manage a list of messages with pagination.
|
||||
This class can be used to load messages, perform queries, etc.
|
||||
|
||||
`MessageSearchBloc` can be accessed at anytime by using the static of method
|
||||
using Flutter's BuildContext.
|
||||
|
||||
```dart
|
||||
var _searchBloc = MessageSearchBloc.of(context);
|
||||
```
|
||||
|
||||
The `MessageSearchBloc` widget encapsulates common functionality related to searching for messages
|
||||
across channels and also supplies them down the widget tree.
|
||||
|
||||
Here is a basic implementation of `ChannelsBloc`:
|
||||
|
||||
```dart
|
||||
MessageSearchBloc(
|
||||
child: // Further Widget Tree
|
||||
),
|
||||
```
|
||||
@@ -2,4 +2,24 @@
|
||||
id: users_bloc
|
||||
sidebar_position: 9
|
||||
title: Users Bloc
|
||||
---
|
||||
---
|
||||
|
||||
Widget dedicated to the management of a users list with pagination.
|
||||
|
||||
`UsersBloc` can be accessed at anytime by using the static of method
|
||||
using Flutter's `BuildContext`.
|
||||
|
||||
```dart
|
||||
var _userBloc_ = UsersBloc.of(context);
|
||||
```
|
||||
|
||||
The `UsersBloc` widget encapsulates common functionality related to searching for users
|
||||
and also supplies them down the widget tree.
|
||||
|
||||
Here is a basic implementation of `UsersBloc`:
|
||||
|
||||
```dart
|
||||
UsersBloc(
|
||||
child: // Further Widget Tree
|
||||
),
|
||||
```
|
||||
Reference in New Issue
Block a user