Browse Source

消息长按菜单修改

dart3_last
fff 1 week ago
parent
commit
a839ea9639
  1. 264
      lib/im/chat_details_page.dart

264
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/im/out/message.pb.dart';
import 'package:huixiang/main.dart'; import 'package:huixiang/main.dart';
import 'package:huixiang/retrofit/retrofit_api.dart'; import 'package:huixiang/retrofit/retrofit_api.dart';
import 'package:huixiang/utils/constant.dart';
import 'package:huixiang/utils/shared_preference.dart'; import 'package:huixiang/utils/shared_preference.dart';
import 'package:huixiang/view_widget/my_appbar.dart'; import 'package:huixiang/view_widget/my_appbar.dart';
import 'package:image_pickers/image_pickers.dart'; import 'package:image_pickers/image_pickers.dart';
@ -131,7 +132,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
debugPrint("refresh-message-height: ${height} page: $page"); debugPrint("refresh-message-height: ${height} page: $page");
scrollController.position.restoreOffset(height, initialRestore: true); scrollController.position.restoreOffset(height, initialRestore: true);
} }
newmessages.addAll(messagePage!.reversed.toList()); newmessages.addAll(messagePage.reversed.toList());
newanimatedListKey.currentState?.insertAllItems(0, messagePage.length); newanimatedListKey.currentState?.insertAllItems(0, messagePage.length);
} else { } else {
loadmessages.addAll(messagePage!.toList()); loadmessages.addAll(messagePage!.toList());
@ -799,7 +800,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
), ),
key: _buttonKey, key: _buttonKey,
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: 6, vertical: 6.h,
horizontal: 12.w, horizontal: 12.w,
), ),
child: Text( child: Text(
@ -877,7 +878,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
), ),
key: _buttonKey, key: _buttonKey,
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
vertical: 6, vertical: 6.h,
horizontal: 12.w, horizontal: 12.w,
), ),
child: Text( child: Text(
@ -1073,217 +1074,104 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
/// ///
showMessageMenu(context, _buttonKey, message, index, animatedListKey) { 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( SmartDialog.showAttach(
targetContext: _buttonKey.currentContext, targetContext: _buttonKey.currentContext,
alignment: Alignment.topCenter,
maskColor: Colors.transparent,
animationType: SmartAnimationType.fade,
builder: (ctx) { builder: (ctx) {
return Stack( return Stack(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
children: [ children: [
Container( Container(
padding: EdgeInsets.only(bottom: 13.h), padding: EdgeInsets.only(bottom: 16),
child: Container( child: Container(
width: 180.w,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(0xFF2A2A2A), color: Color(0xFF2A2A2A),
borderRadius: BorderRadius.circular(6), borderRadius: BorderRadius.circular(6),
), ),
padding: EdgeInsets.symmetric( padding: EdgeInsets.symmetric(
horizontal: 32.w, horizontal: 24.w,
vertical: 7.5.h, vertical: 7.5.h,
), ),
child: Row( child: IntrinsicWidth(
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: Row(
crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ crossAxisAlignment: CrossAxisAlignment.center,
GestureDetector( children: [
onTap: () { GestureDetector(
setState(() { onTap: () {
this.copy(message.content); this.copy(message.content);
Navigator.pop(context); SmartDialog.dismiss(status: SmartStatus.attach);
}); },
}, child: Column(
child: Column( children: [
children: [ Image.asset(
Image.asset( "assets/image/icon_chat_copy.webp",
"assets/image/icon_chat_copy.webp", height: 16,
height: 16, width: 16,
width: 16,
),
SizedBox(
height: 2.h,
),
Text(
"复制",
textAlign:
TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
fontWeight: MyFontWeight
.regular,
), ),
), SizedBox(
], height: 2.h,
),
Text(
"复制",
textAlign:
TextAlign.center,
style: TextStyle(
color: Colors.white,
fontSize: 12.sp,
fontWeight: MyFontWeight
.regular,
),
),
],
),
), ),
), 24.w.vd,
GestureDetector( GestureDetector(
onTap: () async { onTap: () async {
await hxDatabase.deleteByMsgId("${message.id}"); await hxDatabase.deleteByMsgId("${message.id}");
if (animatedListKey == loadanimatedListKey) { if (animatedListKey == loadanimatedListKey) {
loadmessages.remove(message); loadmessages.remove(message);
animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();});
} else { } else {
newmessages.remove(message); newmessages.remove(message);
animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();}); animatedListKey.currentState?.removeItem(index, (context, animation) {return Container();});
} }
Navigator.pop(context); SmartDialog.dismiss(status: SmartStatus.attach);
}, },
child: Column( child: Column(
children: [ children: [
Image.asset( Image.asset(
"assets/image/icon_chat_delete.webp", "assets/image/icon_chat_delete.webp",
height: 16, height: 16,
width: 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,
), ),
), 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( Image.asset(
"assets/image/icon_copy_j.webp", "assets/image/icon_copy_j.webp",
height: 17, height: 17,
fit: BoxFit.fill,
width: 17, width: 17,
), ),
], ],

Loading…
Cancel
Save