Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"explorer.excludeGitIgnore": true
}
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -342,7 +342,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -361,7 +361,7 @@
DEVELOPMENT_TEAM = KX234MPD84;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down Expand Up @@ -421,7 +421,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -470,7 +470,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand All @@ -490,7 +490,7 @@
DEVELOPMENT_TEAM = KX234MPD84;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -514,7 +514,7 @@
DEVELOPMENT_TEAM = KX234MPD84;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
31 changes: 12 additions & 19 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class Example extends StatelessWidget {
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: const Color(0xffEE5366),
colorScheme:
ColorScheme.fromSwatch(accentColor: const Color(0xffEE5366)),
colorScheme: ColorScheme.fromSwatch(accentColor: const Color(0xffEE5366)),
),
home: const ChatScreen(),
);
Expand Down Expand Up @@ -123,8 +122,8 @@ class _ChatScreenState extends State<ChatScreen> {
flashingCircleDarkColor: theme.flashingCircleDarkColor,
),
appBar: ChatViewAppBar(
elevation: theme.elevation,
backGroundColor: theme.appBarColor,
elevation: theme.elevation!,
backgroundColor: theme.appBarColor!,
profilePicture: Data.profileImage,
backArrowColor: theme.backArrowColor,
chatTitle: "Chat view",
Expand All @@ -135,14 +134,13 @@ class _ChatScreenState extends State<ChatScreen> {
letterSpacing: 0.25,
),
userStatus: "online",
centerTitle: false,
userStatusTextStyle: const TextStyle(color: Colors.grey),
actions: [
IconButton(
onPressed: _onThemeIconTap,
icon: Icon(
isDarkTheme
? Icons.brightness_4_outlined
: Icons.dark_mode_outlined,
isDarkTheme ? Icons.brightness_4_outlined : Icons.dark_mode_outlined,
color: theme.themeIconColor,
),
),
Expand Down Expand Up @@ -187,6 +185,7 @@ class _ChatScreenState extends State<ChatScreen> {
textFieldBackgroundColor: theme.textFieldBackgroundColor,
closeIconColor: theme.closeIconColor,
textFieldConfig: TextFieldConfiguration(
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
onMessageTyping: (status) {
/// Do with status
debugPrint(status.toString());
Expand All @@ -212,8 +211,7 @@ class _ChatScreenState extends State<ChatScreen> {
bodyStyle: theme.outgoingChatLinkBodyStyle,
titleStyle: theme.outgoingChatLinkTitleStyle,
),
receiptsWidgetConfig:
const ReceiptsWidgetConfig(showReceiptsIn: ShowReceiptsIn.all),
receiptsWidgetConfig: const ReceiptsWidgetConfig(showReceiptsIn: ShowReceiptsIn.all),
color: theme.outgoingChatBubbleColor,
),
inComingChatBubbleConfig: ChatBubble(
Expand All @@ -231,8 +229,7 @@ class _ChatScreenState extends State<ChatScreen> {
/// send your message reciepts to the other client
debugPrint('Message Read');
},
senderNameTextStyle:
TextStyle(color: theme.inComingChatBubbleTextColor),
senderNameTextStyle: TextStyle(color: theme.inComingChatBubbleTextColor),
color: theme.inComingChatBubbleColor,
),
),
Expand All @@ -252,10 +249,8 @@ class _ChatScreenState extends State<ChatScreen> {
messageReactionConfig: MessageReactionConfiguration(
backgroundColor: theme.messageReactionBackGroundColor,
borderColor: theme.messageReactionBackGroundColor,
reactedUserCountTextStyle:
TextStyle(color: theme.inComingChatBubbleTextColor),
reactionCountTextStyle:
TextStyle(color: theme.inComingChatBubbleTextColor),
reactedUserCountTextStyle: TextStyle(color: theme.inComingChatBubbleTextColor),
reactionCountTextStyle: TextStyle(color: theme.inComingChatBubbleTextColor),
reactionsBottomSheetConfig: ReactionsBottomSheetConfiguration(
backgroundColor: theme.backgroundColor,
reactedUserTextStyle: TextStyle(
Expand Down Expand Up @@ -316,8 +311,7 @@ class _ChatScreenState extends State<ChatScreen> {
color: isDarkTheme ? Colors.white : Colors.black,
),
),
onTap: (item) =>
_onSendTap(item.text, const ReplyMessage(), MessageType.text),
onTap: (item) => _onSendTap(item.text, const ReplyMessage(), MessageType.text),
),
),
);
Expand All @@ -339,8 +333,7 @@ class _ChatScreenState extends State<ChatScreen> {
),
);
Future.delayed(const Duration(milliseconds: 300), () {
_chatController.initialMessageList.last.setStatus =
MessageStatus.undelivered;
_chatController.initialMessageList.last.setStatus = MessageStatus.undelivered;
});
Future.delayed(const Duration(seconds: 1), () {
_chatController.initialMessageList.last.setStatus = MessageStatus.read;
Expand Down
5 changes: 5 additions & 0 deletions lib/src/models/config_models/send_message_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ class TextFieldConfiguration {
/// Default is [true].
final bool enabled;

/// Determines if pressing enter submits the message.
/// Defaults to [false].
final bool enableEnterToSubmit;

const TextFieldConfiguration({
this.contentPadding,
this.maxLines,
Expand All @@ -184,6 +188,7 @@ class TextFieldConfiguration {
this.inputFormatters,
this.textCapitalization,
this.enabled = true,
this.enableEnterToSubmit = false,
});
}

Expand Down
64 changes: 21 additions & 43 deletions lib/src/widgets/chat_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ class ChatView extends StatefulWidget {
this.replyMessageBuilder,
this.replySuggestionsConfig,
this.scrollToBottomButtonConfig,
}) : chatBackgroundConfig =
chatBackgroundConfig ?? const ChatBackgroundConfiguration(),
chatViewStateConfig =
chatViewStateConfig ?? const ChatViewStateConfiguration(),
}) : chatBackgroundConfig = chatBackgroundConfig ?? const ChatBackgroundConfiguration(),
chatViewStateConfig = chatViewStateConfig ?? const ChatViewStateConfiguration(),
super(key: key);

/// Provides configuration related to user profile circle avatar.
Expand Down Expand Up @@ -161,21 +159,17 @@ class ChatView extends StatefulWidget {
State<ChatView> createState() => _ChatViewState();
}

class _ChatViewState extends State<ChatView>
with SingleTickerProviderStateMixin {
class _ChatViewState extends State<ChatView> with SingleTickerProviderStateMixin {
final GlobalKey<SendMessageWidgetState> _sendMessageKey = GlobalKey();
ValueNotifier<ReplyMessage> replyMessage =
ValueNotifier(const ReplyMessage());
ValueNotifier<ReplyMessage> replyMessage = ValueNotifier(const ReplyMessage());

ChatController get chatController => widget.chatController;

ChatBackgroundConfiguration get chatBackgroundConfig =>
widget.chatBackgroundConfig;
ChatBackgroundConfiguration get chatBackgroundConfig => widget.chatBackgroundConfig;

ChatViewState get chatViewState => widget.chatViewState;

ChatViewStateConfiguration? get chatViewStateConfig =>
widget.chatViewStateConfig;
ChatViewStateConfiguration? get chatViewStateConfig => widget.chatViewStateConfig;

FeatureActiveConfig get featureActiveConfig => widget.featureActiveConfig;

Expand All @@ -188,8 +182,7 @@ class _ChatViewState extends State<ChatView>
@override
Widget build(BuildContext context) {
// Scroll to last message on in hasMessages state.
if (widget.chatController.showTypingIndicator &&
chatViewState.hasMessages) {
if (widget.chatController.showTypingIndicator && chatViewState.hasMessages) {
chatController.scrollToLastMessage();
}
return ChatViewInheritedWidget(
Expand All @@ -214,17 +207,14 @@ class _ChatViewState extends State<ChatView>
child: Stack(
children: [
Container(
height: chatBackgroundConfig.height ??
MediaQuery.of(context).size.height,
width: chatBackgroundConfig.width ??
MediaQuery.of(context).size.width,
height: chatBackgroundConfig.height ?? MediaQuery.of(context).size.height,
width: chatBackgroundConfig.width ?? MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: chatBackgroundConfig.backgroundColor ?? Colors.white,
image: chatBackgroundConfig.backgroundImage != null
? DecorationImage(
fit: BoxFit.fill,
image: NetworkImage(
chatBackgroundConfig.backgroundImage!),
image: NetworkImage(chatBackgroundConfig.backgroundImage!),
)
: null,
),
Expand All @@ -238,25 +228,20 @@ class _ChatViewState extends State<ChatView>
children: [
if (chatViewState.isLoading)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.loadingWidgetConfig,
chatViewStateWidgetConfig: chatViewStateConfig?.loadingWidgetConfig,
chatViewState: chatViewState,
)
else if (chatViewState.noMessages)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.noMessageWidgetConfig,
chatViewStateWidgetConfig: chatViewStateConfig?.noMessageWidgetConfig,
chatViewState: chatViewState,
onReloadButtonTap:
chatViewStateConfig?.onReloadButtonTap,
onReloadButtonTap: chatViewStateConfig?.onReloadButtonTap,
)
else if (chatViewState.isError)
ChatViewStateWidget(
chatViewStateWidgetConfig:
chatViewStateConfig?.errorWidgetConfig,
chatViewStateWidgetConfig: chatViewStateConfig?.errorWidgetConfig,
chatViewState: chatViewState,
onReloadButtonTap:
chatViewStateConfig?.onReloadButtonTap,
onReloadButtonTap: chatViewStateConfig?.onReloadButtonTap,
)
else if (chatViewState.hasMessages)
ValueListenableBuilder<ReplyMessage>(
Expand All @@ -270,8 +255,7 @@ class _ChatViewState extends State<ChatView>
loadingWidget: widget.loadingWidget,
onChatListTap: widget.onChatListTap,
assignReplyMessage: (message) =>
_sendMessageKey.currentState
?.assignReplyMessage(message),
_sendMessageKey.currentState?.assignReplyMessage(message),
);
},
),
Expand All @@ -280,20 +264,14 @@ class _ChatViewState extends State<ChatView>
key: _sendMessageKey,
sendMessageBuilder: widget.sendMessageBuilder,
sendMessageConfig: widget.sendMessageConfig,
onSendTap:
(message, replyMessage, messageType) {
if (context.suggestionsConfig
?.autoDismissOnSelection ??
true) {
onSendTap: (message, replyMessage, messageType) {
if (context.suggestionsConfig?.autoDismissOnSelection ?? true) {
chatController.removeReplySuggestions();
}
_onSendTap(
message, replyMessage, messageType);
_onSendTap(message, replyMessage, messageType);
},
onReplyCallback: (reply) =>
replyMessage.value = reply,
onReplyCloseCallback: () =>
replyMessage.value = const ReplyMessage(),
onReplyCallback: (reply) => replyMessage.value = reply,
onReplyCloseCallback: () => replyMessage.value = const ReplyMessage(),
messageConfig: widget.messageConfig,
replyMessageBuilder: widget.replyMessageBuilder,
),
Expand Down
Loading