Skip to content

Commit 9f9abde

Browse files
committed
feat:✨Handled message time for types of messages
1 parent ce3d40a commit 9f9abde

13 files changed

+311
-124
lines changed

CHANGELOG.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,78 @@
22

33
* **Feat**: [115](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/115) Added
44
option for showing message sent/received time in message bubble. Removed 'enableSwipeToSeeTime'
5-
& added 'showMessageTimeIn' from FeatureActiveConfig class for the visibility of message time.
5+
& added 'messageTimePositionType' to FeatureActiveConfig class for changing position of message
6+
time.
67

78
## [1.3.1]
89

9-
* **Feat**: [105](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/105) Allow user
10-
to get callback when image is picked so user can perform operation like crop. Allow user to pass
10+
* **Feat**: [105](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/105) Allow user
11+
to get callback when image is picked so user can perform operation like crop. Allow user to pass
1112
configuration like height, width, image quality and preferredCameraDevice.
12-
* **Fix**: [95](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/95) Fix issue of
13+
* **Fix**: [95](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/95) Fix issue of
1314
chat is added to bottom while `loadMoreData` callback.
14-
* **Fix**: [109](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/109) Added
15-
support for the hiding/Un-hiding gallery and camera buttons
16-
15+
* **Fix**: [109](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/109) Added
16+
support for the hiding/Un-hiding gallery and camera buttons
17+
1718
## [1.3.0]
1819

1920
* **Feat**: [71](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/71) Added Callback
2021
when a user starts/stops composing typing a message.
2122
* **Fix**: [78](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/78) Fix issue of
2223
unmodifiable list.
23-
* **Feat**: [76](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/76) Message Receipts.
24+
* **Feat**: [76](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/76) Message
25+
Receipts.
2426
* **Fix**: [81](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/81) Fix issue of
2527
TypingIndicator Rebuilding ChatView.
2628
* **Fix**: [94](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/94) Fixed deprecated
2729
`showRecentsTab` property with new `recentTabBehavior`.
2830
* Support for latest flutter version `3.10.5`.
29-
* Update dependencies `http` to version `1.1.0` and `image_picker` to version range `'>=0.8.9 <2.0.0'`.
30-
31+
* Update dependencies `http` to version `1.1.0` and `image_picker` to version
32+
range `'>=0.8.9 <2.0.0'`.
3133

3234
## [1.2.1]
3335

3436
* **Fix**: [60](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/60) Fix image from
3537
file is not loaded.
3638
* **Fix**: [61](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/61) Fix issue of
3739
audio message is not working.
38-
* **Feat**: [65](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/65) Add callback
40+
* **Feat**: [65](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/65) Add callback
3941
when user react on message.
4042

41-
4243
## [1.2.0+1]
4344

44-
* **Feat**: [42](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/42) Ability to
45+
* **Feat**: [42](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/42) Ability to
4546
get callback on tap of profile circle avatar.
4647
* **Breaking**: Add `messageType` in `onSendTap` callback for encountering messages.
4748
* **Breaking**: Remove `onRecordingComplete` and you can get Recorded audio in `onSendTap` callback
4849
with `messageType`.
4950
* **Breaking**: Remove `onImageSelected` from `ImagePickerIconsConfiguration` and can get selected
5051
image in `onSendTap` callback with `messageType`.
51-
* **Feat**: [49](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/49) Add `onUrlDetect`
52+
* **Feat**: [49](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/49)
53+
Add `onUrlDetect`
5254
callback for opening urls.
5355
* **Feat**: [51](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/51) Ability to
5456
get callback on long press of profile circle avatar.
5557

5658
## [1.1.0]
5759

