|
|
|
|
@ -79,16 +79,13 @@ class _ChatMessagesState {
|
|
|
|
|
_ChatMessagesState({
|
|
|
|
|
required this.isLoading,
|
|
|
|
|
required this.messages,
|
|
|
|
|
}) : messageCount = messages.length,
|
|
|
|
|
lastMessageTime = messages.isNotEmpty ? messages.first.createdDate : null;
|
|
|
|
|
}) : messageCount = messages.length,
|
|
|
|
|
lastMessageTime = messages.isNotEmpty ? messages.first.createdDate : null;
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
bool operator ==(Object other) =>
|
|
|
|
|
identical(this, other) ||
|
|
|
|
|
other is _ChatMessagesState &&
|
|
|
|
|
isLoading == other.isLoading &&
|
|
|
|
|
messageCount == other.messageCount &&
|
|
|
|
|
lastMessageTime == other.lastMessageTime; // FIX: Compare timestamp to detect new messages
|
|
|
|
|
identical(this, other) ||
|
|
|
|
|
other is _ChatMessagesState && isLoading == other.isLoading && messageCount == other.messageCount && lastMessageTime == other.lastMessageTime; // FIX: Compare timestamp to detect new messages
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
int get hashCode => Object.hash(isLoading, messageCount, lastMessageTime);
|
|
|
|
|
@ -198,7 +195,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: AppColor.white10,
|
|
|
|
|
// backgroundColor: AppColor.white10,
|
|
|
|
|
appBar: DefaultAppBar(title: widget.title),
|
|
|
|
|
// OPTIMIZATION: Using Selector for connection state (rarely changes)
|
|
|
|
|
// This prevents rebuilding entire chat UI on every message/typing event
|
|
|
|
|
@ -208,7 +205,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
loginResponse: provider.chatLoginResponse,
|
|
|
|
|
),
|
|
|
|
|
builder: (context, connectionState, child) {
|
|
|
|
|
if (connectionState.isLoading) return CircularProgressIndicator(color: AppColor.loadingColor(context), strokeWidth: 3).center;
|
|
|
|
|
if (connectionState.isLoading) return CircularProgressIndicator(color: AppColor.loadingColor(context), strokeWidth: 3).center;
|
|
|
|
|
|
|
|
|
|
if (connectionState.loginResponse == null) {
|
|
|
|
|
return Column(
|
|
|
|
|
@ -278,7 +275,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(
|
|
|
|
|
color: AppColor.white10,
|
|
|
|
|
decoration: TextDecoration.underline,
|
|
|
|
|
decorationColor: AppColor.white10,
|
|
|
|
|
decorationColor: AppColor.white10
|
|
|
|
|
),
|
|
|
|
|
).onPress(() {
|
|
|
|
|
Navigator.push(context, CupertinoPageRoute(builder: (context) => ViewAllAttachmentPage(moduleId: widget.moduleId, requestId: widget.requestId)));
|
|
|
|
|
@ -294,7 +291,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
messages: provider.chatResponseList,
|
|
|
|
|
),
|
|
|
|
|
builder: (context, messagesState, _) => Container(
|
|
|
|
|
color: AppColor.neutral100,
|
|
|
|
|
// color: AppColor.neutral100,
|
|
|
|
|
child: messagesState.isLoading
|
|
|
|
|
? ListView(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
@ -311,7 +308,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
"Send a message to start conversation",
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(color: AppColor.neutral50.withOpacity(.5), fontWeight: FontWeight.w500),
|
|
|
|
|
style: AppTextStyles.heading6.copyWith(color: AppColor.lightTextColor(context), fontWeight: FontWeight.w500),
|
|
|
|
|
).center
|
|
|
|
|
: ListView.builder(
|
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
|
@ -340,7 +337,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
if (!widget.readOnly) ...[
|
|
|
|
|
Divider(height: 1, thickness: 1, color: const Color(0xff767676).withOpacity(.11)),
|
|
|
|
|
const Divider().defaultStyle(context),
|
|
|
|
|
SafeArea(
|
|
|
|
|
child: ConstrainedBox(
|
|
|
|
|
constraints: const BoxConstraints(minHeight: 56),
|
|
|
|
|
@ -349,8 +346,8 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
if (chatState == ChatState.idle) ...[
|
|
|
|
|
TextFormField(
|
|
|
|
|
controller: textEditingController,
|
|
|
|
|
cursorColor: AppColor.neutral50,
|
|
|
|
|
style: AppTextStyles.bodyText.copyWith(color: AppColor.neutral50),
|
|
|
|
|
cursorColor: AppColor.loadingColor(context),
|
|
|
|
|
style: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 14, color: AppColor.textStyleColor(context)),
|
|
|
|
|
minLines: 1,
|
|
|
|
|
maxLines: 3,
|
|
|
|
|
textInputAction: TextInputAction.none,
|
|
|
|
|
@ -371,11 +368,11 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
errorBorder: InputBorder.none,
|
|
|
|
|
contentPadding: const EdgeInsets.only(left: 16, top: 8, bottom: 8),
|
|
|
|
|
alignLabelWithHint: true,
|
|
|
|
|
filled: true,
|
|
|
|
|
// filled: true,
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
suffixIconConstraints: const BoxConstraints(),
|
|
|
|
|
hintText: "Type your message here...",
|
|
|
|
|
hintStyle: AppTextStyles.bodyText.copyWith(color: const Color(0xffCCCCCC)),
|
|
|
|
|
hintStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: AppColor.lightTextColor(context)),
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
IconButton(
|
|
|
|
|
@ -399,7 +396,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
style: const ButtonStyle(
|
|
|
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap, // or .padded
|
|
|
|
|
),
|
|
|
|
|
icon: "chat_attachment".toSvgAsset(width: 24, height: 24),
|
|
|
|
|
icon: "chat_attachment".toSvgAsset(width: 24, height: 24,color: AppColor.icon2Color(context)),
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
),
|
|
|
|
|
IconButton(
|
|
|
|
|
@ -420,7 +417,7 @@ class _ChatPageState extends State<ChatPage> {
|
|
|
|
|
style: const ButtonStyle(
|
|
|
|
|
tapTargetSize: MaterialTapTargetSize.shrinkWrap, // or .padded
|
|
|
|
|
),
|
|
|
|
|
icon: "chat_mic".toSvgAsset(width: 24, height: 24),
|
|
|
|
|
icon: "chat_mic".toSvgAsset(width: 24, height: 24,color: AppColor.icon2Color(context)),
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
),
|
|
|
|
|
] else if (chatState == ChatState.voiceRecordingStarted) ...[
|
|
|
|
|
|