diff --git a/lib/pages/message/conversation_tab.dart b/lib/pages/message/conversation_tab.dart index 7a20406..c0b9d63 100644 --- a/lib/pages/message/conversation_tab.dart +++ b/lib/pages/message/conversation_tab.dart @@ -1,3 +1,5 @@ +import 'package:dating_touchme_app/extension/ex_widget.dart'; +import 'package:dating_touchme_app/im/im_manager.dart'; import 'package:flutter/material.dart'; import 'package:dating_touchme_app/generated/assets.dart'; import 'package:get/get.dart'; @@ -147,83 +149,88 @@ class _ConversationTabState extends State with AutomaticKeepAli future: controller.getUnreadCount(conversation), builder: (context, snapshot){ int unreadCount = snapshot.data ?? 0; - return Container( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(16)), - ), - margin: const EdgeInsets.only(bottom: 8, left: 16, right: 16), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // 头像 - Container( - width: 56, - height: 56, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(28), - image: DecorationImage( - image: userInfo?.avatarUrl != '' ? NetworkImage(userInfo?.avatarUrl ?? '') : AssetImage(Assets.imagesAvatarsExample), - fit: BoxFit.cover, + return GestureDetector( + onTap: () async{ + await IMManager.instance.sendTextMessage('来了', conversation.id); + }, + child: Container( + padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12), + decoration: const BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(16)), + ), + margin: const EdgeInsets.only(bottom: 8, left: 16, right: 16), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + // 头像 + Container( + width: 56, + height: 56, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(28), + image: DecorationImage( + image: userInfo?.avatarUrl != '' ? NetworkImage(userInfo?.avatarUrl ?? '') : AssetImage(Assets.imagesAvatarsExample), + fit: BoxFit.cover, + ), ), ), - ), - const SizedBox(width: 12), - // 会话信息 - Expanded( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - userInfo?.nickName ?? '联系人', - style: const TextStyle( - fontSize: 16, - fontWeight: FontWeight.w500, - color: Colors.black, + const SizedBox(width: 12), + // 会话信息 + Expanded( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + userInfo?.nickName ?? '联系人', + style: const TextStyle( + fontSize: 16, + fontWeight: FontWeight.w500, + color: Colors.black, + ), ), - ), - Text( - controller.formatMessageTime(message?.serverTime ?? 0), - style: const TextStyle( - fontSize: 12, - color: Colors.grey, + Text( + controller.formatMessageTime(message?.serverTime ?? 0), + style: const TextStyle( + fontSize: 12, + color: Colors.grey, + ), ), + ], + ), + const SizedBox(height: 4), + Text( + controller.getLastMessageContent(message), + style: const TextStyle( + fontSize: 14, + color: Colors.grey, ), - ], + overflow: TextOverflow.ellipsis, + ), + ], + ), + ), + // 未读消息数 + if (unreadCount > 0) + Container( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), + decoration: BoxDecoration( + color: Colors.red, + borderRadius: BorderRadius.circular(10), ), - const SizedBox(height: 4), - Text( - controller.getLastMessageContent(message), + child: Text( + unreadCount.toString(), style: const TextStyle( - fontSize: 14, - color: Colors.grey, + fontSize: 12, + color: Colors.white, ), - overflow: TextOverflow.ellipsis, - ), - ], - ), - ), - // 未读消息数 - if (unreadCount > 0) - Container( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), - decoration: BoxDecoration( - color: Colors.red, - borderRadius: BorderRadius.circular(10), - ), - child: Text( - unreadCount.toString(), - style: const TextStyle( - fontSize: 12, - color: Colors.white, ), ), - ), - ], + ], + ), ), ); }