|
|
|
@ -390,17 +390,6 @@ class AgentView extends StatelessWidget { |
|
|
|
); |
|
|
|
}), |
|
|
|
), |
|
|
|
GestureDetector( |
|
|
|
onTap: () => controller.sendMessage(), |
|
|
|
child: Container( |
|
|
|
padding: const EdgeInsets.all(6), |
|
|
|
child: Icon( |
|
|
|
Icons.send, |
|
|
|
color: primaryColor, |
|
|
|
size: 22, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
); |
|
|
|
@ -482,60 +471,87 @@ class AgentView extends StatelessWidget { |
|
|
|
|
|
|
|
const SizedBox(width: 8), |
|
|
|
|
|
|
|
// 图片选择按钮 |
|
|
|
Container( |
|
|
|
width: 44, |
|
|
|
height: 44, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isDarkMode ? Colors.grey[800] : Colors.grey[200], |
|
|
|
borderRadius: BorderRadius.circular(22), |
|
|
|
), |
|
|
|
child: PopupMenuButton<String>( |
|
|
|
icon: Icon( |
|
|
|
Icons.add_photo_alternate_outlined, |
|
|
|
color: |
|
|
|
isDarkMode ? Colors.grey[300] : Colors.grey[700], |
|
|
|
size: 22, |
|
|
|
), |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12), |
|
|
|
), |
|
|
|
onSelected: (value) async { |
|
|
|
if (value == 'camera') { |
|
|
|
await controller.takePhoto(); |
|
|
|
} else if (value == 'gallery') { |
|
|
|
await controller.pickImage(); |
|
|
|
} |
|
|
|
}, |
|
|
|
itemBuilder: (context) => [ |
|
|
|
PopupMenuItem<String>( |
|
|
|
value: 'camera', |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Icon(Icons.camera_alt, |
|
|
|
color: primaryColor, size: 20), |
|
|
|
const SizedBox(width: 8), |
|
|
|
const Text('拍照', |
|
|
|
style: TextStyle(fontSize: 14)), |
|
|
|
], |
|
|
|
// 动态按钮:图片选择按钮 或 发送按钮 |
|
|
|
Obx(() { |
|
|
|
final hasText = controller.hasTextInput.value; |
|
|
|
final hasImage = controller.isImageInputActive.value; |
|
|
|
final shouldShowSend = hasText || hasImage; |
|
|
|
|
|
|
|
if (shouldShowSend) { |
|
|
|
// 显示发送按钮 |
|
|
|
return GestureDetector( |
|
|
|
onTap: () => controller.sendMessage(), |
|
|
|
child: Container( |
|
|
|
width: 44, |
|
|
|
height: 44, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: primaryColor, |
|
|
|
borderRadius: BorderRadius.circular(22), |
|
|
|
), |
|
|
|
child: const Icon( |
|
|
|
Icons.send, |
|
|
|
color: Colors.white, |
|
|
|
size: 22, |
|
|
|
), |
|
|
|
), |
|
|
|
PopupMenuItem<String>( |
|
|
|
value: 'gallery', |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Icon(Icons.photo_library, |
|
|
|
color: primaryColor, size: 20), |
|
|
|
const SizedBox(width: 8), |
|
|
|
const Text('从相册选择', |
|
|
|
style: TextStyle(fontSize: 14)), |
|
|
|
], |
|
|
|
); |
|
|
|
} else { |
|
|
|
// 显示图片选择按钮 |
|
|
|
return Container( |
|
|
|
width: 44, |
|
|
|
height: 44, |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isDarkMode ? Colors.grey[800] : Colors.grey[200], |
|
|
|
borderRadius: BorderRadius.circular(22), |
|
|
|
), |
|
|
|
child: PopupMenuButton<String>( |
|
|
|
icon: Icon( |
|
|
|
Icons.add_photo_alternate_outlined, |
|
|
|
color: |
|
|
|
isDarkMode ? Colors.grey[300] : Colors.grey[700], |
|
|
|
size: 22, |
|
|
|
), |
|
|
|
padding: EdgeInsets.zero, |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(12), |
|
|
|
), |
|
|
|
onSelected: (value) async { |
|
|
|
if (value == 'camera') { |
|
|
|
await controller.takePhoto(); |
|
|
|
} else if (value == 'gallery') { |
|
|
|
await controller.pickImage(); |
|
|
|
} |
|
|
|
}, |
|
|
|
itemBuilder: (context) => [ |
|
|
|
PopupMenuItem<String>( |
|
|
|
value: 'camera', |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Icon(Icons.camera_alt, |
|
|
|
color: primaryColor, size: 20), |
|
|
|
const SizedBox(width: 8), |
|
|
|
const Text('拍照', |
|
|
|
style: TextStyle(fontSize: 14)), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
PopupMenuItem<String>( |
|
|
|
value: 'gallery', |
|
|
|
child: Row( |
|
|
|
children: [ |
|
|
|
Icon(Icons.photo_library, |
|
|
|
color: primaryColor, size: 20), |
|
|
|
const SizedBox(width: 8), |
|
|
|
const Text('从相册选择', |
|
|
|
style: TextStyle(fontSize: 14)), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
}), |
|
|
|
], |
|
|
|
), |
|
|
|
], |
|
|
|
|