Skip to content

Commit

Permalink
AI Forum: added user thumbnail icon in chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Varun Kumar committed Jul 22, 2023
1 parent 4edb43a commit 200a65a
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 37 deletions.
98 changes: 62 additions & 36 deletions lib/src/modules/ai_forum/screens/ai_forum_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,18 @@ class _AiForumScreen extends State<AiForumScreen> {
'AI Forum',
type: HeadingType.h4,
),
Container(
margin: const EdgeInsets.only(left: 12, right: 4),
child: const Icon(
Icons.person,
color: CustomColors.primary,
)),
StreamBuilder<QuerySnapshot>(
stream: onlineUserSessionsStream,
builder: (BuildContext context,
AsyncSnapshot<QuerySnapshot> snapshot) {
return CustomText("${snapshot.data?.docs.length ?? 0}");
return Container(
margin: const EdgeInsets.only(left: 8),
child: CustomText(
"(Online users: ${snapshot.data?.docs.length ?? 0})",
size: CustomTextSize.small,
style: const TextStyle(color: CustomColors.primary),
),
);
})
],
),
Expand Down Expand Up @@ -152,42 +153,67 @@ class _AiForumScreen extends State<AiForumScreen> {
AiForumMessage.fromJson(data);
bool messageFromSelf =
messageItem.deviceId == Globals.deviceId;
String? username = isEmpty(messageItem.username)
? messageItem.deviceId
: messageItem.username;
return GestureDetector(
onLongPress: () {
onAiForumMessageLongPress(messageItem);
},
child: AiForumMessageBubble(
messageFromSelf: messageFromSelf,
message: messageItem,
child: Column(
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
margin: const EdgeInsets.only(bottom: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
CustomText(
'@${(messageItem.username == null || messageItem.username == '') ? messageItem.deviceId : messageItem.username}',
size: CustomTextSize.tiny,
)
],
)),
MarkdownBody(
data: messageItem.content ?? 'Null'),
Container(
margin: const EdgeInsets.only(top: 8),
child: CustomText(
messageItem.time == null
? ''
: getFormattedTime(messageItem.time!),
size: CustomTextSize.tiny,
))
],
),
),
padding: const EdgeInsets.all(4),
margin:
const EdgeInsets.only(top: 12, left: 12),
decoration: BoxDecoration(
color: CustomColors.secondary,
shape: BoxShape.circle,
border: Border.all()),
child: const Icon(
Icons.person,
color: Colors.white,
size: 16,
),
),
Expanded(
child: AiForumMessageBubble(
messageFromSelf: messageFromSelf,
message: messageItem,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Container(
margin:
const EdgeInsets.only(bottom: 8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
CustomText(
'@$username',
size: CustomTextSize.tiny,
)
],
)),
MarkdownBody(
data: messageItem.content ?? 'Null'),
Container(
margin: const EdgeInsets.only(top: 8),
child: CustomText(
messageItem.time == null
? ''
: getFormattedTime(
messageItem.time!),
size: CustomTextSize.tiny,
))
],
),
))
]),
);
})
.toList()
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.3.2+20
version: 1.3.2+21

environment:
sdk: ">=2.17.6 <3.0.0"
Expand Down

0 comments on commit 200a65a

Please sign in to comment.