-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathsend_message_configuration.dart
More file actions
337 lines (263 loc) · 10.1 KB
/
Copy pathsend_message_configuration.dart
File metadata and controls
337 lines (263 loc) · 10.1 KB
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
/*
* Copyright (c) 2022 Simform Solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
import 'package:audio_waveforms/audio_waveforms.dart';
import 'package:chatview_utils/chatview_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:image_picker/image_picker.dart';
import '../../values/typedefs.dart';
class SendMessageConfiguration {
const SendMessageConfiguration({
this.textFieldConfig,
this.textFieldBackgroundColor,
this.imagePickerIconsConfig,
this.imagePickerConfiguration,
this.defaultSendButtonColor,
this.sendButtonIcon,
this.replyDialogColor,
this.replyTitleColor,
this.replyMessageColor,
this.closeIconColor,
this.allowRecordingVoice = true,
this.enableCameraImagePicker = true,
this.enableGalleryImagePicker = true,
this.voiceRecordingConfiguration,
this.micIconColor,
this.cancelRecordConfiguration,
this.shouldSendImageWithText = false,
this.removeImageIcon,
this.removeImageIconColor,
this.removeImageIconSize,
this.selectedImageMargin,
this.selectedImageViewHeight,
this.imageBorderRadius,
this.selectedImageViewBuilder,
this.trailing, // <--- ADDED THIS LINE
});
/// Used to give background color to text field.
final Color? textFieldBackgroundColor;
/// Used to give color to send button.
final Color? defaultSendButtonColor;
/// Provides ability to give custom send button.
final Widget? sendButtonIcon;
/// Used to give reply dialog color.
final Color? replyDialogColor;
/// Used to give color to title of reply pop-up.
final Color? replyTitleColor;
/// Used to give color to reply message.
final Color? replyMessageColor;
/// Used to give color to close icon in reply pop-up.
final Color? closeIconColor;
/// Provides configuration of image picker functionality.
final ImagePickerIconsConfiguration? imagePickerIconsConfig;
/// Provides configuration of image picker plugin.
final ImagePickerConfiguration? imagePickerConfiguration;
/// Provides configuration of text field.
final TextFieldConfiguration? textFieldConfig;
/// Enable/disable voice recording. Enabled by default.
final bool allowRecordingVoice;
/// Enable/disable image picker from gallery. Enabled by default.
final bool enableGalleryImagePicker;
/// Enable/disable send image from camera. Enabled by default.
final bool enableCameraImagePicker;
/// Color of mic icon when replying to some voice message.
final Color? micIconColor;
/// Styling configuration for recorder widget.
final VoiceRecordingConfiguration? voiceRecordingConfiguration;
/// Configuration for cancel voice recording
final CancelRecordConfiguration? cancelRecordConfiguration;
/// If true, then image will be sent with text message.
final bool shouldSendImageWithText;
/// Icon to remove image from text field.
final Widget? removeImageIcon;
/// Color of remove image icon.
final Color? removeImageIconColor;
/// Size of remove image icon.
final double? removeImageIconSize;
/// Margin around selected image in text field.
final EdgeInsets? selectedImageMargin;
/// Height of selected image view in text field.
final double? selectedImageViewHeight;
/// Border radius of selected image in text field.
final double? imageBorderRadius;
/// Provides ability to build custom view for selected images in text field.
final SelectedImageViewBuilder? selectedImageViewBuilder;
/// Provides list of widgets that will be placed at the trailing end
/// of the text input field, typically used for custom action buttons.
final List<Widget>? trailing; // <--- ADDED THIS FIELD
}
class ImagePickerIconsConfiguration {
const ImagePickerIconsConfiguration({
this.cameraIconColor,
this.galleryIconColor,
this.galleryImagePickerIcon,
this.cameraImagePickerIcon,
});
/// Provides ability to pass custom gallery image picker icon.
final Widget? galleryImagePickerIcon;
/// Provides ability to pass custom camera image picker icon.
final Widget? cameraImagePickerIcon;
/// Used to give color to camera icon.
final Color? cameraIconColor;
/// Used to give color to gallery icon.
final Color? galleryIconColor;
}
class TextFieldConfiguration {
const TextFieldConfiguration({
this.contentPadding,
this.maxLines,
this.borderRadius,
this.hintText,
this.hintStyle,
this.textStyle,
this.padding,
this.margin,
this.minLines,
this.textInputType,
this.onMessageTyping,
this.compositionThresholdTime = const Duration(seconds: 1),
this.inputFormatters,
this.textCapitalization,
this.enabled = true,
this.height,
});
/// Used to give max lines in text field.
final int? maxLines;
/// Used to give min lines in text field.
final int? minLines;
/// Used to give padding in text field.
final EdgeInsetsGeometry? padding;
/// Used to give margin in text field.
final EdgeInsetsGeometry? margin;
/// Used to give hint text in text field.
final String? hintText;
/// Used to give text style of hint text in text field.
final TextStyle? hintStyle;
/// Used to give text style of actual text in text field.
final TextStyle? textStyle;
/// Used to give border radius in text field.
final BorderRadius? borderRadius;
/// Used to give content padding in text field.
final EdgeInsetsGeometry? contentPadding;
/// Used to give text input type of text field.
final TextInputType? textInputType;
/// Used to give list of input formatters for text field.
final List<TextInputFormatter>? inputFormatters;
/// Used to give textCapitalization enums to text field.
final TextCapitalization? textCapitalization;
/// Callback when a user starts/stops typing a message by [TypeWriterStatus]
final ValueSetter<TypeWriterStatus>? onMessageTyping;
/// After typing stopped, the threshold time after which the composing
/// status to be changed to [TypeWriterStatus.composed].
/// Default is 1 second.
final Duration compositionThresholdTime;
/// Used for enable or disable the chat text field.
/// [false] also will disable the buttons for send images, record audio or take picture.
/// Default is [true].
final bool enabled;
/// Used to give height of text field.
final double? height;
}
class ImagePickerConfiguration {
const ImagePickerConfiguration({
this.maxWidth,
this.maxHeight,
this.imageQuality,
this.preferredCameraDevice,
this.onImagePicked,
});
/// Used to give max width of image.
final double? maxWidth;
/// Used to give max height of image.
final double? maxHeight;
/// Used to give image quality.
final int? imageQuality;
/// Preferred camera device to pick image from.
final CameraDevice? preferredCameraDevice;
/// Callback when image is picked from camera or gallery,
/// we can perform our task on image like adding crop options and return new image path
final ImagePickedCallback? onImagePicked;
}
class VoiceRecordingConfiguration {
/// Styling configuration for the recorder widget as well as
/// configuring the audio recording quality.
const VoiceRecordingConfiguration({
this.waveStyle,
this.padding,
this.margin,
this.decoration,
this.backgroundColor,
this.micIcon,
this.recorderIconColor,
this.stopIcon,
this.sampleRate,
this.bitRate,
this.androidEncoder,
this.iosEncoder,
this.androidOutputFormat,
});
/// Applies styles to waveform.
final WaveStyle? waveStyle;
/// Applies padding around waveform widget.
final EdgeInsets? padding;
/// Applies margin around waveform widget.
final EdgeInsets? margin;
/// Box decoration containing waveforms
final BoxDecoration? decoration;
/// If only background color needs to be changed then use this instead of
/// decoration.
final Color? backgroundColor;
/// An icon for recording voice.
final Widget? micIcon;
/// An icon for stopping voice recording.
final Widget? stopIcon;
/// Applies color to mic and stop icon.
final Color? recorderIconColor;
/// The sample rate for audio is measured in samples per second.
/// A higher sample rate generates more samples per second,
/// resulting in better audio quality but also larger file sizes.
final int? sampleRate;
/// Bitrate is the amount of data per second that the codec uses to
/// encode the audio. A higher bitrate results in better quality
/// but also larger file sizes.
final int? bitRate;
/// Audio encoder to be used for recording for IOS.
final IosEncoder? iosEncoder;
/// Audio encoder to be used for recording for Android.
final AndroidEncoder? androidEncoder;
/// The audio output format to be used for recorded audio files on Android.
final AndroidOutputFormat? androidOutputFormat;
}
class CancelRecordConfiguration {
/// Configuration for cancel voice recording
const CancelRecordConfiguration({
this.icon,
this.iconColor,
this.onCancel,
});
/// An icon for cancelling voice recording.
final Widget? icon;
/// Cancel record icon color
final Color? iconColor;
/// Provides callback on voice record cancel
final VoidCallback? onCancel;
}