forked from eatvio/eatvio_app
feat(chat): add init and dispose chat, typing info, receive a messages
This commit is contained in:
@@ -11,12 +11,12 @@ class ChatBubbleWidget extends StatelessWidget {
|
||||
super.key,
|
||||
required this.text,
|
||||
required this.isCurrentUser,
|
||||
this.mediaData,
|
||||
required this.mediaData,
|
||||
});
|
||||
|
||||
final String text;
|
||||
final bool isCurrentUser;
|
||||
final List<dynamic>? mediaData;
|
||||
final List<dynamic> mediaData;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -32,23 +32,24 @@ class ChatBubbleWidget extends StatelessWidget {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (mediaData != null)
|
||||
if (mediaData.isNotEmpty)
|
||||
CustomScrollView(
|
||||
shrinkWrap: true,
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
slivers: [
|
||||
SliverList.separated(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (!mediaData![index].toString().contains('.png') &&
|
||||
!mediaData![index].toString().contains('.jpg') &&
|
||||
!mediaData![index].toString().contains('.jpeg')) {
|
||||
if (!mediaData[index].toString().contains('.png') &&
|
||||
!mediaData[index].toString().contains('.jpg') &&
|
||||
!mediaData[index].toString().contains('.jpeg')) {
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
horizontalTitleGap: 8,
|
||||
onTap: () async {
|
||||
if (!await launchUrl(Uri.parse(dotenv.env['STORAGE_URL']! + mediaData![index].toString()))) {
|
||||
throw Exception('Could not launch ${mediaData![index].toString()}');
|
||||
if (!await launchUrl(Uri.parse(dotenv.env['STORAGE_URL']! + mediaData[index].toString()))) {
|
||||
throw Exception('Could not launch ${mediaData[index].toString()}');
|
||||
}
|
||||
},
|
||||
leading: Icon(
|
||||
@@ -60,7 +61,7 @@ class ChatBubbleWidget extends StatelessWidget {
|
||||
color: Color(0xFF2F80ED),
|
||||
),
|
||||
title: Text(
|
||||
mediaData![index].toString().replaceAll('chat_files/', ''),
|
||||
mediaData[index].toString().replaceAll('chat_files/', ''),
|
||||
maxLines: 2,
|
||||
style: TextStyle(
|
||||
color: Color(0xFF323F4B),
|
||||
@@ -74,29 +75,29 @@ class ChatBubbleWidget extends StatelessWidget {
|
||||
onTap: () {
|
||||
context.pushTransparentRoute(
|
||||
PhotoViewScreen(
|
||||
imageUrls: mediaData!.map((e) => dotenv.env['STORAGE_URL']! + e.toString()).toList(),
|
||||
imageUrls: mediaData.map((e) => dotenv.env['STORAGE_URL']! + e.toString()).toList(),
|
||||
index: index,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Hero(
|
||||
tag: dotenv.env['STORAGE_URL']! + '${mediaData![index]}',
|
||||
tag: dotenv.env['STORAGE_URL']! + '${mediaData[index]}',
|
||||
transitionOnUserGestures: true,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadiusStyle.roundedBorder8,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + '${mediaData![index]}',
|
||||
imageUrl: dotenv.env['STORAGE_URL']! + '${mediaData[index]}',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) => const SizedBox(height: 8),
|
||||
itemCount: mediaData!.length,
|
||||
itemCount: mediaData.length,
|
||||
),
|
||||
],
|
||||
),
|
||||
if (mediaData!.length > 0 && text.isNotEmpty) SizedBox(height: 8),
|
||||
if (mediaData.length > 0 && text.isNotEmpty) SizedBox(height: 8),
|
||||
if (text.isNotEmpty)
|
||||
Text(
|
||||
text,
|
||||
|
||||
Reference in New Issue
Block a user