|
|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
import 'package:flutter_markdown_plus/flutter_markdown_plus.dart';
|
|
|
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
|
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
|
|
|
@ -89,7 +91,16 @@ class CopilotMessageBubble extends StatelessWidget {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
(26 + 8).width,
|
|
|
|
|
SizedBox.square(
|
|
|
|
|
dimension: (26 + 8).toScreenWidth,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
onPressed: () => message.content.copyToClipboard,
|
|
|
|
|
style: const ButtonStyle(tapTargetSize: MaterialTapTargetSize.shrinkWrap),
|
|
|
|
|
icon: Icon(Icons.copy_rounded, size: 18, color: AppColor.icon2Color(context)),
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
tooltip: "Copy",
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
@ -125,68 +136,87 @@ class CopilotMessageBubble extends StatelessWidget {
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
children: [
|
|
|
|
|
if (showHeader) ...[recipientHeader, 4.height] else 8.height,
|
|
|
|
|
Container(
|
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
|
margin: const EdgeInsets.only(left: 26 + 8, right: 26 + 8),
|
|
|
|
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.75),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AppColor.background(context),
|
|
|
|
|
border: Border.all(color: AppColor.borderColor(context)),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
if (showLoadingDots)
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
child: ThinkingOrb(
|
|
|
|
|
size: 48,
|
|
|
|
|
state: ThinkingOrbState.searching,
|
|
|
|
|
theme: context.isDark ? ThinkingOrbTheme.dark : ThinkingOrbTheme.light,
|
|
|
|
|
))
|
|
|
|
|
else
|
|
|
|
|
_buildMessageContent(context),
|
|
|
|
|
// if (message.content.isNotEmpty && message.images.isNotEmpty) 8.height,
|
|
|
|
|
// if (message.content.isNotEmpty)
|
|
|
|
|
// Text(
|
|
|
|
|
// message.content,
|
|
|
|
|
// style: AppTextStyles.bodyText2.copyWith(
|
|
|
|
|
// color: message.isError ? Colors.red : AppColor.white10,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
if (message.images.isNotEmpty) ...[
|
|
|
|
|
8.height,
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 90,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
itemCount: message.images.length,
|
|
|
|
|
separatorBuilder: (_, __) => 8.width,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
final img = message.images[index];
|
|
|
|
|
return Image.memory(
|
|
|
|
|
base64Decode(img.base64),
|
|
|
|
|
width: 100,
|
|
|
|
|
height: 100,
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
SizedBox.square(
|
|
|
|
|
dimension: (26 + 8).toScreenWidth,
|
|
|
|
|
child: IconButton(
|
|
|
|
|
onPressed: () => message.content.copyToClipboard,
|
|
|
|
|
style: const ButtonStyle(tapTargetSize: MaterialTapTargetSize.shrinkWrap),
|
|
|
|
|
icon: Icon(Icons.copy_rounded, size: 18, color: AppColor.icon2Color(context)),
|
|
|
|
|
constraints: const BoxConstraints(),
|
|
|
|
|
tooltip: "Copy",
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
Flexible(
|
|
|
|
|
fit: FlexFit.loose,
|
|
|
|
|
child: Container(
|
|
|
|
|
padding: const EdgeInsets.all(8),
|
|
|
|
|
margin: const EdgeInsets.only(left: 0, right: 26 + 8),
|
|
|
|
|
constraints: BoxConstraints(maxWidth: MediaQuery.of(context).size.width * 0.75),
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
color: AppColor.background(context),
|
|
|
|
|
border: Border.all(color: AppColor.borderColor(context)),
|
|
|
|
|
borderRadius: BorderRadius.circular(12),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
widthFactor: 1,
|
|
|
|
|
child: Text(
|
|
|
|
|
_timeText,
|
|
|
|
|
style: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
if (showLoadingDots)
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
|
child: ThinkingOrb(
|
|
|
|
|
size: 48,
|
|
|
|
|
state: ThinkingOrbState.searching,
|
|
|
|
|
theme: context.isDark ? ThinkingOrbTheme.dark : ThinkingOrbTheme.light,
|
|
|
|
|
))
|
|
|
|
|
else
|
|
|
|
|
_buildMessageContent(context),
|
|
|
|
|
// if (message.content.isNotEmpty && message.images.isNotEmpty) 8.height,
|
|
|
|
|
// if (message.content.isNotEmpty)
|
|
|
|
|
// Text(
|
|
|
|
|
// message.content,
|
|
|
|
|
// style: AppTextStyles.bodyText2.copyWith(
|
|
|
|
|
// color: message.isError ? Colors.red : AppColor.white10,
|
|
|
|
|
// ),
|
|
|
|
|
// ),
|
|
|
|
|
if (message.images.isNotEmpty) ...[
|
|
|
|
|
8.height,
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 90,
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
child: ListView.separated(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
itemCount: message.images.length,
|
|
|
|
|
separatorBuilder: (_, __) => 8.width,
|
|
|
|
|
itemBuilder: (context, index) {
|
|
|
|
|
final img = message.images[index];
|
|
|
|
|
return Image.memory(
|
|
|
|
|
base64Decode(img.base64),
|
|
|
|
|
width: 100,
|
|
|
|
|
height: 100,
|
|
|
|
|
fit: BoxFit.contain,
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
Align(
|
|
|
|
|
alignment: Alignment.centerRight,
|
|
|
|
|
widthFactor: 1,
|
|
|
|
|
child: Text(
|
|
|
|
|
_timeText,
|
|
|
|
|
style: AppTextStyles.textFieldLabelStyle.copyWith(color: AppColor.textColor(context)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
|