Skip to content

Commit

Permalink
rename another typo at InComing and also change to typing
Browse files Browse the repository at this point in the history
  • Loading branch information
lcsvcn committed Nov 19, 2024
1 parent 574876b commit fcd7f1a
Show file tree
Hide file tree
Showing 12 changed files with 353 additions and 425 deletions.
353 changes: 203 additions & 150 deletions README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class _ChatScreenState extends State<ChatScreen> {
),
onReloadButtonTap: () {},
),
typeIndicatorConfig: TypeIndicatorConfiguration(
typingIndicatorConfig: TypingIndicatorConfiguration(
flashingCircleBrightColor: theme.flashingCircleBrightColor,
flashingCircleDarkColor: theme.flashingCircleDarkColor,
),
Expand Down Expand Up @@ -206,7 +206,7 @@ class _ChatScreenState extends State<ChatScreen> {
),
),
chatBubbleConfig: ChatBubbleConfiguration(
outgoingChatBubbleConfig: ChatBubble(
outgoingChatBubble: ChatBubble(
linkPreviewConfig: LinkPreviewConfiguration(
backgroundColor: theme.linkPreviewOutgoingChatColor,
bodyStyle: theme.outgoingChatLinkBodyStyle,
Expand All @@ -215,7 +215,7 @@ class _ChatScreenState extends State<ChatScreen> {
receiptsWidgetConfig: const ReceiptsWidgetConfig(showReceiptsIn: ShowReceiptsIn.all),
color: theme.outgoingChatBubbleColor,
),
inComingChatBubbleConfig: ChatBubble(
incomingChatBubble: ChatBubble(
linkPreviewConfig: LinkPreviewConfiguration(
linkStyle: TextStyle(
color: theme.inComingChatBubbleTextColor,
Expand Down
11 changes: 5 additions & 6 deletions lib/src/inherited_widgets/configurations_inherited_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ConfigurationsInheritedWidget extends InheritedWidget {
this.profileCircleConfig,
this.swipeToReplyConfig,
this.repliedMessageConfig,
this.typeIndicatorConfig,
this.typingIndicatorConfig,
this.replyPopupConfig,
this.emojiPickerSheetConfig,
this.scrollToBottomButtonConfig,
Expand Down Expand Up @@ -43,7 +43,7 @@ class ConfigurationsInheritedWidget extends InheritedWidget {
final RepliedMessageConfiguration? repliedMessageConfig;

/// Provides configuration of typing indicator's appearance.
final TypeIndicatorConfiguration? typeIndicatorConfig;
final TypingIndicatorConfiguration? typingIndicatorConfig;

/// Provides configuration for reply snack bar's appearance and options.
final ReplyPopupConfiguration? replyPopupConfig;
Expand All @@ -54,10 +54,9 @@ class ConfigurationsInheritedWidget extends InheritedWidget {
/// Provides a configuration for scroll to bottom button config
final ScrollToBottomButtonConfig? scrollToBottomButtonConfig;

static ConfigurationsInheritedWidget? of(BuildContext context) => context
.dependOnInheritedWidgetOfExactType<ConfigurationsInheritedWidget>();
static ConfigurationsInheritedWidget? of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<ConfigurationsInheritedWidget>();

@override
bool updateShouldNotify(covariant ConfigurationsInheritedWidget oldWidget) =>
oldWidget != this;
bool updateShouldNotify(covariant ConfigurationsInheritedWidget oldWidget) => oldWidget != this;
}
8 changes: 4 additions & 4 deletions lib/src/models/config_models/chat_bubble_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ class ChatBubbleConfiguration {
final Duration? longPressAnimationDuration;

/// Provides configuration of other users message's chat bubble.
final ChatBubble? inComingChatBubbleConfig;
final ChatBubble? incomingChatBubble;

/// Provides configuration of current user message's chat bubble.
final ChatBubble? outgoingChatBubbleConfig;
final ChatBubble? outgoingChatBubble;

/// Provides callback when user tap twice on chat bubble.
final MessageCallBack? onDoubleTap;
Expand All @@ -54,8 +54,8 @@ class ChatBubbleConfiguration {
this.margin,
this.maxWidth,
this.longPressAnimationDuration,
this.inComingChatBubbleConfig,
this.outgoingChatBubbleConfig,
this.incomingChatBubble,
this.outgoingChatBubble,
this.onDoubleTap,
this.receiptsWidgetConfig,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
import 'package:flutter/material.dart';

class TypeIndicatorConfiguration {
class TypingIndicatorConfiguration {
/// Used for giving typing indicator size.
final double? indicatorSize;

Expand All @@ -34,7 +34,7 @@ class TypeIndicatorConfiguration {
/// Used to give color of light circle dots.
final Color? flashingCircleBrightColor;

const TypeIndicatorConfiguration({
const TypingIndicatorConfiguration({
this.indicatorSize,
this.indicatorSpacing,
this.flashingCircleDarkColor,
Expand Down
96 changes: 31 additions & 65 deletions lib/src/widgets/chat_bubble_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {

bool get isMessageBySender => widget.message.sentBy == currentUser?.id;

bool get isLastMessage =>
chatController?.initialMessageList.last.id == widget.message.id;
bool get isLastMessage => chatController?.initialMessageList.last.id == widget.message.id;

FeatureActiveConfig? featureActiveConfig;
ChatController? chatController;
Expand Down Expand Up @@ -123,19 +122,16 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
margin: chatBubbleConfig?.margin ?? const EdgeInsets.only(bottom: 10),
child: Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment:
isMessageBySender ? MainAxisAlignment.end : MainAxisAlignment.start,
mainAxisAlignment: isMessageBySender ? MainAxisAlignment.end : MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
if (!isMessageBySender &&
(featureActiveConfig?.enableOtherUserProfileAvatar ?? true))
if (!isMessageBySender && (featureActiveConfig?.enableOtherUserProfileAvatar ?? true))
profileCircle(messagedUser),
Expanded(
child: _messagesWidgetColumn(messagedUser),
),
if (isMessageBySender) ...[getReceipt()],
if (isMessageBySender &&
(featureActiveConfig?.enableCurrentUserProfileAvatar ?? true))
if (isMessageBySender && (featureActiveConfig?.enableCurrentUserProfileAvatar ?? true))
profileCircle(messagedUser),
],
),
Expand All @@ -152,8 +148,7 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
imageUrl: messagedUser?.profilePhoto,
imageType: messagedUser?.imageType,
defaultAvatarImage: messagedUser?.defaultAvatarImage ?? profileImage,
networkImageProgressIndicatorBuilder:
messagedUser?.networkImageProgressIndicatorBuilder,
networkImageProgressIndicatorBuilder: messagedUser?.networkImageProgressIndicatorBuilder,
assetImageErrorBuilder: messagedUser?.assetImageErrorBuilder,
networkImageErrorBuilder: messagedUser?.networkImageErrorBuilder,
circleRadius: profileCircleConfig?.circleRadius,
Expand All @@ -164,49 +159,39 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {

void onRightSwipe() {
if (maxDuration != null) {
widget.message.voiceMessageDuration =
Duration(milliseconds: maxDuration!);
widget.message.voiceMessageDuration = Duration(milliseconds: maxDuration!);
}
if (chatListConfig.swipeToReplyConfig?.onRightSwipe != null) {
chatListConfig.swipeToReplyConfig?.onRightSwipe!(
widget.message.message, widget.message.sentBy);
chatListConfig.swipeToReplyConfig?.onRightSwipe!(widget.message.message, widget.message.sentBy);
}
widget.onSwipe(widget.message);
}

void onLeftSwipe() {
if (maxDuration != null) {
widget.message.voiceMessageDuration =
Duration(milliseconds: maxDuration!);
widget.message.voiceMessageDuration = Duration(milliseconds: maxDuration!);
}
if (chatListConfig.swipeToReplyConfig?.onLeftSwipe != null) {
chatListConfig.swipeToReplyConfig?.onLeftSwipe!(
widget.message.message, widget.message.sentBy);
chatListConfig.swipeToReplyConfig?.onLeftSwipe!(widget.message.message, widget.message.sentBy);
}
widget.onSwipe(widget.message);
}

void _onAvatarTap(ChatUser? user) {
if (chatListConfig.profileCircleConfig?.onAvatarTap != null &&
user != null) {
if (chatListConfig.profileCircleConfig?.onAvatarTap != null && user != null) {
chatListConfig.profileCircleConfig?.onAvatarTap!(user);
}
}

Widget getReceipt() {
final showReceipts = chatListConfig.chatBubbleConfig
?.outgoingChatBubbleConfig?.receiptsWidgetConfig?.showReceiptsIn ??
final showReceipts = chatListConfig.chatBubbleConfig?.outgoingChatBubble?.receiptsWidgetConfig?.showReceiptsIn ??
ShowReceiptsIn.lastMessage;
if (showReceipts == ShowReceiptsIn.all) {
return ValueListenableBuilder(
valueListenable: widget.message.statusNotifier,
builder: (context, value, child) {
if (ChatViewInheritedWidget.of(context)
?.featureActiveConfig
.receiptsBuilderVisibility ??
true) {
return chatListConfig.chatBubbleConfig?.outgoingChatBubbleConfig
?.receiptsWidgetConfig?.receiptsBuilder
if (ChatViewInheritedWidget.of(context)?.featureActiveConfig.receiptsBuilderVisibility ?? true) {
return chatListConfig.chatBubbleConfig?.outgoingChatBubble?.receiptsWidgetConfig?.receiptsBuilder
?.call(value) ??
sendMessageAnimationBuilder(value);
}
Expand All @@ -215,15 +200,10 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
);
} else if (showReceipts == ShowReceiptsIn.lastMessage && isLastMessage) {
return ValueListenableBuilder(
valueListenable:
chatController!.initialMessageList.last.statusNotifier,
valueListenable: chatController!.initialMessageList.last.statusNotifier,
builder: (context, value, child) {
if (ChatViewInheritedWidget.of(context)
?.featureActiveConfig
.receiptsBuilderVisibility ??
true) {
return chatListConfig.chatBubbleConfig?.outgoingChatBubbleConfig
?.receiptsWidgetConfig?.receiptsBuilder
if (ChatViewInheritedWidget.of(context)?.featureActiveConfig.receiptsBuilderVisibility ?? true) {
return chatListConfig.chatBubbleConfig?.outgoingChatBubble?.receiptsWidgetConfig?.receiptsBuilder
?.call(value) ??
sendMessageAnimationBuilder(value);
}
Expand All @@ -234,59 +214,48 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
}

void _onAvatarLongPress(ChatUser? user) {
if (chatListConfig.profileCircleConfig?.onAvatarLongPress != null &&
user != null) {
if (chatListConfig.profileCircleConfig?.onAvatarLongPress != null && user != null) {
chatListConfig.profileCircleConfig?.onAvatarLongPress!(user);
}
}

Widget _messagesWidgetColumn(ChatUser? messagedUser) {
return Column(
crossAxisAlignment:
isMessageBySender ? CrossAxisAlignment.end : CrossAxisAlignment.start,
crossAxisAlignment: isMessageBySender ? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: [
if ((chatController?.otherUsers.isNotEmpty ?? false) &&
!isMessageBySender &&
(featureActiveConfig?.enableOtherUserName ?? true))
Padding(
padding: chatListConfig
.chatBubbleConfig?.inComingChatBubbleConfig?.padding ??
padding: chatListConfig.chatBubbleConfig?.incomingChatBubble?.padding ??
const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
child: Text(
messagedUser?.name ?? '',
style: chatListConfig.chatBubbleConfig?.inComingChatBubbleConfig
?.senderNameTextStyle,
style: chatListConfig.chatBubbleConfig?.incomingChatBubble?.senderNameTextStyle,
),
),
if (replyMessage.isNotEmpty)
chatListConfig.repliedMessageConfig?.repliedMessageWidgetBuilder !=
null
? chatListConfig.repliedMessageConfig!
.repliedMessageWidgetBuilder!(widget.message.replyMessage)
chatListConfig.repliedMessageConfig?.repliedMessageWidgetBuilder != null
? chatListConfig.repliedMessageConfig!.repliedMessageWidgetBuilder!(widget.message.replyMessage)
: ReplyMessageWidget(
message: widget.message,
repliedMessageConfig: chatListConfig.repliedMessageConfig,
onTap: () => widget.onReplyTap
?.call(widget.message.replyMessage.messageId),
onTap: () => widget.onReplyTap?.call(widget.message.replyMessage.messageId),
),
SwipeToReply(
isMessageByCurrentUser: isMessageBySender,
onSwipe: isMessageBySender ? onLeftSwipe : onRightSwipe,
child: MessageView(
outgoingChatBubbleConfig:
chatListConfig.chatBubbleConfig?.outgoingChatBubbleConfig,
isLongPressEnable:
(featureActiveConfig?.enableReactionPopup ?? true) ||
(featureActiveConfig?.enableReplySnackBar ?? true),
inComingChatBubbleConfig:
chatListConfig.chatBubbleConfig?.inComingChatBubbleConfig,
outgoingChatBubble: chatListConfig.chatBubbleConfig?.outgoingChatBubble,
isLongPressEnable: (featureActiveConfig?.enableReactionPopup ?? true) ||
(featureActiveConfig?.enableReplySnackBar ?? true),
incomingChatBubble: chatListConfig.chatBubbleConfig?.incomingChatBubble,
message: widget.message,
isMessageBySender: isMessageBySender,
messageConfig: chatListConfig.messageConfig,
onLongPress: widget.onLongPress,
chatBubbleMaxWidth: chatListConfig.chatBubbleConfig?.maxWidth,
longPressAnimationDuration:
chatListConfig.chatBubbleConfig?.longPressAnimationDuration,
longPressAnimationDuration: chatListConfig.chatBubbleConfig?.longPressAnimationDuration,
onDoubleTap: featureActiveConfig?.enableDoubleTapToLike ?? false
? chatListConfig.chatBubbleConfig?.onDoubleTap ??
(message) => currentUser != null
Expand All @@ -299,12 +268,9 @@ class _ChatBubbleWidgetState extends State<ChatBubbleWidget> {
: null,
shouldHighlight: widget.shouldHighlight,
controller: chatController,
highlightColor: chatListConfig.repliedMessageConfig
?.repliedMsgAutoScrollConfig.highlightColor ??
Colors.grey,
highlightScale: chatListConfig.repliedMessageConfig
?.repliedMsgAutoScrollConfig.highlightScale ??
1.1,
highlightColor:
chatListConfig.repliedMessageConfig?.repliedMsgAutoScrollConfig.highlightColor ?? Colors.grey,
highlightScale: chatListConfig.repliedMessageConfig?.repliedMsgAutoScrollConfig.highlightScale ?? 1.1,
onMaxDuration: _onMaxDuration,
),
),
Expand Down
Loading

0 comments on commit fcd7f1a

Please sign in to comment.