|
|
|
@ -1,18 +1,46 @@ |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
import '../../model/rtc/chat_audio_product_model.dart'; |
|
|
|
|
|
|
|
/// 通话类型选择弹框 |
|
|
|
class CallTypeSelectionDialog extends StatelessWidget { |
|
|
|
final VoidCallback? onVoiceCall; |
|
|
|
final VoidCallback? onVideoCall; |
|
|
|
final List<ChatAudioProductModel>? products; |
|
|
|
|
|
|
|
const CallTypeSelectionDialog({ |
|
|
|
super.key, |
|
|
|
this.onVoiceCall, |
|
|
|
this.onVideoCall, |
|
|
|
this.products, |
|
|
|
}); |
|
|
|
|
|
|
|
/// 根据子分类获取产品(2102=语音通话,2103=视频通话) |
|
|
|
ChatAudioProductModel? _getProductBySubCategory(int subCategory) { |
|
|
|
if (products == null || products!.isEmpty) return null; |
|
|
|
try { |
|
|
|
return products!.firstWhere( |
|
|
|
(product) => product.subCategory == subCategory, |
|
|
|
); |
|
|
|
} catch (e) { |
|
|
|
// 如果找不到匹配的产品,返回 null |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// 获取语音通话产品 |
|
|
|
ChatAudioProductModel? get voiceProduct => _getProductBySubCategory(2102); |
|
|
|
|
|
|
|
/// 获取视频通话产品 |
|
|
|
ChatAudioProductModel? get videoProduct => _getProductBySubCategory(2103); |
|
|
|
|
|
|
|
/// 格式化价格显示 |
|
|
|
String _formatPrice(ChatAudioProductModel? product) { |
|
|
|
if (product == null) return '35玫瑰/分钟'; |
|
|
|
return '${product.unitSellingPrice.toInt()}玫瑰/分钟'; |
|
|
|
} |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Container( |
|
|
|
@ -37,7 +65,7 @@ class CallTypeSelectionDialog extends StatelessWidget { |
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.w), |
|
|
|
child: Center( |
|
|
|
child: Text( |
|
|
|
'语音通话 (35玫瑰/分钟)', |
|
|
|
'语音通话 (${_formatPrice(voiceProduct)})', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
color: const Color.fromRGBO(51, 51, 51, 1), |
|
|
|
@ -63,7 +91,7 @@ class CallTypeSelectionDialog extends StatelessWidget { |
|
|
|
padding: EdgeInsets.symmetric(vertical: 16.w), |
|
|
|
child: Center( |
|
|
|
child: Text( |
|
|
|
'视频通话 (35玫瑰/分钟)', |
|
|
|
'视频通话 (${_formatPrice(videoProduct)})', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 16.sp, |
|
|
|
color: const Color.fromRGBO(51, 51, 51, 1), |
|
|
|
|