116 lines
3.8 KiB
Dart
116 lines
3.8 KiB
Dart
import 'package:cached_network_image/cached_network_image.dart';
|
|
import 'package:circle_app/app/chat/TIMUIKitChat/tim_uikit_chat.dart';
|
|
import 'package:circle_app/components/my_app_bar.dart';
|
|
import 'package:circle_app/util/util.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:tencent_cloud_chat_uikit/tencent_cloud_chat_uikit.dart';
|
|
|
|
import 'logic.dart';
|
|
|
|
class ChatPage extends StatelessWidget {
|
|
final logic = Get.find<ChatLogic>();
|
|
final state = Get.find<ChatLogic>().state;
|
|
|
|
|
|
ChatPage({Key? key})
|
|
: super(key: key);
|
|
|
|
Widget renderCustomStickerPanel({
|
|
sendTextMessage,
|
|
sendFaceMessage,
|
|
deleteText,
|
|
addCustomEmojiText,
|
|
addText,
|
|
List<CustomEmojiFaceData> defaultCustomEmojiStickerList = const [],
|
|
double? height,
|
|
double? width
|
|
}) {
|
|
final defaultEmojiList =
|
|
defaultCustomEmojiStickerList.map((customEmojiPackage) {
|
|
return CustomStickerPackage(
|
|
name: customEmojiPackage.name,
|
|
baseUrl: "assets/custom_face_resource/${customEmojiPackage.name}",
|
|
isEmoji: customEmojiPackage.isEmoji,
|
|
isDefaultEmoji: true,
|
|
stickerList: customEmojiPackage.list
|
|
.asMap()
|
|
.keys
|
|
.map((idx) =>
|
|
CustomSticker(index: idx, name: customEmojiPackage.list[idx]))
|
|
.toList(),
|
|
menuItem: CustomSticker(
|
|
index: 0,
|
|
name: customEmojiPackage.icon,
|
|
));
|
|
}).toList();
|
|
return StickerPanel(
|
|
backgroundColor:Colors.transparent,
|
|
showBottomContainer: false,
|
|
sendTextMsg: sendTextMessage,
|
|
sendFaceMsg: (index, data) =>
|
|
sendFaceMessage(index + 1, (data.split("/")[3]).split("@")[0]),
|
|
deleteText: deleteText,
|
|
addText: addText,
|
|
addCustomEmojiText: addCustomEmojiText,
|
|
customStickerPackageList: [
|
|
...defaultEmojiList,
|
|
]);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TIMChat(
|
|
conversation: logic.selectedConversation!,
|
|
customStickerPanel: renderCustomStickerPanel,
|
|
config: const TIMUIKitChatConfig(
|
|
// 仅供演示,非全部配置项,实际使用中,可只传和默认项不同的参数,无需传入所有开关
|
|
isAllowClickAvatar: true,
|
|
isUseDefaultEmoji: true,
|
|
isAllowLongPressMessage: false,
|
|
isShowReadingStatus: true,
|
|
isShowGroupReadingStatus: true,
|
|
notificationTitle: "",
|
|
isUseMessageReaction: true,
|
|
groupReadReceiptPermissionList: [
|
|
GroupReceiptAllowType.work,
|
|
GroupReceiptAllowType.meeting,
|
|
GroupReceiptAllowType.public
|
|
],
|
|
),
|
|
customAppBar: MyAppBar(
|
|
centerTitle: logic.selectedConversation!.showName!,
|
|
actionWdiget: GestureDetector(
|
|
child: Text('TA的主页',style: TextStyle(color: Color(0xFF00FFF4),fontSize:12.sp,fontWeight: FontWeight.w500),),
|
|
),
|
|
onPressed: () {},
|
|
),
|
|
userAvatarBuilder: (BuildContext context, V2TimMessage message) {
|
|
return avatarWidget(message.faceUrl ?? 'http://qiniuyun.ikuayou.com/avatar/default/default_header.png');
|
|
},
|
|
);
|
|
}
|
|
|
|
avatarWidget(String url, {double width = 34}) {
|
|
return GestureDetector(
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Image.asset(
|
|
getCircleImage('avatar_bg'),
|
|
width: width.sp,
|
|
),
|
|
url.contains("http") ? ClipOval(
|
|
child: CachedNetworkImage(
|
|
imageUrl:url,
|
|
width: (width - 2).sp,
|
|
height: (width - 2).sp,
|
|
fit: BoxFit.cover,
|
|
),
|
|
) : Text(url,style: TextStyle(color: Color(0xffF756FF),fontSize: 12.sp),)
|
|
],
|
|
));
|
|
}
|
|
}
|