diff --git a/lib/im/chat_details_page.dart b/lib/im/chat_details_page.dart index a1471727..1a141630 100644 --- a/lib/im/chat_details_page.dart +++ b/lib/im/chat_details_page.dart @@ -14,7 +14,6 @@ import 'package:huixiang/im/database/message.dart'; import 'package:huixiang/main.dart'; import 'package:huixiang/retrofit/data/im_user.dart'; import 'package:huixiang/retrofit/retrofit_api.dart'; -import 'package:huixiang/utils/qiniu.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:image_pickers/image_pickers.dart'; @@ -26,7 +25,6 @@ import '../../community/release_dynamic.dart'; import '../../generated/l10n.dart'; import '../../utils/font_weight.dart'; import '../retrofit/data/base_data.dart'; -import '../retrofit/data/upload_result.dart'; import '../retrofit/data/user_info.dart'; import '../utils/flutter_utils.dart'; import '../view_widget/custom_image.dart'; @@ -68,7 +66,6 @@ class _ChatDetailsPage extends State OnChatMsgInstance.instance.onChatMessage; final ScrollController scrollController = ScrollController(); String tex = ""; - int copyIndex = 0; String selfUserId = ""; ImUser _toUser; String conversation; @@ -574,7 +571,6 @@ class _ChatDetailsPage extends State behavior: HitTestBehavior.opaque, onTap: () { setState(() { - copyIndex = 0; if (emojiShowing) { emojiShowing = !emojiShowing; } @@ -638,90 +634,7 @@ class _ChatDetailsPage extends State // SizedBox( // height: 16.h, // ), - // if (copyIndex == -1) - // 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(() { - // copyIndex = 0; - // this.copy(tex); - // }); - // }, - // 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: () {}, - // 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, - // ), - // ], - // ), + /// not self if (!isSelf && isText) @@ -764,98 +677,113 @@ class _ChatDetailsPage extends State alignment: Alignment.centerLeft, child:GestureDetector( onLongPress: () { - final RenderBox renderBox = _buttonKey.currentContext.findRenderObject() as RenderBox; - final buttonPosition = renderBox.localToGlobal(Offset.zero); - final buttonSize = renderBox.size; + RenderBox renderBox = _buttonKey.currentContext.findRenderObject() as RenderBox; + Offset buttonPosition = renderBox.localToGlobal(Offset.zero); + Size buttonSize = renderBox.size; - setState(() { - // showMenu( - // context: context, - // color: Color(0xFF2A2A2A), - // position: RelativeRect.fromLTRB( - // buttonPosition.dx + (buttonSize.width - 152.w) / 2, // 居中对齐 - // buttonPosition.dy - 55, - // buttonPosition.dx + buttonSize.width, - // buttonPosition.dy - // ), /// 设置弹出菜单的显示位置 - // items: [ - // PopupMenuItem( - // value: 1, - // height: 30.h, - // padding: EdgeInsets.zero, - // child:Container( - // child:Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // GestureDetector( - // behavior: HitTestBehavior.translucent, - // onTap: () { - // setState(() { - // copyIndex = 0; - // this.copy(messages[position].content); - // Navigator.pop(context); - // }); - // }, - // child:Padding( - // padding:EdgeInsets.only(left: 28.w,right:25.w), - // 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( - // behavior: HitTestBehavior.translucent, - // onTap: () {}, - // child: Padding( - // padding:EdgeInsets.only(right: 28.w,left:25.w), - // 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, - // ), - // ), - // ], - // )), - // ) - // ], - // ), - // ), - // ), - // ], - // ); - }); + 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(messages[position].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(messages[position].id.toString()); + messages.removeAt(position); + 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, + ), + ], + ), + ), + ], + ); }, child: Container( decoration: BoxDecoration( @@ -893,89 +821,6 @@ class _ChatDetailsPage extends State ), ), - // if (copyIndex == 1) - // 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(() { - // copyIndex = 0; - // this.copy(tex); - // }); - // }, - // 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: () {}, - // 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, - // ), - // ], - // ), - /// self if (isSelf && isText) SizedBox( @@ -1014,100 +859,115 @@ class _ChatDetailsPage extends State Expanded( child: Container( alignment: Alignment.centerRight, - child: GestureDetector( + child: InkWell( onLongPress: () { - final RenderBox renderBox = _buttonKey.currentContext.findRenderObject() as RenderBox; - final buttonPosition = renderBox.localToGlobal(Offset.zero); - final buttonSize = renderBox.size; + RenderBox renderBox = _buttonKey.currentContext.findRenderObject() as RenderBox; + Offset buttonPosition = renderBox.localToGlobal(Offset.zero); + Size buttonSize = renderBox.size; - setState(() { - // showMenu( - // context: context, - // color: Color(0xFF2A2A2A), - // position: RelativeRect.fromLTRB( - // buttonPosition.dx + (buttonSize.width - 152.w) / 2, // 居中对齐 - // buttonPosition.dy - 55, - // buttonPosition.dx + buttonSize.width, - // buttonPosition.dy - // ), /// 设置弹出菜单的显示位置 - // items: [ - // PopupMenuItem( - // value: 1, - // height: 30.h, - // padding: EdgeInsets.zero, - // child:Container( - // child:Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - // crossAxisAlignment: CrossAxisAlignment.center, - // children: [ - // GestureDetector( - // behavior: HitTestBehavior.translucent, - // onTap: () { - // setState(() { - // copyIndex = 0; - // this.copy(messages[position].content); - // Navigator.pop(context); - // }); - // }, - // child:Padding( - // padding:EdgeInsets.only(left: 28.w,right:25.w), - // 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( - // behavior: HitTestBehavior.translucent, - // onTap: () {}, - // child: Padding( - // padding:EdgeInsets.only(right: 28.w,left:25.w), - // 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, - // ), - // ), - // ], - // )), - // ) - // ], - // ), - // ), - // ), - // ], - // ); - }); + 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(messages[position].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(messages[position].id.toString()); + messages.removeAt(position); + 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, + ), + ], + ), + ), + ], + ); }, child: Container( decoration: BoxDecoration( diff --git a/lib/im/database/hx_database.dart b/lib/im/database/hx_database.dart index 4daa8573..94566b14 100644 --- a/lib/im/database/hx_database.dart +++ b/lib/im/database/hx_database.dart @@ -131,6 +131,10 @@ class HxDatabase { return db.delete("Message",where: "conversationId = ?", whereArgs: [conversationId]); } + Future deleteByMsgId(String id) async { + return db.delete("Message",where: "id = ?", whereArgs: [id]); + } + Future deleteAll() async { return db.delete("Message"); }