From a839ea9639fe39a7fd37281e2017929fef003a6a Mon Sep 17 00:00:00 2001 From: fff Date: Wed, 15 Jan 2025 18:24:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=95=BF=E6=8C=89=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/im/chat_details_page.dart | 264 ++++++++++------------------------ 1 file changed, 76 insertions(+), 188 deletions(-) diff --git a/lib/im/chat_details_page.dart b/lib/im/chat_details_page.dart index d1f95b3f..8e8cd849 100644 --- a/lib/im/chat_details_page.dart +++ b/lib/im/chat_details_page.dart @@ -20,6 +20,7 @@ import 'package:huixiang/im/database/message.dart'; import 'package:huixiang/im/out/message.pb.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; +import 'package:huixiang/utils/constant.dart'; import 'package:huixiang/utils/shared_preference.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:image_pickers/image_pickers.dart'; @@ -131,7 +132,7 @@ class _ChatDetailsPage extends State debugPrint("refresh-message-height: ${height} page: $page"); scrollController.position.restoreOffset(height, initialRestore: true); } - newmessages.addAll(messagePage!.reversed.toList()); + newmessages.addAll(messagePage.reversed.toList()); newanimatedListKey.currentState?.insertAllItems(0, messagePage.length); } else { loadmessages.addAll(messagePage!.toList()); @@ -799,7 +800,7 @@ class _ChatDetailsPage extends State ), key: _buttonKey, padding: EdgeInsets.symmetric( - vertical: 6, + vertical: 6.h, horizontal: 12.w, ), child: Text( @@ -877,7 +878,7 @@ class _ChatDetailsPage extends State ), key: _buttonKey, padding: EdgeInsets.symmetric( - vertical: 6, + vertical: 6.h, horizontal: 12.w, ), child: Text( @@ -1073,217 +1074,104 @@ class _ChatDetailsPage extends State /// 显示消息菜单 showMessageMenu(context, _buttonKey, message, index, animatedListKey) { - RenderBox renderBox = _buttonKey.currentContext.findRenderObject() as RenderBox; - Offset buttonPosition = renderBox.localToGlobal(Offset.zero); - Size buttonSize = renderBox.size; - // showMenu( - // context: context, ///去除阴影 - // elevation: 0, - // color: Colors.transparent, - // position: RelativeRect.fromLTRB( - // buttonPosition.dx + (buttonSize.width - 180.w) / 2, // 居中对齐 - // buttonPosition.dy - 68, - // buttonPosition.dx + buttonSize.width, - // buttonPosition.dy, - // ), - // /// 设置弹出菜单的显示位置 - // items: [ - // PopupMenuItem( - // value: 1, - // padding: EdgeInsets.zero, - // child: Stack( - // alignment: Alignment.bottomCenter, - // children: [ - // Container( - // padding: EdgeInsets.only(bottom: 13.h), - // child: Container( - // width: 180.w, - // decoration: BoxDecoration( - // color: Color(0xFF2A2A2A), - // borderRadius: BorderRadius.circular(6), - // ), - // padding: EdgeInsets.symmetric( - // horizontal: 32.w, - // vertical: 7.5.h, - // ), - // child: Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // GestureDetector( - // onTap: () { - // setState(() { - // this.copy(message.content); - // Navigator.pop(context); - // }); - // }, - // child: Column( - // children: [ - // Image.asset( - // "assets/image/icon_chat_copy.webp", - // height: 16, - // width: 16, - // ), - // SizedBox( - // height: 2.h, - // ), - // Text( - // "复制", - // textAlign: - // TextAlign.center, - // style: TextStyle( - // color: Colors.white, - // fontSize: 12.sp, - // fontWeight: MyFontWeight - // .regular, - // ), - // ), - // ], - // ), - // ), - // GestureDetector( - // onTap: () async { - // await hxDatabase.deleteByMsgId("${message.id}"); - // if (animatedListKey == loadanimatedListKey) { - // loadmessages.remove(message); - // animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); - // } else { - // newmessages.remove(message); - // animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); - // } - // Navigator.pop(context); - // }, - // child: Column( - // children: [ - // Image.asset( - // "assets/image/icon_chat_delete.webp", - // height: 16, - // width: 16, - // ), - // SizedBox( - // height: 2.h, - // ), - // Text( - // S.of(context).shanchu, - // textAlign: TextAlign.center, - // style: TextStyle( - // color: Colors.white, - // fontSize: 12.sp, - // fontWeight: MyFontWeight.regular, - // ), - // ), - // ], - // ), - // ), - // ], - // ), - // ), - // ), - // Image.asset( - // "assets/image/icon_copy_j.webp", - // height: 17, - // width: 17, - // ), - // ], - // ), - // ), - // ], - // ); - SmartDialog.showAttach( targetContext: _buttonKey.currentContext, + alignment: Alignment.topCenter, + maskColor: Colors.transparent, + animationType: SmartAnimationType.fade, builder: (ctx) { return Stack( alignment: Alignment.bottomCenter, children: [ Container( - padding: EdgeInsets.only(bottom: 13.h), + padding: EdgeInsets.only(bottom: 16), child: Container( - width: 180.w, decoration: BoxDecoration( color: Color(0xFF2A2A2A), borderRadius: BorderRadius.circular(6), ), padding: EdgeInsets.symmetric( - horizontal: 32.w, + horizontal: 24.w, vertical: 7.5.h, ), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - GestureDetector( - onTap: () { - setState(() { + child: IntrinsicWidth( + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + GestureDetector( + onTap: () { this.copy(message.content); - Navigator.pop(context); - }); - }, - child: Column( - children: [ - Image.asset( - "assets/image/icon_chat_copy.webp", - height: 16, - width: 16, - ), - SizedBox( - height: 2.h, - ), - Text( - "复制", - textAlign: - TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 12.sp, - fontWeight: MyFontWeight - .regular, + SmartDialog.dismiss(status: SmartStatus.attach); + }, + child: Column( + children: [ + Image.asset( + "assets/image/icon_chat_copy.webp", + height: 16, + width: 16, ), - ), - ], + SizedBox( + height: 2.h, + ), + Text( + "复制", + textAlign: + TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + fontWeight: MyFontWeight + .regular, + ), + ), + ], + ), ), - ), - GestureDetector( - onTap: () async { - await hxDatabase.deleteByMsgId("${message.id}"); - if (animatedListKey == loadanimatedListKey) { - loadmessages.remove(message); - animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); - } else { - newmessages.remove(message); - animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); - } - Navigator.pop(context); - }, - child: Column( - children: [ - Image.asset( - "assets/image/icon_chat_delete.webp", - height: 16, - width: 16, - ), - SizedBox( - height: 2.h, - ), - Text( - S.of(context).shanchu, - textAlign: TextAlign.center, - style: TextStyle( - color: Colors.white, - fontSize: 12.sp, - fontWeight: MyFontWeight.regular, + 24.w.vd, + GestureDetector( + onTap: () async { + await hxDatabase.deleteByMsgId("${message.id}"); + if (animatedListKey == loadanimatedListKey) { + loadmessages.remove(message); + animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); + } else { + newmessages.remove(message); + animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); + } + SmartDialog.dismiss(status: SmartStatus.attach); + }, + child: Column( + children: [ + Image.asset( + "assets/image/icon_chat_delete.webp", + height: 16, + width: 16, ), - ), - ], + SizedBox( + height: 2.h, + ), + Text( + S.of(context).shanchu, + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 12.sp, + fontWeight: MyFontWeight.regular, + ), + ), + ], + ), ), - ), - ], + ], + ), ), ), ), Image.asset( "assets/image/icon_copy_j.webp", height: 17, + fit: BoxFit.fill, width: 17, ), ],