|
|
@@ -22,11 +22,10 @@ import 'dart:ui' as ui;
|
|
|
import 'package:uuid/uuid.dart';
|
|
|
|
|
|
import '../components/photo_chat.dart';
|
|
|
-import '../mobile/message_chat.dart';
|
|
|
|
|
|
class WebMessageListPage extends StatefulWidget {
|
|
|
- Map<String, dynamic>? user;
|
|
|
- WebMessageListPage(this.user, {super.key});
|
|
|
+ final Map<String, dynamic>? user;
|
|
|
+ const WebMessageListPage(this.user, {super.key});
|
|
|
|
|
|
@override
|
|
|
State<WebMessageListPage> createState() => _WebMessageListPageState();
|
|
|
@@ -436,147 +435,147 @@ class _WebMessageListPageState extends State<WebMessageListPage> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget chat(){
|
|
|
- final messageModule = Provider.of<MessageModule>(context);
|
|
|
- final dataList = messageModule.data();
|
|
|
- final currentUser = messageModule.user();
|
|
|
- final forumList = messageModule.forum();
|
|
|
-
|
|
|
- return dataList.isEmpty ? Expanded(
|
|
|
- child: Center(
|
|
|
- child: Text('noMessageText'.tr()),
|
|
|
- ),
|
|
|
- ) : SingleChildScrollView(
|
|
|
- padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
|
|
- child: Column(
|
|
|
- mainAxisSize: MainAxisSize.max,
|
|
|
- children: List.generate(dataList.length, (i) {
|
|
|
- final item = dataList[i];
|
|
|
- final isMe = item['userId'] == currentUser['userId'];
|
|
|
- final avatar = item['senderAvatar'];
|
|
|
- final chatIdMatch = idChat != null && idChat == item['chatId'];
|
|
|
- final recipientColor = U.getColor(isMe ? item['recipient'] : item['recipientId']);
|
|
|
- final recipientName = item['recipientName'];
|
|
|
- final senderName = item['senderName'];
|
|
|
- final lastText = item['lastText'] ?? '';
|
|
|
- final isImage = item['isImage'] ?? false;
|
|
|
- final fileType = item['fileType'] ?? '';
|
|
|
- final lastDate = item['lastDateTimeSend'];
|
|
|
- final lastReadStatus = item['lastReadStatus'];
|
|
|
- final forumReadStatus = forumList[i]['readStatus'];
|
|
|
-
|
|
|
- return GestureDetector(
|
|
|
- onTap: () => selectMessage(item, isMe),
|
|
|
- child: Container(
|
|
|
- padding: EdgeInsets.all(10),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: chatIdMatch ? Color(0xff26DA17).withAlpha(50) : Colors.white,
|
|
|
- borderRadius: BorderRadius.circular(12),
|
|
|
- ),
|
|
|
- child: Row(
|
|
|
- children: [
|
|
|
- avatar != null && avatar != ''
|
|
|
- ? CircleAvatar(
|
|
|
- backgroundImage: NetworkImage(avatar),
|
|
|
- radius: 24,
|
|
|
- )
|
|
|
- : Container(
|
|
|
- height: 48,
|
|
|
- width: 48,
|
|
|
- decoration: BoxDecoration(
|
|
|
- shape: BoxShape.circle,
|
|
|
- color: Color(recipientColor),
|
|
|
- ),
|
|
|
- child: Center(
|
|
|
- child: Text(
|
|
|
- isMe
|
|
|
- ? recipientName == "all_informants"
|
|
|
- ? "allInformants".tr()[0]
|
|
|
- : recipientName[0]
|
|
|
- : senderName[0],
|
|
|
- style: TextStyle(
|
|
|
- color: Colors.white,
|
|
|
- fontWeight: FontWeight.bold,
|
|
|
- fontSize: 18,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- ),
|
|
|
- SizedBox(width: 20),
|
|
|
- Expanded(
|
|
|
- child: Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
- children: [
|
|
|
- Text(
|
|
|
- isMe
|
|
|
- ? recipientName == "all_informants"
|
|
|
- ? "allInformants".tr()
|
|
|
- : recipientName
|
|
|
- : senderName,
|
|
|
- style: TextStyle(fontWeight: FontWeight.w600),
|
|
|
- ),
|
|
|
- SizedBox(height: 5),
|
|
|
- Row(
|
|
|
- children: [
|
|
|
- if (isMe)
|
|
|
- Padding(
|
|
|
- padding: EdgeInsets.only(right: 5),
|
|
|
- child: Icon(Icons.done_all, size: 18, color: Colors.blueGrey),
|
|
|
- ),
|
|
|
- if (isImage)
|
|
|
- Row(
|
|
|
- children: [
|
|
|
- Icon(
|
|
|
- fileType == 'pdf' ? Icons.picture_as_pdf : Icons.image,
|
|
|
- color: Colors.black45,
|
|
|
- size: 16,
|
|
|
- ),
|
|
|
- SizedBox(width: 6),
|
|
|
- if (lastText == '')
|
|
|
- Text(fileType == 'pdf' ? 'pdfFile'.tr() : 'photo'.tr()),
|
|
|
- ],
|
|
|
- ),
|
|
|
- Expanded(
|
|
|
- child: Text(
|
|
|
- lastText,
|
|
|
- style: TextStyle(fontSize: 13),
|
|
|
- maxLines: 1,
|
|
|
- overflow: TextOverflow.ellipsis,
|
|
|
- ),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- SizedBox(width: 20),
|
|
|
- Column(
|
|
|
- crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
- children: [
|
|
|
- Text(
|
|
|
- convertDate(lastDate, context.locale.toString()),
|
|
|
- style: TextStyle(
|
|
|
- fontSize: 11,
|
|
|
- fontWeight: forumReadStatus == 'UNREAD' ? FontWeight.w600 : FontWeight.w300,
|
|
|
- color: lastReadStatus == 'UNREAD' && !isMe ? primaryColor : Colors.black45,
|
|
|
- ),
|
|
|
- ),
|
|
|
- SizedBox(height: 12),
|
|
|
- Icon(
|
|
|
- Icons.circle,
|
|
|
- size: 12,
|
|
|
- color: primaryColor.withAlpha(lastReadStatus == 'UNREAD' && !isMe ? 1 : 0),
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ],
|
|
|
- ),
|
|
|
- ),
|
|
|
- );
|
|
|
- }),
|
|
|
- ),
|
|
|
- );
|
|
|
- }
|
|
|
+ // Widget chat(){
|
|
|
+ // final messageModule = Provider.of<MessageModule>(context);
|
|
|
+ // final dataList = messageModule.data();
|
|
|
+ // final currentUser = messageModule.user();
|
|
|
+ // final forumList = messageModule.forum();
|
|
|
+ //
|
|
|
+ // return dataList.isEmpty ? Expanded(
|
|
|
+ // child: Center(
|
|
|
+ // child: Text('noMessageText'.tr()),
|
|
|
+ // ),
|
|
|
+ // ) : SingleChildScrollView(
|
|
|
+ // padding: EdgeInsets.symmetric(vertical: 20, horizontal: 10),
|
|
|
+ // child: Column(
|
|
|
+ // mainAxisSize: MainAxisSize.max,
|
|
|
+ // children: List.generate(dataList.length, (i) {
|
|
|
+ // final item = dataList[i];
|
|
|
+ // final isMe = item['userId'] == currentUser['userId'];
|
|
|
+ // final avatar = item['senderAvatar'];
|
|
|
+ // final chatIdMatch = idChat != null && idChat == item['chatId'];
|
|
|
+ // final recipientColor = U.getColor(isMe ? item['recipient'] : item['recipientId']);
|
|
|
+ // final recipientName = item['recipientName'];
|
|
|
+ // final senderName = item['senderName'];
|
|
|
+ // final lastText = item['lastText'] ?? '';
|
|
|
+ // final isImage = item['isImage'] ?? false;
|
|
|
+ // final fileType = item['fileType'] ?? '';
|
|
|
+ // final lastDate = item['lastDateTimeSend'];
|
|
|
+ // final lastReadStatus = item['lastReadStatus'];
|
|
|
+ // final forumReadStatus = forumList[i]['readStatus'];
|
|
|
+ //
|
|
|
+ // return GestureDetector(
|
|
|
+ // onTap: () => selectMessage(item, isMe),
|
|
|
+ // child: Container(
|
|
|
+ // padding: EdgeInsets.all(10),
|
|
|
+ // decoration: BoxDecoration(
|
|
|
+ // color: chatIdMatch ? Color(0xff26DA17).withAlpha(50) : Colors.white,
|
|
|
+ // borderRadius: BorderRadius.circular(12),
|
|
|
+ // ),
|
|
|
+ // child: Row(
|
|
|
+ // children: [
|
|
|
+ // avatar != null && avatar != ''
|
|
|
+ // ? CircleAvatar(
|
|
|
+ // backgroundImage: NetworkImage(avatar),
|
|
|
+ // radius: 24,
|
|
|
+ // )
|
|
|
+ // : Container(
|
|
|
+ // height: 48,
|
|
|
+ // width: 48,
|
|
|
+ // decoration: BoxDecoration(
|
|
|
+ // shape: BoxShape.circle,
|
|
|
+ // color: Color(recipientColor),
|
|
|
+ // ),
|
|
|
+ // child: Center(
|
|
|
+ // child: Text(
|
|
|
+ // isMe
|
|
|
+ // ? recipientName == "all_informants"
|
|
|
+ // ? "allInformants".tr()[0]
|
|
|
+ // : recipientName[0]
|
|
|
+ // : senderName[0],
|
|
|
+ // style: TextStyle(
|
|
|
+ // color: Colors.white,
|
|
|
+ // fontWeight: FontWeight.bold,
|
|
|
+ // fontSize: 18,
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // SizedBox(width: 20),
|
|
|
+ // Expanded(
|
|
|
+ // child: Column(
|
|
|
+ // crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ // children: [
|
|
|
+ // Text(
|
|
|
+ // isMe
|
|
|
+ // ? recipientName == "all_informants"
|
|
|
+ // ? "allInformants".tr()
|
|
|
+ // : recipientName
|
|
|
+ // : senderName,
|
|
|
+ // style: TextStyle(fontWeight: FontWeight.w600),
|
|
|
+ // ),
|
|
|
+ // SizedBox(height: 5),
|
|
|
+ // Row(
|
|
|
+ // children: [
|
|
|
+ // if (isMe)
|
|
|
+ // Padding(
|
|
|
+ // padding: EdgeInsets.only(right: 5),
|
|
|
+ // child: Icon(Icons.done_all, size: 18, color: Colors.blueGrey),
|
|
|
+ // ),
|
|
|
+ // if (isImage)
|
|
|
+ // Row(
|
|
|
+ // children: [
|
|
|
+ // Icon(
|
|
|
+ // fileType == 'pdf' ? Icons.picture_as_pdf : Icons.image,
|
|
|
+ // color: Colors.black45,
|
|
|
+ // size: 16,
|
|
|
+ // ),
|
|
|
+ // SizedBox(width: 6),
|
|
|
+ // if (lastText == '')
|
|
|
+ // Text(fileType == 'pdf' ? 'pdfFile'.tr() : 'photo'.tr()),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // Expanded(
|
|
|
+ // child: Text(
|
|
|
+ // lastText,
|
|
|
+ // style: TextStyle(fontSize: 13),
|
|
|
+ // maxLines: 1,
|
|
|
+ // overflow: TextOverflow.ellipsis,
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // SizedBox(width: 20),
|
|
|
+ // Column(
|
|
|
+ // crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
+ // children: [
|
|
|
+ // Text(
|
|
|
+ // convertDate(lastDate, context.locale.toString()),
|
|
|
+ // style: TextStyle(
|
|
|
+ // fontSize: 11,
|
|
|
+ // fontWeight: forumReadStatus == 'UNREAD' ? FontWeight.w600 : FontWeight.w300,
|
|
|
+ // color: lastReadStatus == 'UNREAD' && !isMe ? primaryColor : Colors.black45,
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // SizedBox(height: 12),
|
|
|
+ // Icon(
|
|
|
+ // Icons.circle,
|
|
|
+ // size: 12,
|
|
|
+ // color: primaryColor.withAlpha(lastReadStatus == 'UNREAD' && !isMe ? 1 : 0),
|
|
|
+ // ),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // ],
|
|
|
+ // ),
|
|
|
+ // ),
|
|
|
+ // );
|
|
|
+ // }),
|
|
|
+ // ),
|
|
|
+ // );
|
|
|
+ // }
|
|
|
|
|
|
Widget webChat(BuildContext context) {
|
|
|
final messageModule = Provider.of<MessageModule>(context);
|
|
|
@@ -607,7 +606,7 @@ class _WebMessageListPageState extends State<WebMessageListPage> {
|
|
|
final chatId = item['chatId'];
|
|
|
final recipientId = item['recipientId'];
|
|
|
final recipient = item['recipient'];
|
|
|
- final id = item['id'];
|
|
|
+ // final id = item['id'];
|
|
|
|
|
|
return GestureDetector(
|
|
|
onTap: () {
|