-
Notifications
You must be signed in to change notification settings - Fork 307
/
typedefs.dart
362 lines (315 loc) · 11.2 KB
/
typedefs.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/src/message_input/attachment_button.dart';
import 'package:stream_chat_flutter/src/message_input/command_button.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
/// {@template inProgressBuilder}
/// A widget builder for representing in-progress attachment uploads.
/// {@endtemplate}
typedef InProgressBuilder = Widget Function(BuildContext, int, int);
/// {@template failedBuilder}
/// A widget builder for representing failed attachment uploads.
/// {@endtemplate}
typedef FailedBuilder = Widget Function(BuildContext, String);
/// {@template successBuilder}
/// A widget builder for representing successful attachment uploads.
/// {@endtemplate}
typedef SuccessBuilder = WidgetBuilder;
/// {@template preparingBuilder}
/// A widget builder for representing pre-upload attachment state.
/// {@endtemplate}
typedef PreparingBuilder = WidgetBuilder;
/// {@template onAttachmentTap}
/// The action to perform when the attachment is tapped or clicked.
/// {@endtemplate}
typedef OnAttachmentTap = VoidCallback;
/// {@template showMessageCallback}
/// The action to perform when "show message" is tapped
/// {@endtemplate}
typedef ShowMessageCallback = void Function(Message message, Channel channel);
/// {@template showMessageCallback}
/// The action to perform when "reply message" is tapped
/// {@endtemplate}
typedef ReplyMessageCallback = void Function(Message message);
/// {@template onImageGroupAttachmentTap}
/// The action to perform when a specific image attachment in an [ImageGroup]
/// is tapped or clicked.
/// {@endtemplate}
typedef OnImageGroupAttachmentTap = void Function(
Message message,
Attachment attachment,
);
/// {@template onUserAvatarPress}
/// The action to perform when a user's avatar is tapped, clicked, or
/// long-pressed.
/// {@endtemplate}
typedef OnUserAvatarPress = void Function(User);
/// {@template placeholderUserImage}
/// A widget builder that will build placeholder user images while loading a
/// user image.
/// {@endtemplate}
typedef PlaceholderUserImage = Widget Function(BuildContext, User);
/// {@template editMessageInputBuilder}
/// A widget builder for building a pre-populated [MessageInput] for use in
/// editing messages.
/// {@endtemplate}
typedef EditMessageInputBuilder = Widget Function(BuildContext, Message);
/// {@template channelListHeaderTitleBuilder}
/// A widget builder for custom [ChannelListHeader] title widgets.
/// {@endtemplate}
typedef ChannelListHeaderTitleBuilder = Widget Function(
BuildContext context,
ConnectionStatus status,
StreamChatClient client,
);
/// {@template channelTapCallback}
/// The action to perform when a channel is tapped or clicked.
/// {@endtemplate}
typedef ChannelTapCallback = void Function(Channel, Widget?);
/// {@template channelInfoCallback}
/// The action to perform when a particular channel slidable option is tapped
/// or clicked.
/// {@endtemplate}
typedef ChannelInfoCallback = void Function(Channel);
/// {@template viewInfoCallback}
/// Callback for when 'View Info' is tapped
/// {@endtemplate}
typedef ViewInfoCallback = void Function(Channel);
/// {@template attachmentActionsBuilder}
/// A widget builder for representing the actions a user can take on an
/// attachment.
///
/// [defaultActionsModal] is the default [AttachmentActionsModal] configuration.
/// Use [defaultActionsModal.copyWith] to easily customize it
/// {@endtemplate}
typedef AttachmentActionsBuilder = Widget Function(
BuildContext context,
Attachment attachment,
AttachmentActionsModal defaultActionsModal,
);
/// {@template errorListener}
/// A callback that can be passed to [StreamMessageInput.onError].
///
/// This callback should not throw.
///
/// It exists merely for error reporting, and should not be used otherwise.
/// {@endtemplate}
typedef ErrorListener = void Function(
Object error,
StackTrace? stackTrace,
);
/// {@template attachmentLimitExceededListener}
/// A callback that can be passed to
/// [StreamMessageInput.onAttachmentLimitExceed].
///
/// This callback should not throw.
///
/// It exists merely for showing custom error, and should not be used otherwise.
/// {@endtemplate}
typedef AttachmentLimitExceedListener = void Function(
int limit,
String error,
);
/// {@template attachmentThumbnailBuilder}
/// A widget builder for representing attachment thumbnails.
/// {@endtemplate}
typedef AttachmentThumbnailBuilder = Widget Function(
BuildContext,
Attachment,
);
/// {@template mentionTileBuilder}
/// A widget builder for representing a custom mention tile.
/// {@endtemplate}
typedef MentionTileBuilder = Widget Function(
BuildContext context,
Member member,
);
/// {@template mentionTileOverlayBuilder}
/// A widget builder for representing a custom mention tile within a
/// [UserMentionsOverlay].
/// {@endtemplate}
typedef MentionTileOverlayBuilder = Widget Function(
BuildContext context,
User user,
);
/// {@template userMentionTileBuilder}
/// A builder function for representing a custom user mention tile.
///
/// Use [UserMentionTile] for the default implementation.
/// {@endtemplate}
typedef UserMentionTileBuilder = Widget Function(
BuildContext context,
User user,
);
/// {@template actionButtonBuilder}
/// A widget builder for building a custom command button.
///
/// [commandButton] is the default [CommandButton] configuration,
/// use [commandButton.copyWith] to easily customize it.
/// {@endtemplate}
typedef CommandButtonBuilder = Widget Function(
BuildContext context,
CommandButton commandButton,
);
/// {@template actionButtonBuilder}
/// A widget builder for building a custom action button.
///
/// [attachmentButton] is the default [AttachmentButton] configuration,
/// use [attachmentButton.copyWith] to easily customize it.
/// {@endtemplate}
typedef AttachmentButtonBuilder = Widget Function(
BuildContext context,
AttachmentButton attachmentButton,
);
/// {@template quotedMessageAttachmentThumbnailBuilder}
/// A widget builder for building a custom quoted message attachment thumbnail.
/// {@endtemplate}
typedef QuotedMessageAttachmentThumbnailBuilder = Widget Function(
BuildContext,
Attachment,
);
/// {@template attachmentBuilder}
/// A widget builder for representing attachments.
/// {@endtemplate}
typedef AttachmentBuilder = Widget Function(
BuildContext,
Message,
List<Attachment>,
);
/// {@template onQuotedMessageTap}
/// The action to perform when a quoted message is tapped.
/// {@endtemplate}
typedef OnQuotedMessageTap = void Function(String?);
/// {@template onMessageTap}
/// The action to perform when a message is tapped.
/// {@endtemplate}
typedef OnMessageTap = void Function(Message);
/// {@template onReactionsTap}
/// The action to perform when a message's reactions are tapped.
/// {@endtemplate}
typedef OnReactionsTap = void Function(Message);
/// {@template onReactionsHover}
/// The action to perform when a message's reactions are hovered.
/// {@endtemplate}
// ignore: avoid_positional_boolean_parameters
typedef OnReactionsHover = void Function(bool isHovering);
/// {@template messageSearchItemTapCallback}
/// The action to perform when tapping or clicking on a user in a
/// [MessageSearchListView].
/// {@endtemplate}
typedef MessageSearchItemTapCallback = void Function(GetMessageResponse);
/// {@template messageSearchItemBuilder}
/// A widget builder used to create a custom [ListUserItem] from a [User].
/// {@endtemplate}
typedef MessageSearchItemBuilder = Widget Function(
BuildContext,
GetMessageResponse,
);
/// {@template messageBuilder}
/// A widget builder for creating custom message UI.
///
/// [defaultMessageWidget] is the default [StreamMessageWidget] configuration.
/// Use [defaultMessageWidget.copyWith] to customize it.
/// {@endtemplate}
typedef MessageBuilder = Widget Function(
BuildContext,
MessageDetails,
List<Message>,
StreamMessageWidget defaultMessageWidget,
);
/// {@template parentMessageBuilder}
/// A widget builder for creating custom parent message UI.
///
/// [defaultMessageWidget] is the default [StreamMessageWidget] configuration.
/// Use [defaultMessageWidget.copyWith] to customize it.
/// {@endtemplate}
typedef ParentMessageBuilder = Widget Function(
BuildContext,
Message?,
StreamMessageWidget defaultMessageWidget,
);
/// {@template systemMessageBuilder}
/// A widget builder for creating custom system messages.
/// {@endtemplate}
typedef SystemMessageBuilder = Widget Function(
BuildContext,
Message,
);
/// {@template ephemeralMessageBuilder}
/// A widget builder for creating custom ephemeral messages.
/// {@endtemplate}
typedef EphemeralMessageBuilder = Widget Function(
BuildContext,
Message,
);
/// {@template threadBuilder}
/// A widget builder for creating custom thread UI.
/// {@endtemplate}
typedef ThreadBuilder = Widget Function(BuildContext context, Message? parent);
/// {@template threadTapCallback}
/// The action to perform when threads are tapped.
/// {@endtemplate}
typedef ThreadTapCallback = void Function(Message, Widget?);
/// {@template spacingWidgetBuilder}
/// A widget builder for creating certain spacing after widgets.
///
/// This spacing can be in the form of any widgets you like.
///
/// A List of [SpacingType] is provided to help inform the decision of
/// what to build after the message (thread, difference in time between
/// current and last message, default spacing, etc).
///
/// Example:
/// ```dart
/// MessageListView(
/// spacingWidgetBuilder: (context, list) {
/// if(list.contains(SpacingType.defaultSpacing)) {
/// return SizedBox(height: 2.0,);
/// } else {
/// return SizedBox(height: 8.0,);
/// }
/// },
/// ),
/// ```dart
/// {@endtemplate}
typedef SpacingWidgetBuilder = Widget Function(
BuildContext context,
List<SpacingType> spacingTypes,
);
/// {@template attachmentDownloader}
/// A callback for downloading an attachment asset.
/// {@endtemplate}
/// Callback to download an attachment asset
typedef AttachmentDownloader = Future<String> Function(
Attachment attachment, {
ProgressCallback? onReceiveProgress,
Map<String, dynamic>? queryParameters,
CancelToken? cancelToken,
bool deleteOnError,
Options? options,
});
/// Callback to receive the path once the attachment asset is downloaded
typedef DownloadedPathCallback = void Function(String? path);
/// {@template userTapCallback}
/// Callback called when tapping on a user
/// {@endtemplate}
typedef UserTapCallback = void Function(User, Widget?);
/// {@template rawKeyEventPredicate}
/// Callback called to react to a key event
/// {@endtemplate}
typedef KeyEventPredicate = bool Function(FocusNode, KeyEvent);
/// {@template userItemBuilder}
/// Builder used to create a custom [ListUserItem] from a [User]
/// {@endtemplate}
// ignore: avoid_positional_boolean_parameters
typedef UserItemBuilder = Widget Function(BuildContext, User, bool);
/// The action to perform when the "scroll to bottom" button is pressed
/// within a [MessageListView].
typedef OnScrollToBottom = Function(int unreadCount);
/// Widget builder for widgets that may require data from the
/// [MessageInputController].
typedef MessageRelatedBuilder = Widget Function(
BuildContext context,
StreamMessageInputController messageInputController,
);
/// A function that returns true if the message is valid and can be sent.
typedef MessageValidator = bool Function(Message message);