|
|
|
@ -235,8 +235,8 @@ class _VoiceItemState extends State<VoiceItem> with TickerProviderStateMixin { |
|
|
|
// 判断当前音频是否正在播放 |
|
|
|
final isPlaying = _playerManager.isPlaying(widget.messageId); |
|
|
|
|
|
|
|
// 检查是否有金币数值(只对接收的消息显示) |
|
|
|
final coinValue = _getCoinValue(); |
|
|
|
// 检查是否有金币信息(只对接收的消息显示) |
|
|
|
final revenueInfo = _getRevenueInfo(); |
|
|
|
|
|
|
|
return Column( |
|
|
|
children: [ |
|
|
|
@ -309,10 +309,10 @@ class _VoiceItemState extends State<VoiceItem> with TickerProviderStateMixin { |
|
|
|
_handlePlayPause(); |
|
|
|
}), |
|
|
|
// 金币标签(只对接收的消息显示) |
|
|
|
if (!widget.isSentByMe && coinValue != null) |
|
|
|
if (!widget.isSentByMe && revenueInfo != null) |
|
|
|
Padding( |
|
|
|
padding: EdgeInsets.only(top: 10.h), |
|
|
|
child: _buildCoinLabel(coinValue), |
|
|
|
child: _buildCoinLabel(revenueInfo), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
@ -355,15 +355,21 @@ class _VoiceItemState extends State<VoiceItem> with TickerProviderStateMixin { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取金币数值 |
|
|
|
double? _getCoinValue() { |
|
|
|
// 获取金币信息(从 revenueInfo 或 coin_value 中获取) |
|
|
|
String? _getRevenueInfo() { |
|
|
|
try { |
|
|
|
if (widget.message != null) { |
|
|
|
final attributes = widget.message!.attributes; |
|
|
|
if (attributes != null && attributes.containsKey('coin_value')) { |
|
|
|
if (attributes != null) { |
|
|
|
// 优先从 revenueInfo 获取 |
|
|
|
final revenueInfo = attributes['revenueInfo'] as String?; |
|
|
|
if (revenueInfo != null && revenueInfo.isNotEmpty) { |
|
|
|
return revenueInfo; |
|
|
|
} |
|
|
|
// 如果没有 revenueInfo,从 coin_value 获取(可能是之前存储的 revenueInfo 值) |
|
|
|
final coinValueStr = attributes['coin_value'] as String?; |
|
|
|
if (coinValueStr != null && coinValueStr.isNotEmpty) { |
|
|
|
return double.tryParse(coinValueStr); |
|
|
|
return coinValueStr; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -374,7 +380,7 @@ class _VoiceItemState extends State<VoiceItem> with TickerProviderStateMixin { |
|
|
|
} |
|
|
|
|
|
|
|
// 构建金币标签 |
|
|
|
Widget _buildCoinLabel(double coinValue) { |
|
|
|
Widget _buildCoinLabel(String revenueInfo) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 6.h), |
|
|
|
decoration: BoxDecoration( |
|
|
|
@ -391,7 +397,7 @@ class _VoiceItemState extends State<VoiceItem> with TickerProviderStateMixin { |
|
|
|
), |
|
|
|
SizedBox(width: 4.w), |
|
|
|
Text( |
|
|
|
'+${coinValue.toStringAsFixed(2)}', |
|
|
|
revenueInfo, |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 12.sp, |
|
|
|
color: Color.fromRGBO(255, 132, 0, 1), |
|
|
|
|