diff --git a/lib/src/widgets/recording_button.dart b/lib/src/widgets/recording_button.dart index 4e6b3ba..6ca1be8 100644 --- a/lib/src/widgets/recording_button.dart +++ b/lib/src/widgets/recording_button.dart @@ -159,7 +159,7 @@ class _RecordingButtonState extends State try { // 触觉反馈 await HapticFeedback.lightImpact(); - + // 播放点击动画 _animationController.forward().then((_) { _animationController.reverse(); @@ -168,7 +168,8 @@ class _RecordingButtonState extends State if (_isListening) { await _speechService.stopListening(); } else { - await _speechService.startListening(partialResults: widget.partialResults); + await _speechService.startListening( + partialResults: widget.partialResults); } } catch (e) { widget.onError?.call(SpeechRecognitionError( @@ -190,17 +191,19 @@ class _RecordingButtonState extends State @override Widget build(BuildContext context) { - final theme = Theme.of(context); - Color buttonColor; if (!widget.enabled || !_isInitialized) { - buttonColor = widget.disabledColor ?? Colors.grey; + buttonColor = widget.disabledColor ?? Colors.grey[400]!; } else if (_isProcessing) { - buttonColor = (widget.idleColor ?? theme.primaryColor).withValues(alpha: 0.7); + buttonColor = _isListening + ? (widget.recordingColor ?? const Color(0xFFFF5252)) + .withValues(alpha: 0.7) + : (widget.idleColor ?? const Color(0xFF2196F3)) + .withValues(alpha: 0.7); } else if (_isListening) { - buttonColor = widget.recordingColor ?? Colors.red; + buttonColor = widget.recordingColor ?? const Color(0xFFFF5252); // 红色停止按钮 } else { - buttonColor = widget.idleColor ?? theme.primaryColor; + buttonColor = widget.idleColor ?? const Color(0xFF2196F3); // 蓝色录音按钮 } Widget button = AnimatedBuilder( @@ -213,12 +216,13 @@ class _RecordingButtonState extends State height: widget.size, decoration: BoxDecoration( color: buttonColor, - shape: BoxShape.circle, + shape: _isListening ? BoxShape.rectangle : BoxShape.circle, + borderRadius: _isListening ? BorderRadius.circular(12) : null, boxShadow: [ BoxShadow( color: buttonColor.withValues(alpha: 0.3), - blurRadius: _isListening ? 20 : 8, - spreadRadius: _isListening ? 5 : 2, + blurRadius: _isListening ? 20 : 12, + spreadRadius: _isListening ? 5 : 3, ), ], ), @@ -233,12 +237,13 @@ class _RecordingButtonState extends State height: widget.size * 0.4, child: CircularProgressIndicator( strokeWidth: 2, - valueColor: AlwaysStoppedAnimation(Colors.white), + valueColor: + AlwaysStoppedAnimation(Colors.white), ), ) : Icon( - _isListening ? Icons.stop : Icons.mic, - size: widget.size * 0.4, + _isListening ? Icons.stop_rounded : Icons.mic_rounded, + size: widget.size * (_isListening ? 0.35 : 0.4), color: Colors.white, ), ),