|
|
@@ -1,5 +1,8 @@
|
|
|
import 'package:electronic_assistant/base/base_page.dart';
|
|
|
+import 'package:electronic_assistant/data/bean/agenda.dart';
|
|
|
import 'package:electronic_assistant/data/bean/chat_item.dart';
|
|
|
+import 'package:electronic_assistant/data/bean/file_chat_item.dart';
|
|
|
+import 'package:electronic_assistant/data/bean/reference_chat_item.dart';
|
|
|
import 'package:electronic_assistant/module/chat/controller.dart';
|
|
|
import 'package:electronic_assistant/resource/colors.gen.dart';
|
|
|
import 'package:electronic_assistant/utils/expand.dart';
|
|
|
@@ -12,11 +15,25 @@ import 'package:lottie/lottie.dart';
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
|
|
|
|
import '../../data/bean/progressing_chat_item.dart';
|
|
|
+import '../../data/bean/talk_info.dart';
|
|
|
import '../../resource/assets.gen.dart';
|
|
|
+import '../../router/app_pages.dart';
|
|
|
|
|
|
class ChatPage extends BasePage<ChatController> {
|
|
|
const ChatPage({super.key});
|
|
|
|
|
|
+ static start() {
|
|
|
+ Get.toNamed(RoutePath.chat);
|
|
|
+ }
|
|
|
+
|
|
|
+ static startByTalk(TalkInfo talkInfo, {Agenda? agenda}) {
|
|
|
+ Get.toNamed(RoutePath.chat, arguments: [talkInfo, agenda]);
|
|
|
+ }
|
|
|
+
|
|
|
+ static startByTalkId(String talkId, {Agenda? agenda}) {
|
|
|
+ Get.toNamed(RoutePath.chat, arguments: [talkId, agenda]);
|
|
|
+ }
|
|
|
+
|
|
|
@override
|
|
|
bool immersive() {
|
|
|
return true;
|
|
|
@@ -34,8 +51,8 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
|
|
|
return Stack(
|
|
|
children: [
|
|
|
- buildBackgroundGradient(),
|
|
|
- buildTopGradient(),
|
|
|
+ _buildBackgroundGradient(),
|
|
|
+ _buildTopGradient(),
|
|
|
Scaffold(
|
|
|
backgroundColor: Colors.transparent,
|
|
|
appBar: AppBar(
|
|
|
@@ -139,6 +156,14 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 14),
|
|
|
child: Column(
|
|
|
children: [
|
|
|
+ Obx(() {
|
|
|
+ TalkInfo? talkInfo = controller.talkInfo.value;
|
|
|
+ if (talkInfo == null) {
|
|
|
+ return Container();
|
|
|
+ } else {
|
|
|
+ return _buildReferenceFile(talkInfo);
|
|
|
+ }
|
|
|
+ }),
|
|
|
Row(
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
children: [
|
|
|
@@ -170,7 +195,7 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
margin: EdgeInsets.only(left: 16.w),
|
|
|
child: GestureDetector(
|
|
|
onTap: () {
|
|
|
- controller.sendMessage();
|
|
|
+ controller.onSendClick();
|
|
|
},
|
|
|
child: Image(
|
|
|
image: Assets.images.iconChatSend.provider(),
|
|
|
@@ -232,7 +257,7 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
margin: EdgeInsets.symmetric(vertical: 10.h),
|
|
|
alignment: Alignment.centerLeft,
|
|
|
constraints: BoxConstraints(
|
|
|
- maxWidth: 0.78.sw, // 65% of screen width
|
|
|
+ maxWidth: 0.78.sw,
|
|
|
),
|
|
|
decoration: BoxDecoration(
|
|
|
border: isStreamStarted == null || isStreamStarted == true
|
|
|
@@ -253,30 +278,226 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
}
|
|
|
|
|
|
Widget _buildUserChatItem(BuildContext context, ChatItem chatItem) {
|
|
|
+ if (chatItem is FileChatItem) {
|
|
|
+ return _buildUserFileChatItem(context, chatItem);
|
|
|
+ } else if (chatItem is ReferenceChatItem) {
|
|
|
+ return _buildUserNormalChatItem(context, chatItem,
|
|
|
+ referenceTalkTitle: chatItem.talkInfo.title);
|
|
|
+ }
|
|
|
+ return _buildUserNormalChatItem(context, chatItem,
|
|
|
+ referenceTalkTitle: chatItem.talkTitle);
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildUserNormalChatItem(BuildContext context, ChatItem chatItem,
|
|
|
+ {String? referenceTalkTitle}) {
|
|
|
return Align(
|
|
|
alignment: Alignment.centerRight,
|
|
|
- child: IntrinsicWidth(
|
|
|
- child: Container(
|
|
|
- padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
|
|
|
- margin: EdgeInsets.symmetric(vertical: 10.h),
|
|
|
- alignment: Alignment.centerRight,
|
|
|
- constraints: BoxConstraints(
|
|
|
- maxWidth: 0.78.sw, // 65% of screen width
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
+ children: [
|
|
|
+ IntrinsicWidth(
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
|
|
|
+ margin: referenceTalkTitle == null
|
|
|
+ ? EdgeInsets.symmetric(vertical: 10.h)
|
|
|
+ : EdgeInsets.only(top: 10.h),
|
|
|
+ alignment: Alignment.centerRight,
|
|
|
+ constraints: BoxConstraints(
|
|
|
+ maxWidth: 0.78.sw,
|
|
|
+ ),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: ColorName.colorPrimary,
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topLeft: Radius.circular(16.w),
|
|
|
+ bottomRight: Radius.circular(16.w),
|
|
|
+ bottomLeft: Radius.circular(16.w))),
|
|
|
+ child: Text(chatItem.content,
|
|
|
+ style: TextStyle(fontSize: 14.w, color: ColorName.white)),
|
|
|
+ ),
|
|
|
),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: ColorName.colorPrimary,
|
|
|
- borderRadius: BorderRadius.only(
|
|
|
- topLeft: Radius.circular(16.w),
|
|
|
- bottomRight: Radius.circular(16.w),
|
|
|
- bottomLeft: Radius.circular(16.w))),
|
|
|
- child: Text(chatItem.content,
|
|
|
- style: TextStyle(fontSize: 14.w, color: ColorName.white)),
|
|
|
+ if (referenceTalkTitle != null)
|
|
|
+ Container(
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
|
|
|
+ margin: EdgeInsets.only(top: 8.h, bottom: 10.h),
|
|
|
+ constraints: BoxConstraints(
|
|
|
+ maxWidth: 0.78.sw,
|
|
|
+ ),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: "#EFEFEF".color,
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(10.w))),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Image(
|
|
|
+ image: Assets.images.iconReferenceChatArrow.provider(),
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.w),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(right: 2.w, left: 4.w),
|
|
|
+ child: Image(
|
|
|
+ image: Assets.images.iconReferenceChatFile.provider(),
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.w),
|
|
|
+ ),
|
|
|
+ Text(referenceTalkTitle,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.w,
|
|
|
+ color: ColorName.secondaryTextColor,
|
|
|
+ overflow: TextOverflow.ellipsis)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildUserFileChatItem(BuildContext context, FileChatItem chatItem) {
|
|
|
+ return Align(
|
|
|
+ alignment: Alignment.centerRight,
|
|
|
+ child: Container(
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 16.h),
|
|
|
+ margin: EdgeInsets.symmetric(vertical: 10.h),
|
|
|
+ constraints: BoxConstraints(
|
|
|
+ maxWidth: 0.56.sw,
|
|
|
+ ),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: ColorName.white,
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topLeft: Radius.circular(16.w),
|
|
|
+ bottomRight: Radius.circular(16.w),
|
|
|
+ bottomLeft: Radius.circular(16.w)),
|
|
|
+ border: Border.all(color: "#ECECEC".color, width: 1.w),
|
|
|
),
|
|
|
+ child: Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.center,
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(right: 6.w),
|
|
|
+ child: Image(
|
|
|
+ image: Assets.images.iconFilesFile.provider(),
|
|
|
+ width: 30.w,
|
|
|
+ height: 32.w),
|
|
|
+ ),
|
|
|
+ Flexible(
|
|
|
+ child: Column(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
+ children: [
|
|
|
+ Text(chatItem.talkInfo.title ?? '',
|
|
|
+ maxLines: 1,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 14.w,
|
|
|
+ color: ColorName.primaryTextColor,
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ overflow: TextOverflow.ellipsis)),
|
|
|
+ Text(chatItem.talkInfo.summary ?? '',
|
|
|
+ maxLines: 1,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.w,
|
|
|
+ color: ColorName.secondaryTextColor,
|
|
|
+ overflow: TextOverflow.ellipsis)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ _buildReferenceFile(TalkInfo talkInfo) {
|
|
|
+ if (talkInfo.oversizeFile == true) {
|
|
|
+ return _buildOverSizeReference(talkInfo);
|
|
|
+ } else {
|
|
|
+ return _buildNormalReference(talkInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Container _buildOverSizeReference(TalkInfo talkInfo) {
|
|
|
+ return Container(
|
|
|
+ margin: EdgeInsets.only(bottom: 14.h),
|
|
|
+ padding: EdgeInsets.only(left: 8.w, top: 8.h, right: 10.w, bottom: 8.h),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ borderRadius: BorderRadius.all(Radius.circular(8.w)),
|
|
|
+ border: Border.all(color: "#F0F0F0".color, width: 1.w),
|
|
|
+ ),
|
|
|
+ child: Column(
|
|
|
+ children: [
|
|
|
+ Row(
|
|
|
+ children: [
|
|
|
+ Text(talkInfo.title ?? '',
|
|
|
+ style: TextStyle(
|
|
|
+ fontWeight: FontWeight.bold,
|
|
|
+ fontSize: 14.w,
|
|
|
+ color: ColorName.primaryTextColor)),
|
|
|
+ const Spacer(),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 8.w),
|
|
|
+ child: Image(
|
|
|
+ image: Assets.images.iconReferenceChatDeleteFile.provider(),
|
|
|
+ width: 18.w,
|
|
|
+ height: 18.w),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(top: 11.h),
|
|
|
+ child: Row(
|
|
|
+ children: [
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(right: 2.w),
|
|
|
+ child: Image(
|
|
|
+ image: Assets.images.iconReferenceChatFile.provider(),
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.w),
|
|
|
+ ),
|
|
|
+ Text("谈话·超长内容",
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.w, color: ColorName.tertiaryTextColor)),
|
|
|
+ ],
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
),
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget buildTopGradient() {
|
|
|
+ _buildNormalReference(TalkInfo talkInfo) {
|
|
|
+ return Row(
|
|
|
+ children: [
|
|
|
+ Image(
|
|
|
+ image: Assets.images.iconReferenceChatArrow.provider(),
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.w),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(right: 2.w, left: 4.w),
|
|
|
+ child: Image(
|
|
|
+ image: Assets.images.iconReferenceChatFile.provider(),
|
|
|
+ width: 16.w,
|
|
|
+ height: 16.w),
|
|
|
+ ),
|
|
|
+ Text(talkInfo.title ?? '',
|
|
|
+ overflow: TextOverflow.ellipsis,
|
|
|
+ maxLines: 1,
|
|
|
+ style: TextStyle(
|
|
|
+ fontSize: 12.w,
|
|
|
+ color: ColorName.primaryTextColor,
|
|
|
+ overflow: TextOverflow.ellipsis)),
|
|
|
+ const Spacer(),
|
|
|
+ Container(
|
|
|
+ margin: EdgeInsets.only(left: 8.w),
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: ()=> controller.onDeleteReference(),
|
|
|
+ child: Image(
|
|
|
+ image: Assets.images.iconReferenceChatDeleteFile.provider(),
|
|
|
+ width: 18.w,
|
|
|
+ height: 18.w),
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildTopGradient() {
|
|
|
return Container(
|
|
|
width: 1.sw,
|
|
|
height: 128.h,
|
|
|
@@ -290,7 +511,7 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
));
|
|
|
}
|
|
|
|
|
|
- Widget buildBackgroundGradient() {
|
|
|
+ Widget _buildBackgroundGradient() {
|
|
|
return Container(
|
|
|
width: 1.sw,
|
|
|
height: 1.sh,
|