|
|
|
@ -376,7 +376,9 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
body: Stack( |
|
|
|
body: SafeArea( |
|
|
|
top: false, |
|
|
|
child: Stack( |
|
|
|
children: [ |
|
|
|
IntroStepBuilder( |
|
|
|
group: 'ai', |
|
|
|
@ -429,8 +431,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
return _buildLoadMoreIndicator(); |
|
|
|
} |
|
|
|
|
|
|
|
final message = controller |
|
|
|
.messages[controller.messages.length - 1 - index]; |
|
|
|
final message = controller.messages[ |
|
|
|
controller.messages.length - 1 - index]; |
|
|
|
return index == 0 |
|
|
|
? IntroStepBuilder( |
|
|
|
group: 'ai', |
|
|
|
@ -450,8 +452,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
milliseconds: 300)); |
|
|
|
controller |
|
|
|
.noviceGuideService.aiStep++; |
|
|
|
Intro.of(Get.context!) |
|
|
|
.start(group: 'ai', reset: true); |
|
|
|
Intro.of(Get.context!).start( |
|
|
|
group: 'ai', reset: true); |
|
|
|
} |
|
|
|
}, |
|
|
|
onTap: () async { |
|
|
|
@ -463,8 +465,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
milliseconds: 300)); |
|
|
|
controller |
|
|
|
.noviceGuideService.aiStep++; |
|
|
|
Intro.of(Get.context!) |
|
|
|
.start(group: 'ai', reset: true); |
|
|
|
Intro.of(Get.context!).start( |
|
|
|
group: 'ai', reset: true); |
|
|
|
} |
|
|
|
}, |
|
|
|
); |
|
|
|
@ -530,7 +532,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
|
|
|
|
// 输入区域 |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h), |
|
|
|
padding: |
|
|
|
EdgeInsets.symmetric(horizontal: 16.w, vertical: 12.h), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: backgroundColor, |
|
|
|
boxShadow: [ |
|
|
|
@ -562,7 +565,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
ClipRRect( |
|
|
|
borderRadius: BorderRadius.circular(12.w), |
|
|
|
child: Image.file( |
|
|
|
File(controller.selectedImagePath.value!), |
|
|
|
File(controller |
|
|
|
.selectedImagePath.value!), |
|
|
|
height: 150.h, |
|
|
|
width: double.infinity, |
|
|
|
fit: BoxFit.cover, |
|
|
|
@ -572,7 +576,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
top: 8.h, |
|
|
|
right: 8.w, |
|
|
|
child: GestureDetector( |
|
|
|
onTap: () => controller.clearImageInput(), |
|
|
|
onTap: () => |
|
|
|
controller.clearImageInput(), |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.all(4.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
@ -601,7 +606,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
context: context, |
|
|
|
label: |
|
|
|
'summarizeImageContent'.tr, //总结图片内容 |
|
|
|
onTap: () => controller.summarizeImage(), |
|
|
|
onTap: () => |
|
|
|
controller.summarizeImage(), |
|
|
|
), |
|
|
|
SizedBox(width: 8.w), |
|
|
|
_buildPromptChip( |
|
|
|
@ -753,8 +759,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
controller.noviceGuideService |
|
|
|
.startAIGuide(); |
|
|
|
}, |
|
|
|
builder: |
|
|
|
(BuildContext context, GlobalKey key) => |
|
|
|
builder: (BuildContext context, |
|
|
|
GlobalKey key) => |
|
|
|
Container( |
|
|
|
key: key, |
|
|
|
constraints: BoxConstraints( |
|
|
|
@ -781,25 +787,28 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
), |
|
|
|
child: Obx(() { |
|
|
|
// 图片模式下使用更高的输入框 |
|
|
|
final isImageActive = |
|
|
|
controller.isImageInputActive.value; |
|
|
|
final isImageActive = controller |
|
|
|
.isImageInputActive.value; |
|
|
|
|
|
|
|
return TextField( |
|
|
|
focusNode: _textFocusNode, // 绑定焦点节点 |
|
|
|
controller: controller.textController, |
|
|
|
controller: |
|
|
|
controller.textController, |
|
|
|
maxLines: isImageActive |
|
|
|
? 3 |
|
|
|
: 5, // 设置合理的最大行数 |
|
|
|
minLines: isImageActive ? 2 : 1, |
|
|
|
keyboardType: |
|
|
|
TextInputType.multiline, // 启用多行键盘 |
|
|
|
textInputAction: |
|
|
|
TextInputAction.newline, // 支持回车换行 |
|
|
|
keyboardType: TextInputType |
|
|
|
.multiline, // 启用多行键盘 |
|
|
|
textInputAction: TextInputAction |
|
|
|
.newline, // 支持回车换行 |
|
|
|
onTap: () { |
|
|
|
// 当点击输入框时,如果'+'选项已展开,则收缩 |
|
|
|
if (controller |
|
|
|
.isPlusOptionsExpanded.value) { |
|
|
|
controller.collapsePlusOptions(); |
|
|
|
.isPlusOptionsExpanded |
|
|
|
.value) { |
|
|
|
controller |
|
|
|
.collapsePlusOptions(); |
|
|
|
} |
|
|
|
}, |
|
|
|
style: TextStyle( |
|
|
|
@ -812,7 +821,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
hintText: isImageActive |
|
|
|
? 'addQuestionAboutImage' |
|
|
|
.tr // 添加对图片的问题或描述... |
|
|
|
: 'inputMessage'.tr, // 输入消息... |
|
|
|
: 'inputMessage' |
|
|
|
.tr, // 输入消息... |
|
|
|
hintStyle: TextStyle( |
|
|
|
color: Colors.grey[500], |
|
|
|
fontSize: 15.sp, |
|
|
|
@ -938,9 +948,11 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
fontSize: 14, |
|
|
|
fontWeight: |
|
|
|
FontWeight.w500, |
|
|
|
color: isPushToTalkActive |
|
|
|
color: |
|
|
|
isPushToTalkActive |
|
|
|
? Colors.blue |
|
|
|
: Colors.grey[600], |
|
|
|
: Colors |
|
|
|
.grey[600], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
@ -978,11 +990,13 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
}, |
|
|
|
); |
|
|
|
}, |
|
|
|
builder: (BuildContext context, GlobalKey key) => |
|
|
|
builder: |
|
|
|
(BuildContext context, GlobalKey key) => |
|
|
|
Obx( |
|
|
|
key: key, |
|
|
|
() { |
|
|
|
final hasText = controller.hasTextInput.value; |
|
|
|
final hasText = |
|
|
|
controller.hasTextInput.value; |
|
|
|
final hasImage = |
|
|
|
controller.isImageInputActive.value; |
|
|
|
final shouldShowSend = hasText || hasImage; |
|
|
|
@ -1001,7 +1015,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
child: GestureDetector( |
|
|
|
onTap: () { |
|
|
|
// 打开底部弹出编辑模式 |
|
|
|
controller.openFullScreenEdit(); |
|
|
|
controller |
|
|
|
.openFullScreenEdit(); |
|
|
|
showModalBottomSheet( |
|
|
|
context: context, |
|
|
|
isScrollControlled: true, |
|
|
|
@ -1038,7 +1053,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
), |
|
|
|
// 发送按钮 |
|
|
|
GestureDetector( |
|
|
|
onTap: () => controller.sendMessage(), |
|
|
|
onTap: () => |
|
|
|
controller.sendMessage(), |
|
|
|
child: Container( |
|
|
|
width: 44.w, |
|
|
|
height: 44.w, |
|
|
|
@ -1134,7 +1150,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
label: 'takePhoto'.tr, // 拍照 |
|
|
|
onTap: () async { |
|
|
|
//controller.collapsePlusOptions(); |
|
|
|
await controller.takePhoto(); |
|
|
|
await controller |
|
|
|
.takePhoto(); |
|
|
|
}, |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
), |
|
|
|
@ -1145,7 +1162,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
label: 'photoAlbum'.tr, // 相册 |
|
|
|
onTap: () async { |
|
|
|
//controller.collapsePlusOptions(); |
|
|
|
await controller.pickImage(); |
|
|
|
await controller |
|
|
|
.pickImage(); |
|
|
|
}, |
|
|
|
isDarkMode: isDarkMode, |
|
|
|
), |
|
|
|
@ -1197,6 +1215,7 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
|
}), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|