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/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<ChatDetailsPage>
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<ChatDetailsPage>
),
key: _buttonKey,
padding: EdgeInsets.symmetric(
vertical: 6,
vertical: 6.h,
horizontal: 12.w,
),
child: Text(
@ -877,7 +878,7 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
),
key: _buttonKey,
padding: EdgeInsets.symmetric(
vertical: 6,
vertical: 6.h,
horizontal: 12.w,
),
child: Text(
@ -1073,217 +1074,104 @@ class _ChatDetailsPage extends State<ChatDetailsPage>
///
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,
),
],

Loading…
Cancel
Save