58-
* **Feat**: [37](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/37) Ability to
60+
* **Feat**: [37](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/37) Ability to
5961
enable or disable specific features.
6062
* **Feat**: [34](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/34) Ability to
6163
add voice message.
6264
* **Breaking**: Remove `onEmojiTap` from `ReactionPopupConfiguration`, it can be handled internally.
63-
* **Breaking**: Remove `horizontalDragToShowMessageTime` from `ChatBackgroundConfiguration` and
65+
* **Breaking**: Remove `horizontalDragToShowMessageTime` from `ChatBackgroundConfiguration` and
6466
add `enableSwipeToSeeTime` parameter with same feature in `FeatureActiveConfig`.
6567
* **Breaking**: Remove `showReceiverProfileCircle` and add `enableOtherUserProfileAvatar` parameter
6668
with same feature in `FeatureActiveConfig`.
67-
* * **Breaking**: Move `enablePagination` parameter from `ChatView` to `FeatureActiveConfig`.
69+
*
70+
* **Breaking**: Move `enablePagination` parameter from `ChatView` to `FeatureActiveConfig`.
6871

6972
## [1.0.1]
7073

71-
* **Fix**: [32](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/32) Fix issue of
74+
* **Fix**: [32](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/32) Fix issue of
7275
while replying to image it highlights the link instead of the image.
73-
* **Fix**: [35](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/35) Fix issue of
76+
* **Fix**: [35](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/35) Fix issue of
7477
removing reaction which is reacted accidentally.
7578

7679
## [1.0.0+1]

