Browse Source

Merge commit '78db92847a7aabf0caa68e2b6fc4dc2245a66b8a' into 重写ble

newdev_shunjiawei
lxm 1 year ago
parent
commit
e47d569732
  1. 84
      lib/modules/agent/views/message_bubble.dart
  2. 19
      local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt

84
lib/modules/agent/views/message_bubble.dart

@ -56,34 +56,33 @@ class MessageBubble extends GetView<AgentController> {
crossAxisAlignment:
isUser ? CrossAxisAlignment.end : CrossAxisAlignment.start,
children: [
Container(
padding: (hasImage && message == '[图片]')
? EdgeInsets.zero
: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: _getBubbleColor(context),
borderRadius: BorderRadius.only(
topLeft: isUser
? const Radius.circular(18)
: const Radius.circular(4),
topRight: isUser
? const Radius.circular(4)
: const Radius.circular(18),
bottomLeft: const Radius.circular(18),
bottomRight: const Radius.circular(18),
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
blurRadius: 2,
offset: const Offset(0, 1),
Stack(
children: [
Container(
padding: (hasImage && message == '[图片]')
? EdgeInsets.zero
: const EdgeInsets.all(12),
decoration: BoxDecoration(
color: _getBubbleColor(context),
borderRadius: BorderRadius.only(
topLeft: isUser
? const Radius.circular(18)
: const Radius.circular(4),
topRight: isUser
? const Radius.circular(4)
: const Radius.circular(18),
bottomLeft: const Radius.circular(18),
bottomRight: const Radius.circular(18),
),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.05),
blurRadius: 2,
offset: const Offset(0, 1),
),
],
),
],
),
child: Stack(
children: [
// 主要消息内容
Padding(
child: Padding(
padding: (!isUser &&
functionCalls != null &&
functionCalls!.isNotEmpty)
@ -91,14 +90,15 @@ class MessageBubble extends GetView<AgentController> {
: EdgeInsets.zero,
child: _buildMessageContent(context),
),
//工具调用流程显示(仅在AI消息且有functionCalls时显示)
if (!isUser &&
functionCalls != null &&
functionCalls!.isNotEmpty)
_buildFunctionCallsWidget(context),
],
),
),
//工具调用流程显示(仅在AI消息且有functionCalls时显示)
if (!isUser &&
functionCalls != null &&
functionCalls!.isNotEmpty)
_buildFunctionCallsWidget(context),
],
),
const SizedBox(height: 4),
// 识别中的消息不显示时间
if (!isRecognizing)
@ -621,12 +621,17 @@ class MessageBubble extends GetView<AgentController> {
);
},
child: Container(
height: 20, // 增加固定高度,给字体更多空间
height: 30, // 增加固定高度,给字体更多空间
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[800]?.withOpacity(0.8)
? const Color.fromARGB(255, 71, 68, 68)
?.withOpacity(0.8)
: Colors.grey[100]?.withOpacity(0.9),
borderRadius: BorderRadius.circular(6),
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(6),
topRight: Radius.circular(6),
),
border: Border.all(
color: Theme.of(context).brightness == Brightness.dark
? Colors.white.withOpacity(0.1)
@ -682,7 +687,10 @@ class MessageBubble extends GetView<AgentController> {
color: Theme.of(context).brightness == Brightness.dark
? Colors.grey[900]?.withOpacity(0.95) // 深色模式下使用深灰色背景
: Colors.white.withOpacity(0.95), // 浅色模式下使用白色背景
borderRadius: BorderRadius.circular(4), // 减小圆角
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(6),
bottomRight: Radius.circular(6),
),
border: Border.all(
color: Theme.of(context).brightness == Brightness.dark
? Colors.white.withOpacity(0.2)

19
local_plugins/azure_speech/android/src/main/kotlin/com/yunqiinnovation/azure_speech/AzureSpeechPlugin.kt

@ -209,11 +209,12 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
try {
azureAsrHelper.setupEventListeners(object :
AzureAsrHelper.ContinuousRecognizeCallback {
override fun onResult(text: String, detectedLanguage: String) {
override fun onResult(sessionid:String,text: String, detectedLanguage: String) {
sendAsrEvent(
mapOf(
"type" to "result",
"sessionid" to sessionid,
"text" to text,
"detectedLanguage" to detectedLanguage
)
@ -222,6 +223,7 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
}
override fun onRecognizing(
sessionid:String,
recognizing: String,
detectedLanguage: String
) {
@ -229,26 +231,28 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
sendAsrEvent(
mapOf(
"type" to "recognizing",
"sessionid" to sessionid,
"text" to recognizing,
"detectedLanguage" to detectedLanguage
)
)
}
override fun onSessionStarted() {
sendAsrEvent(mapOf("type" to "sessionStarted"))
override fun onSessionStarted(sessionid:String) {
sendAsrEvent(mapOf("type" to "sessionStarted","sessionid" to sessionid,))
}
override fun onSessionStopped() {
sendAsrEvent(mapOf("type" to "sessionStopped"))
override fun onSessionStopped(sessionid:String) {
sendAsrEvent(mapOf("type" to "sessionStopped","sessionid" to sessionid,))
}
override fun onCanceled(reason: String, errorDetails: String) {
override fun onCanceled(sessionid:String,reason: String, errorDetails: String) {
sendAsrEvent(
mapOf(
"type" to "canceled",
"sessionid" to sessionid,
"reason" to reason,
"errorDetails" to errorDetails
)
@ -257,10 +261,11 @@ class AzureSpeechPlugin : BleService.Callback, FlutterPlugin {
}
override fun onError(code: Int, error: String) {
override fun onError(sessionid:String,code: Int, error: String) {
sendAsrEvent(
mapOf(
"type" to "error",
"sessionid" to sessionid,
"code" to code,
"message" to error
)

Loading…
Cancel
Save