Skip to content

Commit aa97eba

Browse files
committed
feat:✨Added a support for showing message time in message bubble. Removed enableSwipeToSeeTime(bool) & added messageTimePositionType(Enum) to FeatureActiveConfig class.(#115)
1 parent 31eedc2 commit aa97eba

17 files changed

+642
-211
lines changed

CHANGELOG.md

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,79 @@
1+
## [1.4.0] (UnReleased)
2+
3+
* **Feat**: [115](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/115) Added
4+
option for showing message sent/received time in message bubble. Removed 'enableSwipeToSeeTime'
5+
& added 'messageTimePositionType' to FeatureActiveConfig class for changing position of message
6+
time.
7+
18
## [1.3.1]
29

3-
* **Feat**: [105](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/105) Allow user
4-
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
512
configuration like height, width, image quality and preferredCameraDevice.
6-
* **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
714
chat is added to bottom while `loadMoreData` callback.
8-
* **Fix**: [109](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/109) Added
9-
support for the hiding/Un-hiding gallery and camera buttons
10-
15+
* **Fix**: [109](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/109) Added
16+
support for the hiding/Un-hiding gallery and camera buttons
17+
1118
## [1.3.0]
1219

1320
* **Feat**: [71](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/71) Added Callback
1421
when a user starts/stops composing typing a message.
1522
* **Fix**: [78](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/78) Fix issue of
1623
unmodifiable list.
17-
* **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.
1826
* **Fix**: [81](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/81) Fix issue of
1927
TypingIndicator Rebuilding ChatView.
2028
* **Fix**: [94](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/pull/94) Fixed deprecated
2129
`showRecentsTab` property with new `recentTabBehavior`.
2230
* Support for latest flutter version `3.10.5`.
23-
* Update dependencies `http` to version `1.1.0` and `image_picker` to version range `'>=0.8.9 <2.0.0'`.
24-
31+
* Update dependencies `http` to version `1.1.0` and `image_picker` to version
32+
range `'>=0.8.9 <2.0.0'`.
2533

2634
## [1.2.1]
2735

2836
* **Fix**: [60](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/60) Fix image from
2937
file is not loaded.
3038
* **Fix**: [61](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/61) Fix issue of
3139
audio message is not working.
32-
* **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
3341
when user react on message.
3442

35-
3643
## [1.2.0+1]
3744

38-
* **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
3946
get callback on tap of profile circle avatar.
4047
* **Breaking**: Add `messageType` in `onSendTap` callback for encountering messages.
4148
* **Breaking**: Remove `onRecordingComplete` and you can get Recorded audio in `onSendTap` callback
4249
with `messageType`.
4350
* **Breaking**: Remove `onImageSelected` from `ImagePickerIconsConfiguration` and can get selected
4451
image in `onSendTap` callback with `messageType`.
45-
* **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`
4654
callback for opening urls.
4755
* **Feat**: [51](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/51) Ability to
4856
get callback on long press of profile circle avatar.
4957

5058
## [1.1.0]
5159

52-
* **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
5361
enable or disable specific features.
5462
* **Feat**: [34](https://github.com/SimformSolutionsPvtLtd/flutter_chatview/issues/34) Ability to
5563
add voice message.
5664
* **Breaking**: Remove `onEmojiTap` from `ReactionPopupConfiguration`, it can be handled internally.
57-
* **Breaking**: Remove `horizontalDragToShowMessageTime` from `ChatBackgroundConfiguration` and
65+
* **Breaking**: Remove `horizontalDragToShowMessageTime` from `ChatBackgroundConfiguration` and
5866
add `enableSwipeToSeeTime` parameter with same feature in `FeatureActiveConfig`.
5967
* **Breaking**: Remove `showReceiverProfileCircle` and add `enableOtherUserProfileAvatar` parameter
6068
with same feature in `FeatureActiveConfig`.
61-
* * **Breaking**: Move `enablePagination` parameter from `ChatView` to `FeatureActiveConfig`.
69+
*
70+
* **Breaking**: Move `enablePagination` parameter from `ChatView` to `FeatureActiveConfig`.
6271

6372
## [1.0.1]
6473

65-
* **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
6675
while replying to image it highlights the link instead of the image.
67-
* **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
6877
removing reaction which is reacted accidentally.
6978

7079
## [1.0.0+1]

example/lib/data.dart

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +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(),
11-
sendBy: '1', // userId of who sends the message
33+
sendBy: '1',
34+
// userId of who sends the message
1235
status: MessageStatus.read,
36+
reaction: Reaction(
37+
reactions: ['\u{2764}', '\u{2763}', '\u{2762}', '\u{2761}'],
38+
reactedUserIds: ['2', '4', '3', '1'],
39+
),
1340
),
1441
Message(
1542
id: '2',
@@ -32,6 +59,14 @@ class Data {
3259
sendBy: '1',
3360
status: MessageStatus.read,
3461
),
62+
Message(
63+
id: '5',
64+
message:
65+
"Can you write the time and place of the meeting? Can you write the time and place of the meeting?",
66+
createdAt: DateTime.now(),
67+
sendBy: '1',
68+
status: MessageStatus.read,
69+
),
3570
Message(
3671
id: '5',
3772
message: "That's fine",
@@ -105,6 +140,14 @@ class Data {
105140
sendBy: '1',
106141
reaction: Reaction(reactions: ['\u{2764}'], reactedUserIds: ['2']),
107142
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,
108151
),
109152
Message(
110153
id: '12',
@@ -113,5 +156,30 @@ class Data {
113156
sendBy: '2',
114157
status: MessageStatus.read,
115158
),
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),
173+
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+
),
180+
createdAt: DateTime.now(),
181+
sendBy: '1',
182+
status: MessageStatus.read,
183+
),
116184
];
117185
}

example/lib/main.dart

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:ui';
2+
13
import 'package:chatview/chatview.dart';
24
import 'package:example/data.dart';
35
import 'package:example/models/theme.dart';
@@ -81,6 +83,9 @@ class _ChatScreenState extends State<ChatScreen> {
8183
featureActiveConfig: const FeatureActiveConfig(
8284
lastSeenAgoBuilderVisibility: true,
8385
receiptsBuilderVisibility: true,
86+
enableOtherUserProfileAvatar: true,
87+
enableCurrentUserProfileAvatar: true,
88+
messageTimePositionType: MessageTimePositionType.onRightSwipe,
8489
),
8590
chatViewState: ChatViewState.hasMessages,
8691
chatViewStateConfig: ChatViewStateConfiguration(
@@ -129,7 +134,7 @@ class _ChatScreenState extends State<ChatScreen> {
129134
),
130135
chatBackgroundConfig: ChatBackgroundConfiguration(
131136
messageTimeIconColor: theme.messageTimeIconColor,
132-
messageTimeTextStyle: TextStyle(color: theme.messageTimeTextColor),
137+
messageTimeTextStyle: TextStyle(color: Colors.green),
133138
defaultGroupSeparatorConfig: DefaultGroupSeparatorConfiguration(
134139
textStyle: TextStyle(
135140
color: theme.chatHeaderColor,
@@ -212,6 +217,17 @@ class _ChatScreenState extends State<ChatScreen> {
212217
backgroundColor: theme.reactionPopupColor,
213218
),
214219
messageConfig: MessageConfiguration(
220+
messageDateTimeBuilder: (date) => const Text(
221+
'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,
230+
),
215231
messageReactionConfig: MessageReactionConfiguration(
216232
backgroundColor: theme.messageReactionBackGroundColor,
217233
borderColor: theme.messageReactionBackGroundColor,
@@ -238,7 +254,7 @@ class _ChatScreenState extends State<ChatScreen> {
238254
),
239255
),
240256
imageMessageConfig: ImageMessageConfiguration(
241-
margin: const EdgeInsets.symmetric(horizontal: 12, vertical: 15),
257+
margin: const EdgeInsets.fromLTRB(12, 0, 12, 15),
242258
shareIconConfig: ShareIconConfiguration(
243259
defaultIconBackgroundColor: theme.shareIconBackgroundColor,
244260
defaultIconColor: theme.shareIconColor,

lib/src/models/feature_active_config.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import 'package:chatview/chatview.dart';
2+
13
class FeatureActiveConfig {
24
const FeatureActiveConfig({
35
this.enableSwipeToReply = true,
46
this.enableReactionPopup = true,
57
this.enableTextField = true,
6-
this.enableSwipeToSeeTime = true,
78
this.enableCurrentUserProfileAvatar = false,
89
this.enableOtherUserProfileAvatar = true,
910
this.enableReplySnackBar = true,
@@ -12,8 +13,8 @@ class FeatureActiveConfig {
1213
this.enableDoubleTapToLike = true,
1314
this.lastSeenAgoBuilderVisibility = true,
1415
this.receiptsBuilderVisibility = true,
15-
});
16-
16+
this.messageTimePositionType = MessageTimePositionType.onRightSwipe,
17+
}) ;
1718
/// Used for enable/disable swipe to reply.
1819
final bool enableSwipeToReply;
1920

@@ -23,9 +24,6 @@ class FeatureActiveConfig {
2324
/// Used for enable/disable text field.
2425
final bool enableTextField;
2526

26-
/// Used for enable/disable swipe whole chat to see message created time.
27-
final bool enableSwipeToSeeTime;
28-
2927
/// Used for enable/disable current user profile circle.
3028
final bool enableCurrentUserProfileAvatar;
3129

@@ -49,4 +47,8 @@ class FeatureActiveConfig {
4947

5048
/// Controls the visibility of the message [receiptsBuilder]
5149
final bool receiptsBuilderVisibility;
50+
51+
/// Controls the Position of message created time.
52+
/// default value: onRightSwipe
53+
final MessageTimePositionType messageTimePositionType;
5254
}

lib/src/models/message_configuration.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
* SOFTWARE.
2121
*/
22-
import 'package:chatview/src/models/models.dart';
22+
import 'package:chatview/chatview.dart';
2323
import 'package:chatview/src/models/voice_message_configuration.dart';
2424
import 'package:flutter/material.dart';
2525

26+
2627
class MessageConfiguration {
2728
/// Provides configuration of image message appearance.
2829
final ImageMessageConfiguration? imageMessageConfig;
@@ -39,11 +40,19 @@ class MessageConfiguration {
3940
/// Configurations for voice message bubble
4041
final VoiceMessageConfiguration? voiceMessageConfig;
4142

43+
/// Allow user to set custom formatting of message time.
44+
final MessageDateTimeBuilder? messageDateTimeBuilder;
45+
46+
/// Used to give text style of message's time of a chat bubble
47+
final TextStyle? messageTimeTextStyle;
48+
4249
const MessageConfiguration({
4350
this.imageMessageConfig,
4451
this.messageReactionConfig,
4552
this.emojiMessageConfig,
4653
this.customMessageBuilder,
4754
this.voiceMessageConfig,
55+
this.messageDateTimeBuilder,
56+
this.messageTimeTextStyle,
4857
});
4958
}

lib/src/values/enumaration.dart

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum MessageType {
3030
custom
3131
}
3232

33-
/// Events, Wheter the user is still typing a message or has
33+
/// Events, Whether the user is still typing a message or has
3434
/// typed the message
3535
enum TypeWriterStatus { typing, typed }
3636

@@ -52,3 +52,30 @@ extension ChatViewStateExtension on ChatViewState {
5252

5353
bool get noMessages => this == ChatViewState.noData;
5454
}
55+
56+
enum MessageTimePositionType {
57+
/// Used for viewing the message created time inside the chatBubble.
58+
insideChatBubble,
59+
60+
/// Used for viewing the message created time outside the chatBubble.
61+
outsideChatBubbleAtBottom,
62+
63+
/// Used for enable/disable swipe whole chat to see message created time.
64+
onRightSwipe,
65+
66+
/// Used for viewing the message created time outside the chatBubble.
67+
outsideChatBubbleAtTop,
68+
69+
/// Used for disabling the viewing of the message created time.
70+
disable;
71+
72+
bool get isInsideChatBubble => this == insideChatBubble;
73+
74+
bool get isOutSideChatBubbleAtBottom => this == outsideChatBubbleAtBottom;
75+
76+
bool get isOnRightSwipe => this == onRightSwipe;
77+
78+
bool get isOutSideChatBubbleAtTop => this == outsideChatBubbleAtTop;
79+
80+
bool get isDisable => this == disable;
81+
}

lib/src/values/typedefs.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ typedef VoidCallBackWithFuture = Future<void> Function();
3535
typedef StringsCallBack = void Function(String emoji, String messageId);
3636
typedef StringWithReturnWidget = Widget Function(String separator);
3737
typedef DragUpdateDetailsCallback = void Function(DragUpdateDetails);
38+
typedef MessageDateTimeBuilder = Widget Function(DateTime date);

0 commit comments

Comments
 (0)