example/lib/data.dart

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,39 @@ class Data {
44
static const profileImage =
55
"https://raw.githubusercontent.com/SimformSolutionsPvtLtd/flutter_showcaseview/master/example/assets/simform.png";
66
static final messageList = [
7+
Message(
8+
id: '58',
9+
message: "https://bit.ly/3JHS2Wl",
10+
createdAt: DateTime.now(),
11+
sendBy: '2',
12+
reaction: Reaction(
13+
reactions: ['\u{2764}', '\u{1F44D}', '\u{1F44D}'],
14+
reactedUserIds: ['2', '3', '4'],
15+
),
16+
status: MessageStatus.read,
17+
),
18+
Message(
19+
id: '88',
20+
message: "https://bit.ly/3JHS2Wl",
21+
createdAt: DateTime.now(),
22+
sendBy: '1',
23+
reaction: Reaction(
24+
reactions: ['\u{2764}', '\u{1F44D}', '\u{1F44D}'],
25+
reactedUserIds: ['2', '3', '4'],
26+
),
27+
status: MessageStatus.read,
28+
),
729
Message(
830
id: '1',
931
message: "Hi!",
1032
createdAt: DateTime.now(),
1133
sendBy: '1',
1234
// userId of who sends the message
1335
status: MessageStatus.read,
36+
reaction: Reaction(
37+
reactions: ['\u{2764}', '\u{2763}', '\u{2762}', '\u{2761}'],
38+
reactedUserIds: ['2', '4', '3', '1'],
39+
),
1440
),
1541
Message(
1642
id: '2',
@@ -114,6 +140,14 @@ class Data {
114140
sendBy: '1',
115141
reaction: Reaction(reactions: ['\u{2764}'], reactedUserIds: ['2']),
116142
status: MessageStatus.read,
143+
), Message(
144+
id: '1321',
145+
message: "https://miro.medium.com/max/1000/0*s7of7kWnf9fDg4XM.jpeg",
146+
createdAt: DateTime.now(),
147+
messageType: MessageType.image,
148+
sendBy: '2',
149+
reaction: Reaction(reactions: ['\u{2764}'], reactedUserIds: ['2']),
150+
status: MessageStatus.read,
117151
),
118152
Message(
119153
id: '12',
@@ -122,20 +156,30 @@ class Data {
122156
sendBy: '2',
123157
status: MessageStatus.read,
124158
),
159+
// Message(
160+
// id: '13',
161+
// message: "",
162+
// createdAt: DateTime.now(),
163+
// sendBy: '2',
164+
// status: MessageStatus.read,
165+
// messageType: MessageType.voice),
166+
// Message(
167+
// id: '14',
168+
// message: "",
169+
// createdAt: DateTime.now(),
170+
// sendBy: '1',
171+
// status: MessageStatus.read,
172+
// messageType: MessageType.voice),
125173
Message(
126-
id: '13',
127-
message: "",
128-
createdAt: DateTime.now(),
129-
sendBy: '2',
130-
status: MessageStatus.read,
131-
messageType: MessageType.voice
132-
),Message(
133-
id: '14',
134-
message: "",
174+
id: '94',
175+
message: "messageMe",
176+
reaction: Reaction(
177+
reactions: ['\u{2764}', '\u{2761}', '\u{2763}', '\u{2762}'],
178+
reactedUserIds: ['2', '4', '3', '1'],
179+
),
135180
createdAt: DateTime.now(),
136181
sendBy: '1',
137182
status: MessageStatus.read,
138-
messageType: MessageType.voice
139183
),
140184
];
141185
}

example/lib/main.dart

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class _ChatScreenState extends State<ChatScreen> {
8383
featureActiveConfig: const FeatureActiveConfig(
8484
lastSeenAgoBuilderVisibility: true,
8585
receiptsBuilderVisibility: true,
86-
messageTimePositionType: MessageTimePositionType.insideChatBubble,
86+
enableOtherUserProfileAvatar: true,
87+
enableCurrentUserProfileAvatar: true,
88+
messageTimePositionType: MessageTimePositionType.onRightSwipe,
8789
),
8890
chatViewState: ChatViewState.hasMessages,
8991
chatViewStateConfig: ChatViewStateConfiguration(
@@ -132,7 +134,7 @@ class _ChatScreenState extends State<ChatScreen> {
132134
),
133135
chatBackgroundConfig: ChatBackgroundConfiguration(
134136
messageTimeIconColor: theme.messageTimeIconColor,
135-
messageTimeTextStyle: TextStyle(color: theme.messageTimeTextColor),
137+
messageTimeTextStyle: TextStyle(color: Colors.green),
136138
defaultGroupSeparatorConfig: DefaultGroupSeparatorConfiguration(
137139
textStyle: TextStyle(
138140
color: theme.chatHeaderColor,
@@ -215,8 +217,16 @@ class _ChatScreenState extends State<ChatScreen> {
215217
backgroundColor: theme.reactionPopupColor,
216218
),
217219
messageConfig: MessageConfiguration(
218-
messageDateTimeBuilder: (date) => Text(
220+
messageDateTimeBuilder: (date) => const Text(
219221
'7:34 PM',
222+
style: TextStyle(
223+
color: Colors.black,
224+
),
225+
),
226+
messageTimeTextStyle: const TextStyle(
227+
color: Colors.green,
228+
fontWeight: FontWeight.bold,
229+
fontSize: 18,
220230
),
221231
messageReactionConfig: MessageReactionConfiguration(
222232
backgroundColor: theme.messageReactionBackGroundColor,
@@ -244,7 +254,7 @@ class _ChatScreenState extends State<ChatScreen> {
244254
),
245255
),
246256
imageMessageConfig: ImageMessageConfiguration(
247-
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 15),
257+
margin: const EdgeInsets.fromLTRB(12, 0, 12, 15),
248258
shareIconConfig: ShareIconConfiguration(
249259
defaultIconBackgroundColor: theme.shareIconBackgroundColor,
250260
defaultIconColor: theme.shareIconColor,

lib/src/models/message_configuration.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ class MessageConfiguration {
4343
/// Allow user to set custom formatting of message time.
4444
final MessageDateTimeBuilder? messageDateTimeBuilder;
4545

46+
/// Used to give text style of message's time of a chat bubble
47+
final TextStyle? messageTimeTextStyle;
48+
4649
const MessageConfiguration({
4750
this.imageMessageConfig,
4851
this.messageReactionConfig,
4952
this.emojiMessageConfig,
5053
this.customMessageBuilder,
5154
this.voiceMessageConfig,
5255
this.messageDateTimeBuilder,
56+
this.messageTimeTextStyle,
5357
});
5458
}

lib/src/values/enumaration.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,26 @@ extension ChatViewStateExtension on ChatViewState {
5656
enum MessageTimePositionType {
5757
/// Used for viewing the message created time inside the chatBubble.
5858
insideChatBubble,
59+
5960
/// Used for viewing the message created time outside the chatBubble.
60-
outsideChatBubble,
61+
outsideChatBubbleAtBottom,
62+
6163
/// Used for enable/disable swipe whole chat to see message created time.
6264
onRightSwipe,
65+
66+
/// Used for viewing the message created time outside the chatBubble.
67+
outsideChatBubbleAtTop,
68+
6369
/// Used for disabling the viewing of the message created time.
6470
disable;
6571

6672
bool get isInsideChatBubble => this == insideChatBubble;
6773

68-
bool get isOutSideChatBubble => this == outsideChatBubble;
74+
bool get isOutSideChatBubbleAtBottom => this == outsideChatBubbleAtBottom;
6975

7076
bool get isOnRightSwipe => this == onRightSwipe;
7177

78+
bool get isOutSideChatBubbleAtTop => this == outsideChatBubbleAtTop;
79+
7280
bool get isDisable => this == disable;
7381
}

lib/src/widgets/chat_bubble_widget.dart

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
127127
final messagedUser = chatController?.getUserFromId(widget.message.sendBy);
128128
return Stack(
129129
children: [
130-
if (featureActiveConfig?.messageTimePositionType.isOnRightSwipe ?? true) ...[
130+
if (featureActiveConfig?.messageTimePositionType.isOnRightSwipe ??
131+
true) ...[
131132
Visibility(
132133
visible: widget.slideAnimation?.value.dx == 0.0 ? false : true,
133134
child: Positioned.fill(
@@ -299,15 +300,36 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
299300
crossAxisAlignment:
300301
isMessageBySender ? CrossAxisAlignment.end : CrossAxisAlignment.start,
301302
children: [
302-
if ((chatController?.chatUsers.length ?? 0) > 1 && !isMessageBySender)
303+
if ((chatController?.chatUsers.length ?? 0) > 1)
303304
Padding(
304305
padding:
305306
widget.chatBubbleConfig?.inComingChatBubbleConfig?.padding ??
306307
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
307-
child: Text(
308-
messagedUser?.name ?? '',
309-
style: widget.chatBubbleConfig?.inComingChatBubbleConfig
310-
?.senderNameTextStyle,
308+
child: Row(
309+
mainAxisAlignment: isMessageBySender
310+
? MainAxisAlignment.end
311+
: MainAxisAlignment.start,
312+
children: [
313+
if (!isMessageBySender)
314+
Text(
315+
messagedUser?.name ?? '',
316+
style: widget.chatBubbleConfig?.inComingChatBubbleConfig
317+
?.senderNameTextStyle,
318+
),
319+
if (featureActiveConfig
320+
?.messageTimePositionType.isOutSideChatBubbleAtTop ??
321+
false) ...[
322+
const SizedBox(width: 4),
323+
widget.messageConfig?.messageDateTimeBuilder
324+
?.call(widget.message.createdAt) ??
325+
MessageTimeWidget(
326+
isCurrentUser: isMessageBySender,
327+
messageTime: widget.message.createdAt,
328+
messageTimeTextStyle:
329+
widget.messageConfig?.messageTimeTextStyle,
330+
),
331+
]
332+
],
311333
),
312334
),
313335
if (replyMessage.isNotEmpty)
@@ -354,6 +376,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
354376
?.repliedMsgAutoScrollConfig.highlightScale ??
355377
1.1,
356378
onMaxDuration: _onMaxDuration,
379+
profileCircleConfig: profileCircleConfig,
357380
),
358381
],
359382
);

0 commit comments

Comments
 (0)