Skip to content

Commit 1e7b83e

Browse files
committed
feat: ✨ Add support for plus icon and action items in chat text field
1 parent 180c0d0 commit 1e7b83e

File tree

5 files changed

+277
-46
lines changed

5 files changed

+277
-46
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
## [2.4.2] (unreleased)
22

3+
* **Feat**: [318](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/318)
4+
Provide support for action items on the chat text field. Also, provide a way to add plus/attach
5+
button to open the overlay for action items.
36
* **Fix**: [303](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/303)
47
Hit ENTER button on PC keyboard, then send out message immediately
58
* **Fix**: [289](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/289)

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class _ChatScreenState extends State<ChatScreen> {
4343
_chatController = ChatController(
4444
initialMessageList: Data.messageList,
4545
scrollController: ScrollController(),
46-
currentUser: ChatUser(
46+
currentUser: const ChatUser(
4747
id: '1',
4848
name: 'Flutter',
4949
profilePhoto: Data.profileImage,

lib/src/models/config_models/send_message_configuration.dart

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
*/
2222

2323
import 'package:audio_waveforms/audio_waveforms.dart';
24+
import 'package:chatview_utils/chatview_utils.dart';
2425
import 'package:flutter/material.dart';
2526
import 'package:flutter/services.dart';
26-
import 'package:chatview_utils/chatview_utils.dart';
2727
import 'package:image_picker/image_picker.dart';
2828

29+
import '../../values/enumeration.dart';
2930
import '../../values/typedefs.dart';
3031

3132
class SendMessageConfiguration {
@@ -168,6 +169,21 @@ class TextFieldConfiguration {
168169
/// Default is [true].
169170
final bool enabled;
170171

172+
/// List of action items to show in the text field
173+
final List<ActionItems> actionItems;
174+
175+
/// Color of plus icon in text field
176+
final Color? plusIconColor;
177+
178+
/// Icon to show in the text field for plus/attach action
179+
final Icon? plusIcon;
180+
181+
/// List of options to show in the plus/attach modal sheet
182+
final List<ActionWidget> actionWidgetList;
183+
184+
/// Callback when plus icon is pressed
185+
final VoidCallBack? onPressedPlusIcon;
186+
171187
const TextFieldConfiguration({
172188
this.contentPadding,
173189
this.maxLines,
@@ -184,6 +200,27 @@ class TextFieldConfiguration {
184200
this.inputFormatters,
185201
this.textCapitalization,
186202
this.enabled = true,
203+
this.actionItems = const [
204+
ActionItems.camera,
205+
ActionItems.gallery,
206+
],
207+
this.plusIcon,
208+
this.plusIconColor,
209+
this.actionWidgetList = const [],
210+
this.onPressedPlusIcon,
211+
});
212+
}
213+
214+
/// Represents a widget that can be used in the plus/attach modal sheet.
215+
class ActionWidget {
216+
final Widget icon;
217+
final String label;
218+
final VoidCallBack onTap;
219+
220+
const ActionWidget({
221+
required this.icon,
222+
required this.label,
223+
required this.onTap,
187224
});
188225
}
189226

lib/src/values/enumeration.dart

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222

2323
// Different types Message of ChatView
2424

25-
import 'package:flutter/material.dart';
2625
import 'package:chatview_utils/chatview_utils.dart';
26+
import 'package:flutter/material.dart';
2727

2828
enum ShowReceiptsIn { all, lastMessage }
2929

@@ -73,3 +73,16 @@ enum SuggestionItemsType {
7373

7474
bool get isMultilineType => this == SuggestionItemsType.multiline;
7575
}
76+
77+
/// Represents the type of action items in the chat view text field.
78+
enum ActionItems {
79+
camera,
80+
gallery,
81+
plus;
82+
83+
bool get isCamera => this == ActionItems.camera;
84+
85+
bool get isGallery => this == ActionItems.gallery;
86+
87+
bool get isPlus => this == ActionItems.plus;
88+
}

0 commit comments

Comments
 (0)