diff --git a/lib/modules/copilot/screens/copilot_chat_page.dart b/lib/modules/copilot/screens/copilot_chat_page.dart index 6c35a740..06f901c6 100644 --- a/lib/modules/copilot/screens/copilot_chat_page.dart +++ b/lib/modules/copilot/screens/copilot_chat_page.dart @@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:test_sa/border_beam/src/beam_style.dart'; import 'package:test_sa/border_beam/src/border_beam.dart'; +import 'package:test_sa/controllers/providers/api/user_provider.dart'; import 'package:test_sa/extensions/context_extension.dart'; import 'package:test_sa/extensions/int_extensions.dart'; import 'package:test_sa/extensions/string_extensions.dart'; @@ -177,7 +178,7 @@ class _CopilotChatPageState extends State { mainAxisSize: MainAxisSize.min, children: [ if (showDateHeader) _dateCard(currentMessage.timestamp?.toIso8601String().chatMsgDateWithYear ?? ""), - CopilotMessageBubble(message: currentMessage, showHeader: showHeader), + CopilotMessageBubble(message: currentMessage, showHeader: showHeader, userAvatar: Provider.of(context, listen: false).user?.profilePhotoName), ], ); }, diff --git a/lib/modules/copilot/widgets/copilot_message_bubble.dart b/lib/modules/copilot/widgets/copilot_message_bubble.dart index 754fdcbe..4ad9eaea 100644 --- a/lib/modules/copilot/widgets/copilot_message_bubble.dart +++ b/lib/modules/copilot/widgets/copilot_message_bubble.dart @@ -13,10 +13,11 @@ import 'package:url_launcher/url_launcher.dart'; import '../model/copilot_message_model.dart'; class CopilotMessageBubble extends StatelessWidget { + final String? userAvatar; final CopilotMessage message; final bool showHeader; - const CopilotMessageBubble({Key? key, required this.message, this.showHeader = true}) : super(key: key); + const CopilotMessageBubble({Key? key, required this.message, this.showHeader = true, this.userAvatar}) : super(key: key); @override Widget build(BuildContext context) { @@ -24,12 +25,6 @@ class CopilotMessageBubble extends StatelessWidget { return isUser ? _senderCard(context) : _recipientCard(context); } - static const Widget _avatar = SizedBox( - height: 26, - width: 26, - child: DecoratedBox(decoration: BoxDecoration(shape: BoxShape.circle, color: Colors.grey)), - ); - String get _timeText => (message.timestamp?.toIso8601String() ?? DateTime.now().toIso8601String()).chatMsgTime; Widget _senderCard(BuildContext context) { @@ -38,7 +33,19 @@ class CopilotMessageBubble extends StatelessWidget { children: [ const InfoTextLabelWidget(label: "Me"), 8.width, - _avatar, + Container( + height: 36, + width: 36, + padding: const EdgeInsets.all(4), + decoration: BoxDecoration(color: AppColor.background(context), shape: BoxShape.circle, border: Border.all(color: Colors.transparent)), + child: userAvatar != null + ? ClipOval(child: Image.network(userAvatar!, width: 14, height: 14)) + : Icon( + Icons.person, + size: 16, + color: AppColor.icon2Color(context), + ), + ), ], ); @@ -95,7 +102,12 @@ class CopilotMessageBubble extends StatelessWidget { final recipientHeader = Row( mainAxisSize: MainAxisSize.min, children: [ - _avatar, + Container( + height: 36, + width: 36, + padding: const EdgeInsets.all(8), + decoration: BoxDecoration(color: AppColor.background(context), shape: BoxShape.circle, border: Border.all(color: Colors.transparent)), + child: "copilot_logo".toSvgAsset(width: 14, height: 14)), 8.width, const InfoTextLabelWidget(label: "Copilot"), // Text(