|
|
@ -29,6 +29,77 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
// 👇 新增:用于控制 TextField 焦点 |
|
|
// 👇 新增:用于控制 TextField 焦点 |
|
|
final FocusNode _textFocusNode = FocusNode(); |
|
|
final FocusNode _textFocusNode = FocusNode(); |
|
|
|
|
|
|
|
|
|
|
|
void _showTtsSpeedDialog() { |
|
|
|
|
|
final primaryColor = Theme.of(context).primaryColor; |
|
|
|
|
|
final isDarkMode = Theme.of(context).brightness == Brightness.dark; |
|
|
|
|
|
final RxInt tempRate = controller.ttsRatePercent.value.obs; |
|
|
|
|
|
|
|
|
|
|
|
Get.dialog( |
|
|
|
|
|
AlertDialog( |
|
|
|
|
|
backgroundColor: isDarkMode ? Colors.grey[850] : Colors.white, |
|
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
|
borderRadius: BorderRadius.circular(12.w), |
|
|
|
|
|
), |
|
|
|
|
|
title: Text( |
|
|
|
|
|
'ttsSpeed'.tr, // 语速 |
|
|
|
|
|
style: TextStyle(fontSize: 16.sp), |
|
|
|
|
|
), |
|
|
|
|
|
content: Obx(() { |
|
|
|
|
|
return Column( |
|
|
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
|
|
children: [ |
|
|
|
|
|
Align( |
|
|
|
|
|
alignment: Alignment.centerLeft, |
|
|
|
|
|
child: Text( |
|
|
|
|
|
'ttsSpeedDefaultHint'.tr, // 默认 +25% |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
|
color: isDarkMode ? Colors.grey[400] : Colors.grey[600], |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
SizedBox(height: 12.h), |
|
|
|
|
|
Text( |
|
|
|
|
|
'+${tempRate.value}%', |
|
|
|
|
|
style: TextStyle( |
|
|
|
|
|
fontSize: 20.sp, |
|
|
|
|
|
fontWeight: FontWeight.w600, |
|
|
|
|
|
color: primaryColor, |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
SizedBox(height: 8.h), |
|
|
|
|
|
Slider( |
|
|
|
|
|
value: tempRate.value.toDouble(), |
|
|
|
|
|
min: 0, |
|
|
|
|
|
max: 100, |
|
|
|
|
|
divisions: 20, |
|
|
|
|
|
label: '+${tempRate.value}%', |
|
|
|
|
|
activeColor: primaryColor, |
|
|
|
|
|
onChanged: (value) { |
|
|
|
|
|
tempRate.value = value.round(); |
|
|
|
|
|
}, |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
); |
|
|
|
|
|
}), |
|
|
|
|
|
actions: [ |
|
|
|
|
|
TextButton( |
|
|
|
|
|
onPressed: () => Get.back(), |
|
|
|
|
|
child: Text('cancel'.tr), |
|
|
|
|
|
), |
|
|
|
|
|
TextButton( |
|
|
|
|
|
onPressed: () async { |
|
|
|
|
|
Get.back(); |
|
|
|
|
|
await controller.updateTtsRate(tempRate.value); |
|
|
|
|
|
}, |
|
|
|
|
|
child: Text('confirm'.tr), |
|
|
|
|
|
), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
barrierDismissible: true, |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@override |
|
|
@override |
|
|
void initState() { |
|
|
void initState() { |
|
|
super.initState(); |
|
|
super.initState(); |
|
|
@ -86,7 +157,7 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
borderRadius: BorderRadius.circular(20.w), |
|
|
borderRadius: BorderRadius.circular(20.w), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.1), |
|
|
color: Colors.black.withValues(alpha: 0.1), |
|
|
blurRadius: 3.w, |
|
|
blurRadius: 3.w, |
|
|
offset: const Offset(0, 1), |
|
|
offset: const Offset(0, 1), |
|
|
), |
|
|
), |
|
|
@ -179,13 +250,14 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
height: 34.w, |
|
|
height: 34.w, |
|
|
margin: EdgeInsets.only(right: 8.w), |
|
|
margin: EdgeInsets.only(right: 8.w), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: |
|
|
color: isDarkMode |
|
|
isDarkMode ? Colors.white.withOpacity(0.1) : Colors.grey[100], |
|
|
? Colors.white.withValues(alpha: 0.1) |
|
|
|
|
|
: Colors.grey[100], |
|
|
shape: BoxShape.circle, |
|
|
shape: BoxShape.circle, |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
if (!isDarkMode) |
|
|
if (!isDarkMode) |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.05), |
|
|
color: Colors.black.withValues(alpha: 0.05), |
|
|
blurRadius: 2.w, |
|
|
blurRadius: 2.w, |
|
|
spreadRadius: 0.5.w, |
|
|
spreadRadius: 0.5.w, |
|
|
), |
|
|
), |
|
|
@ -268,6 +340,21 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
onTap: () => controller.toggleTtsInterrupt(), |
|
|
onTap: () => controller.toggleTtsInterrupt(), |
|
|
), |
|
|
), |
|
|
|
|
|
|
|
|
|
|
|
PopupMenuItem( |
|
|
|
|
|
child: Row( |
|
|
|
|
|
children: [ |
|
|
|
|
|
Icon(Icons.speed, color: primaryColor, size: 20.sp), |
|
|
|
|
|
SizedBox(width: 8.w), |
|
|
|
|
|
Text('ttsSpeed'.tr, // 语速 |
|
|
|
|
|
style: TextStyle(fontSize: 14.sp)), |
|
|
|
|
|
], |
|
|
|
|
|
), |
|
|
|
|
|
onTap: () => Future.delayed( |
|
|
|
|
|
const Duration(milliseconds: 100), |
|
|
|
|
|
() => _showTtsSpeedDialog(), |
|
|
|
|
|
), |
|
|
|
|
|
), |
|
|
|
|
|
|
|
|
// 清除聊天记录选项 |
|
|
// 清除聊天记录选项 |
|
|
PopupMenuItem( |
|
|
PopupMenuItem( |
|
|
child: Row( |
|
|
child: Row( |
|
|
@ -448,14 +535,14 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
color: backgroundColor, |
|
|
color: backgroundColor, |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: Colors.black.withOpacity(0.06), |
|
|
color: Colors.black.withValues(alpha: 0.06), |
|
|
blurRadius: 8.w, |
|
|
blurRadius: 8.w, |
|
|
offset: const Offset(0, -1), |
|
|
offset: const Offset(0, -1), |
|
|
), |
|
|
), |
|
|
], |
|
|
], |
|
|
border: Border( |
|
|
border: Border( |
|
|
top: BorderSide( |
|
|
top: BorderSide( |
|
|
color: Colors.grey.withOpacity(0.15), |
|
|
color: Colors.grey.withValues(alpha: 0.15), |
|
|
width: 1.w, |
|
|
width: 1.w, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
@ -489,7 +576,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
child: Container( |
|
|
child: Container( |
|
|
padding: EdgeInsets.all(4.w), |
|
|
padding: EdgeInsets.all(4.w), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: Colors.black.withOpacity(0.6), |
|
|
color: Colors.black |
|
|
|
|
|
.withValues(alpha: 0.6), |
|
|
shape: BoxShape.circle, |
|
|
shape: BoxShape.circle, |
|
|
), |
|
|
), |
|
|
child: Icon( |
|
|
child: Icon( |
|
|
@ -635,7 +723,7 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
final isTextMode = |
|
|
final isTextMode = |
|
|
controller.isTextInputMode.value; |
|
|
controller.isTextInputMode.value; |
|
|
|
|
|
|
|
|
if (controller.isTextInputMode.value) { |
|
|
if (isTextMode) { |
|
|
// 文本输入模式 - 限制最大高度并只向上扩展 |
|
|
// 文本输入模式 - 限制最大高度并只向上扩展 |
|
|
return IntroStepBuilder( |
|
|
return IntroStepBuilder( |
|
|
group: 'ai', |
|
|
group: 'ai', |
|
|
@ -686,7 +774,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
border: Border.all( |
|
|
border: Border.all( |
|
|
color: isDarkMode |
|
|
color: isDarkMode |
|
|
? Colors.grey[800]! |
|
|
? Colors.grey[800]! |
|
|
: Colors.grey.withOpacity(0.1), |
|
|
: Colors.grey |
|
|
|
|
|
.withValues(alpha: 0.1), |
|
|
width: 1.w, |
|
|
width: 1.w, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
@ -748,7 +837,6 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
), |
|
|
), |
|
|
); |
|
|
); |
|
|
} else { |
|
|
} else { |
|
|
Timer? _holdTimer; // 增加延迟触发的计时器 |
|
|
|
|
|
// 语音输入模式 - 按住说话模式 |
|
|
// 语音输入模式 - 按住说话模式 |
|
|
return Listener( |
|
|
return Listener( |
|
|
onPointerDown: (_) { |
|
|
onPointerDown: (_) { |
|
|
@ -775,8 +863,6 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
child: Obx(() { |
|
|
child: Obx(() { |
|
|
final isPushToTalkActive = |
|
|
final isPushToTalkActive = |
|
|
controller.isPushToTalkActive.value; |
|
|
controller.isPushToTalkActive.value; |
|
|
final isListening = |
|
|
|
|
|
controller.isListening.value; |
|
|
|
|
|
|
|
|
|
|
|
return Container( |
|
|
return Container( |
|
|
height: 48.w, |
|
|
height: 48.w, |
|
|
@ -795,8 +881,8 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
BorderRadius.circular(22.w), |
|
|
BorderRadius.circular(22.w), |
|
|
boxShadow: [ |
|
|
boxShadow: [ |
|
|
BoxShadow( |
|
|
BoxShadow( |
|
|
color: |
|
|
color: Colors.black |
|
|
Colors.black.withOpacity(0.2), |
|
|
.withValues(alpha: 0.2), |
|
|
spreadRadius: 1, |
|
|
spreadRadius: 1, |
|
|
blurRadius: 2, |
|
|
blurRadius: 2, |
|
|
offset: const Offset(0, 1), |
|
|
offset: const Offset(0, 1), |
|
|
@ -1127,10 +1213,10 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver { |
|
|
child: Container( |
|
|
child: Container( |
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h), |
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h), |
|
|
decoration: BoxDecoration( |
|
|
decoration: BoxDecoration( |
|
|
color: primaryColor.withOpacity(0.08), |
|
|
color: primaryColor.withValues(alpha: 0.08), |
|
|
borderRadius: BorderRadius.circular(16.w), |
|
|
borderRadius: BorderRadius.circular(16.w), |
|
|
border: Border.all( |
|
|
border: Border.all( |
|
|
color: primaryColor.withOpacity(0.2), |
|
|
color: primaryColor.withValues(alpha: 0.2), |
|
|
width: 1.w, |
|
|
width: 1.w, |
|
|
), |
|
|
), |
|
|
), |
|
|
), |
|
|
|