|
|
@@ -254,7 +254,7 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
child: IntrinsicWidth(
|
|
|
child: progressingChatItem == null
|
|
|
? _buildAssistantChatItemContent(
|
|
|
- null, null, chatItem.content, chatItem.id)
|
|
|
+ true, null, null, chatItem.content, chatItem.id)
|
|
|
: Obx(() {
|
|
|
bool? isStreamStarted = progressingChatItem == null
|
|
|
? null
|
|
|
@@ -262,6 +262,7 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
progressingChatItem.isFinished.value ||
|
|
|
progressingChatItem.isFailed.value;
|
|
|
return _buildAssistantChatItemContent(
|
|
|
+ progressingChatItem?.isFinished.value,
|
|
|
isStreamStarted,
|
|
|
progressingChatItem?.graduallyController,
|
|
|
progressingChatItem!.isFailed.value
|
|
|
@@ -273,60 +274,42 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- Widget _buildAssistantChatItemContent(bool? isStreamStarted,
|
|
|
+ Widget _buildAssistantChatItemContent(bool? isFinish, bool? isStreamStarted,
|
|
|
GraduallyController? graduallyController, String? content, String id) {
|
|
|
return Column(
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
children: [
|
|
|
SizedBox(height: 10.h),
|
|
|
- isStreamStarted != null && isStreamStarted == false
|
|
|
- ? Container(
|
|
|
- padding: const EdgeInsets.all(1),
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: ColorName.colorPrimary,
|
|
|
- gradient: LinearGradient(
|
|
|
- colors: ['#B57AFF'.toColor(), '#4466FF'.toColor()],
|
|
|
- stops: const [0, 1.0],
|
|
|
- begin: Alignment.topLeft,
|
|
|
- end: Alignment.bottomRight,
|
|
|
- ),
|
|
|
- borderRadius: BorderRadius.only(
|
|
|
- topRight: Radius.circular(20.w),
|
|
|
- bottomRight: Radius.circular(20.w),
|
|
|
- bottomLeft: Radius.circular(20.w))),
|
|
|
- child: Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
- color: ColorName.white,
|
|
|
- borderRadius: BorderRadius.only(
|
|
|
- topRight: Radius.circular(20.w),
|
|
|
- bottomRight: Radius.circular(20.w),
|
|
|
- bottomLeft: Radius.circular(20.w))),
|
|
|
- padding:
|
|
|
- EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
|
|
|
- child: Lottie.asset(
|
|
|
- "assets/anim/anim_chat_response_loading.zip",
|
|
|
- width: 46.w,
|
|
|
- height: 20.w)),
|
|
|
- )
|
|
|
- : Container(
|
|
|
+ if (isStreamStarted != null && isStreamStarted == false)
|
|
|
+ Container(
|
|
|
+ padding: const EdgeInsets.all(1),
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: ColorName.colorPrimary,
|
|
|
+ gradient: LinearGradient(
|
|
|
+ colors: ['#B57AFF'.toColor(), '#4466FF'.toColor()],
|
|
|
+ stops: const [0, 1.0],
|
|
|
+ begin: Alignment.topLeft,
|
|
|
+ end: Alignment.bottomRight,
|
|
|
+ ),
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topRight: Radius.circular(20.w),
|
|
|
+ bottomRight: Radius.circular(20.w),
|
|
|
+ bottomLeft: Radius.circular(20.w))),
|
|
|
+ child: Container(
|
|
|
decoration: BoxDecoration(
|
|
|
color: ColorName.white,
|
|
|
- border: Border.all(color: '#ECECEC'.color, width: 1.w),
|
|
|
borderRadius: BorderRadius.only(
|
|
|
topRight: Radius.circular(20.w),
|
|
|
bottomRight: Radius.circular(20.w),
|
|
|
bottomLeft: Radius.circular(20.w))),
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
|
|
|
- alignment: Alignment.centerLeft,
|
|
|
- constraints: BoxConstraints(
|
|
|
- maxWidth: 0.78.sw,
|
|
|
- ),
|
|
|
- child: GraduallyMdText(
|
|
|
- initTxt: content,
|
|
|
- graduallyController: graduallyController,
|
|
|
- textStyle: TextStyle(
|
|
|
- fontSize: 14.w, color: ColorName.primaryTextColor)),
|
|
|
- ),
|
|
|
+ child: Lottie.asset(
|
|
|
+ "assets/anim/anim_chat_response_loading.zip",
|
|
|
+ width: 46.w,
|
|
|
+ height: 20.w)),
|
|
|
+ )
|
|
|
+ else
|
|
|
+ _buildAiContent(isFinish, content, graduallyController),
|
|
|
Obx(() {
|
|
|
return Visibility(
|
|
|
visible: id == controller.chatAiTagId.value,
|
|
|
@@ -351,6 +334,58 @@ class ChatPage extends BasePage<ChatController> {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
+ Widget _buildAiContent(bool? isFinish, String? content,
|
|
|
+ GraduallyController? graduallyController) {
|
|
|
+ if (isFinish == true) {
|
|
|
+ return Row(
|
|
|
+ crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
+ children: [
|
|
|
+ IntrinsicWidth(
|
|
|
+ child: _buildGraduallyMdText(content, graduallyController),
|
|
|
+ ),
|
|
|
+ SizedBox(width: 10.w),
|
|
|
+ Visibility(
|
|
|
+ visible: isFinish == true,
|
|
|
+ child: Padding(
|
|
|
+ padding: EdgeInsets.only(bottom: 4.w),
|
|
|
+ child: GestureDetector(
|
|
|
+ onTap: () {
|
|
|
+ controller.onCopyClick(content);
|
|
|
+ },
|
|
|
+ child: Assets.images.iconChatCopy
|
|
|
+ .image(width: 28.w, height: 28.w)),
|
|
|
+ ),
|
|
|
+ )
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return _buildGraduallyMdText(content, graduallyController);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Widget _buildGraduallyMdText(
|
|
|
+ String? content, GraduallyController? graduallyController) {
|
|
|
+ return Container(
|
|
|
+ decoration: BoxDecoration(
|
|
|
+ color: ColorName.white,
|
|
|
+ border: Border.all(color: '#ECECEC'.color, width: 1.w),
|
|
|
+ borderRadius: BorderRadius.only(
|
|
|
+ topRight: Radius.circular(20.w),
|
|
|
+ bottomRight: Radius.circular(20.w),
|
|
|
+ bottomLeft: Radius.circular(20.w))),
|
|
|
+ padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h),
|
|
|
+ alignment: Alignment.centerLeft,
|
|
|
+ constraints: BoxConstraints(
|
|
|
+ maxWidth: 0.78.sw,
|
|
|
+ ),
|
|
|
+ child: GraduallyMdText(
|
|
|
+ initTxt: content,
|
|
|
+ graduallyController: graduallyController,
|
|
|
+ textStyle:
|
|
|
+ TextStyle(fontSize: 14.w, color: ColorName.primaryTextColor)),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
Widget _buildUserChatItem(BuildContext context, ChatItem chatItem) {
|
|
|
if (chatItem is FileChatItem) {
|
|
|
return _buildUserFileChatItem(context, chatItem);
|