|
|
|
@ -2,6 +2,7 @@ import 'dart:io'; |
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
import 'package:get/get.dart'; |
|
|
|
import '../controllers/agent_controller.dart'; |
|
|
|
import '../controllers/report_controller.dart'; |
|
|
|
import 'message_bubble.dart'; |
|
|
|
import 'package:flutter/services.dart'; |
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
@ -609,163 +610,187 @@ class AgentView extends StatelessWidget { |
|
|
|
isDarkMode ? Colors.red[700]! : Colors.red, |
|
|
|
() { |
|
|
|
// 实现举报功能 |
|
|
|
showModalBottomSheet( |
|
|
|
context: context, |
|
|
|
isScrollControlled: true, // 关键:允许弹窗随键盘移动 |
|
|
|
backgroundColor: |
|
|
|
isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16.r)), |
|
|
|
), |
|
|
|
builder: (BuildContext context) { |
|
|
|
return Padding( |
|
|
|
// 添加底部内边距以容纳键盘 |
|
|
|
padding: EdgeInsets.only( |
|
|
|
bottom: MediaQuery.of(context).viewInsets.bottom, |
|
|
|
), |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
child: SingleChildScrollView( |
|
|
|
// 添加滚动视图 |
|
|
|
child: Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
children: [ |
|
|
|
Stack( |
|
|
|
alignment: Alignment.center, |
|
|
|
children: [ |
|
|
|
Center( |
|
|
|
child: Text( |
|
|
|
'举报', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 18.sp, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
color: isDarkMode |
|
|
|
? Colors.white |
|
|
|
: Colors.black, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox( |
|
|
|
height: 20.w, |
|
|
|
), |
|
|
|
Positioned( |
|
|
|
right: 0, |
|
|
|
child: IconButton( |
|
|
|
icon: Icon( |
|
|
|
Icons.close, |
|
|
|
color: isDarkMode |
|
|
|
? Colors.grey[400] |
|
|
|
: Colors.black54, |
|
|
|
), |
|
|
|
onPressed: () => Navigator.pop(context), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|
|
|
margin: EdgeInsets.only(bottom: 10.w), |
|
|
|
child: Divider( |
|
|
|
height: 1, |
|
|
|
color: Colors.grey[300], |
|
|
|
), |
|
|
|
), |
|
|
|
Wrap( |
|
|
|
spacing: 8.w, |
|
|
|
runSpacing: 8.h, |
|
|
|
children: [ |
|
|
|
_buildReportChip('有害/不安全', isDarkMode), |
|
|
|
_buildReportChip('色情低俗', isDarkMode), |
|
|
|
_buildReportChip('误导攻击', isDarkMode), |
|
|
|
_buildReportChip('违法犯罪', isDarkMode), |
|
|
|
_buildReportChip('隐私相关', isDarkMode), |
|
|
|
_buildReportChip('侵犯我的著作权、名誉权等', isDarkMode), |
|
|
|
_buildReportChip('其他', isDarkMode), |
|
|
|
], |
|
|
|
), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.all(12.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isDarkMode |
|
|
|
? Colors.grey[800] |
|
|
|
: Colors.grey[200], |
|
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
|
), |
|
|
|
child: TextField( |
|
|
|
maxLines: 3, |
|
|
|
style: TextStyle( |
|
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
|
), |
|
|
|
decoration: InputDecoration( |
|
|
|
hintText: '我们想知道你举报的原因,你可以描述你遇到的问题。', |
|
|
|
hintStyle: TextStyle( |
|
|
|
color: isDarkMode |
|
|
|
? Colors.white70 |
|
|
|
: Colors.black54, |
|
|
|
fontSize: 14.sp, |
|
|
|
), |
|
|
|
border: InputBorder.none, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 14.h), |
|
|
|
ElevatedButton( |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: Colors.blue, |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text('提交'), |
|
|
|
onPressed: () { |
|
|
|
Navigator.pop(context); |
|
|
|
Get.snackbar( |
|
|
|
'提示', |
|
|
|
'举报已提交,我们会尽快处理', |
|
|
|
backgroundColor: Colors.green.withOpacity(0.8), |
|
|
|
colorText: Colors.white, |
|
|
|
); |
|
|
|
}, |
|
|
|
), |
|
|
|
SizedBox(height: 8.h), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
}, |
|
|
|
); |
|
|
|
final reportController = Get.find<ReportController>(); |
|
|
|
reportController.initReport(message); |
|
|
|
|
|
|
|
_showReportForm(context, isDarkMode); |
|
|
|
// showModalBottomSheet( |
|
|
|
// context: context, |
|
|
|
// isScrollControlled: true, // 关键:允许弹窗随键盘移动 |
|
|
|
// backgroundColor: |
|
|
|
// isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
|
// shape: RoundedRectangleBorder( |
|
|
|
// borderRadius: BorderRadius.vertical(top: Radius.circular(16.r)), |
|
|
|
// ), |
|
|
|
// builder: (BuildContext context) { |
|
|
|
// return Padding( |
|
|
|
// // 添加底部内边距以容纳键盘 |
|
|
|
// padding: EdgeInsets.only( |
|
|
|
// bottom: MediaQuery.of(context).viewInsets.bottom, |
|
|
|
// ), |
|
|
|
// child: Container( |
|
|
|
// padding: EdgeInsets.all(16.w), |
|
|
|
// child: SingleChildScrollView( |
|
|
|
// // 添加滚动视图 |
|
|
|
// child: Column( |
|
|
|
// mainAxisSize: MainAxisSize.min, |
|
|
|
// crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
// children: [ |
|
|
|
// Stack( |
|
|
|
// alignment: Alignment.center, |
|
|
|
// children: [ |
|
|
|
// Center( |
|
|
|
// child: Text( |
|
|
|
// '举报', |
|
|
|
// style: TextStyle( |
|
|
|
// fontSize: 18.sp, |
|
|
|
// fontWeight: FontWeight.bold, |
|
|
|
// color: isDarkMode |
|
|
|
// ? Colors.white |
|
|
|
// : Colors.black, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// SizedBox( |
|
|
|
// height: 20.w, |
|
|
|
// ), |
|
|
|
// Positioned( |
|
|
|
// right: 0, |
|
|
|
// child: IconButton( |
|
|
|
// icon: Icon( |
|
|
|
// Icons.close, |
|
|
|
// color: isDarkMode |
|
|
|
// ? Colors.grey[400] |
|
|
|
// : Colors.black54, |
|
|
|
// ), |
|
|
|
// onPressed: () => Navigator.pop(context), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ], |
|
|
|
// ), |
|
|
|
// Container( |
|
|
|
// padding: EdgeInsets.symmetric(horizontal: 12.w), |
|
|
|
// margin: EdgeInsets.only(bottom: 10.w), |
|
|
|
// child: Divider( |
|
|
|
// height: 1, |
|
|
|
// color: Colors.grey[300], |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// Wrap( |
|
|
|
// spacing: 8.w, |
|
|
|
// runSpacing: 8.h, |
|
|
|
// children: [ |
|
|
|
// _buildReportChip('有害/不安全', isDarkMode), |
|
|
|
// _buildReportChip('色情低俗', isDarkMode), |
|
|
|
// _buildReportChip('误导攻击', isDarkMode), |
|
|
|
// _buildReportChip('违法犯罪', isDarkMode), |
|
|
|
// _buildReportChip('隐私相关', isDarkMode), |
|
|
|
// _buildReportChip('侵犯我的著作权、名誉权等', isDarkMode), |
|
|
|
// _buildReportChip('其他', isDarkMode), |
|
|
|
// ], |
|
|
|
// ), |
|
|
|
// SizedBox(height: 16.h), |
|
|
|
// Container( |
|
|
|
// padding: EdgeInsets.all(12.w), |
|
|
|
// decoration: BoxDecoration( |
|
|
|
// color: isDarkMode |
|
|
|
// ? Colors.grey[800] |
|
|
|
// : Colors.grey[200], |
|
|
|
// borderRadius: BorderRadius.circular(8.r), |
|
|
|
// ), |
|
|
|
// child: TextField( |
|
|
|
// maxLines: 3, |
|
|
|
// style: TextStyle( |
|
|
|
// color: isDarkMode ? Colors.white : Colors.black, |
|
|
|
// ), |
|
|
|
// decoration: InputDecoration( |
|
|
|
// hintText: '我们想知道你举报的原因,你可以描述你遇到的问题。', |
|
|
|
// hintStyle: TextStyle( |
|
|
|
// color: isDarkMode |
|
|
|
// ? Colors.white70 |
|
|
|
// : Colors.black54, |
|
|
|
// fontSize: 14.sp, |
|
|
|
// ), |
|
|
|
// border: InputBorder.none, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// SizedBox(height: 14.h), |
|
|
|
// ElevatedButton( |
|
|
|
// style: ElevatedButton.styleFrom( |
|
|
|
// backgroundColor: Colors.blue, |
|
|
|
// foregroundColor: Colors.white, |
|
|
|
// padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
// shape: RoundedRectangleBorder( |
|
|
|
// borderRadius: BorderRadius.circular(8.r), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// child: Text('提交'), |
|
|
|
// onPressed: () { |
|
|
|
// Navigator.pop(context); |
|
|
|
// Get.snackbar( |
|
|
|
// '提示', |
|
|
|
// '举报已提交,我们会尽快处理', |
|
|
|
// backgroundColor: Colors.green.withOpacity(0.8), |
|
|
|
// colorText: Colors.white, |
|
|
|
// ); |
|
|
|
// }, |
|
|
|
// ), |
|
|
|
// SizedBox(height: 8.h), |
|
|
|
// ], |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// ); |
|
|
|
// }, |
|
|
|
// ); |
|
|
|
}, |
|
|
|
), |
|
|
|
], |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// 添加这个辅助方法来创建举报选项 |
|
|
|
Widget _buildReportChip(String label, bool isDarkMode) { |
|
|
|
return ChoiceChip( |
|
|
|
label: Text( |
|
|
|
label, |
|
|
|
style: TextStyle( |
|
|
|
color: isDarkMode ? Colors.white : Colors.black87, |
|
|
|
fontSize: 14.sp, |
|
|
|
), |
|
|
|
), |
|
|
|
selected: false, |
|
|
|
backgroundColor: isDarkMode ? Colors.grey[800] : Colors.grey[200], |
|
|
|
// 更新_showReportForm方法 |
|
|
|
void _showReportForm(BuildContext context, bool isDarkMode) { |
|
|
|
showModalBottomSheet( |
|
|
|
context: context, |
|
|
|
isScrollControlled: true, |
|
|
|
backgroundColor: isDarkMode ? AppColors.cardBackground : Colors.white, |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
borderRadius: BorderRadius.vertical(top: Radius.circular(16.r)), |
|
|
|
), |
|
|
|
onSelected: (bool selected) { |
|
|
|
// 可以在这里处理选择逻辑 |
|
|
|
builder: (BuildContext context) { |
|
|
|
return Padding( |
|
|
|
padding: EdgeInsets.only( |
|
|
|
bottom: MediaQuery.of(context).viewInsets.bottom, |
|
|
|
), |
|
|
|
child: _ReportForm(isDarkMode: isDarkMode), |
|
|
|
); |
|
|
|
}, |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
// // 添加这个辅助方法来创建举报选项 |
|
|
|
// Widget _buildReportChip(String label, bool isDarkMode) { |
|
|
|
// return ChoiceChip( |
|
|
|
// label: Text( |
|
|
|
// label, |
|
|
|
// style: TextStyle( |
|
|
|
// color: isDarkMode ? Colors.white : Colors.black87, |
|
|
|
// fontSize: 14.sp, |
|
|
|
// ), |
|
|
|
// ), |
|
|
|
// selected: false, |
|
|
|
// backgroundColor: isDarkMode ? Colors.grey[800] : Colors.grey[200], |
|
|
|
// shape: RoundedRectangleBorder( |
|
|
|
// borderRadius: BorderRadius.circular(16.r), |
|
|
|
// ), |
|
|
|
// onSelected: (bool selected) { |
|
|
|
// // 可以在这里处理选择逻辑 |
|
|
|
// }, |
|
|
|
// ); |
|
|
|
// } |
|
|
|
|
|
|
|
PopupMenuEntry _popupMenuEntry( |
|
|
|
Icon icon, |
|
|
|
String title, |
|
|
|
@ -838,6 +863,151 @@ class AgentView extends StatelessWidget { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
class _ReportForm extends StatelessWidget { |
|
|
|
final bool isDarkMode; |
|
|
|
final ReportController reportController = Get.find<ReportController>(); |
|
|
|
|
|
|
|
_ReportForm({required this.isDarkMode}); |
|
|
|
|
|
|
|
@override |
|
|
|
Widget build(BuildContext context) { |
|
|
|
return Container( |
|
|
|
padding: EdgeInsets.all(16.w), |
|
|
|
child: SingleChildScrollView( |
|
|
|
child: GetBuilder<ReportController>( |
|
|
|
builder: (_) => Column( |
|
|
|
mainAxisSize: MainAxisSize.min, |
|
|
|
crossAxisAlignment: CrossAxisAlignment.stretch, |
|
|
|
children: [ |
|
|
|
Stack( |
|
|
|
alignment: Alignment.center, |
|
|
|
children: [ |
|
|
|
Center( |
|
|
|
child: Text( |
|
|
|
'举报', |
|
|
|
style: TextStyle( |
|
|
|
fontSize: 18.sp, |
|
|
|
fontWeight: FontWeight.bold, |
|
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
Positioned( |
|
|
|
right: 0, |
|
|
|
child: IconButton( |
|
|
|
icon: Icon( |
|
|
|
Icons.close, |
|
|
|
color: isDarkMode ? Colors.grey[400] : Colors.black54, |
|
|
|
), |
|
|
|
onPressed: () => Navigator.pop(context), |
|
|
|
), |
|
|
|
), |
|
|
|
], |
|
|
|
), |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w), |
|
|
|
margin: EdgeInsets.only(bottom: 10.w), |
|
|
|
child: Divider( |
|
|
|
height: 1, |
|
|
|
color: Colors.grey[300], |
|
|
|
), |
|
|
|
), |
|
|
|
GetBuilder<ReportController>( |
|
|
|
builder: (controller) { |
|
|
|
return Wrap( |
|
|
|
spacing: 8.w, |
|
|
|
runSpacing: 8.h, |
|
|
|
children: [ |
|
|
|
_buildReportChip('有害/不安全', isDarkMode, controller), |
|
|
|
_buildReportChip('色情低俗', isDarkMode, controller), |
|
|
|
_buildReportChip('误导攻击', isDarkMode, controller), |
|
|
|
_buildReportChip('违法犯罪', isDarkMode, controller), |
|
|
|
_buildReportChip('隐私相关', isDarkMode, controller), |
|
|
|
_buildReportChip('侵犯我的著作权、名誉权等', isDarkMode, controller), |
|
|
|
_buildReportChip('其他', isDarkMode, controller), |
|
|
|
], |
|
|
|
); |
|
|
|
}, |
|
|
|
), |
|
|
|
SizedBox(height: 16.h), |
|
|
|
Container( |
|
|
|
padding: EdgeInsets.all(12.w), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isDarkMode ? Colors.grey[800] : Colors.grey[200], |
|
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
|
), |
|
|
|
child: TextField( |
|
|
|
maxLines: 3, |
|
|
|
onChanged: reportController.updateDescription, |
|
|
|
style: TextStyle( |
|
|
|
color: isDarkMode ? Colors.white : Colors.black, |
|
|
|
), |
|
|
|
decoration: InputDecoration( |
|
|
|
hintText: '我们想知道你举报的原因,你可以描述你遇到的问题。', |
|
|
|
hintStyle: TextStyle( |
|
|
|
color: isDarkMode ? Colors.white70 : Colors.black54, |
|
|
|
fontSize: 14.sp, |
|
|
|
), |
|
|
|
border: InputBorder.none, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
SizedBox(height: 14.h), |
|
|
|
ElevatedButton( |
|
|
|
style: ElevatedButton.styleFrom( |
|
|
|
backgroundColor: Colors.blue, |
|
|
|
foregroundColor: Colors.white, |
|
|
|
padding: EdgeInsets.symmetric(vertical: 12.h), |
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
borderRadius: BorderRadius.circular(8.r), |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text('提交'), |
|
|
|
onPressed: () => reportController.submitReport(), |
|
|
|
), |
|
|
|
SizedBox(height: 8.h), |
|
|
|
], |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
Widget _buildReportChip( |
|
|
|
String label, bool isDarkMode, ReportController controller) { |
|
|
|
final isSelected = reportController.selectedReasons.contains(label); |
|
|
|
|
|
|
|
return GestureDetector( |
|
|
|
onTap: () => reportController.toggleReason(label), |
|
|
|
child: Container( |
|
|
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 8.h), |
|
|
|
decoration: BoxDecoration( |
|
|
|
color: isSelected |
|
|
|
? Colors.red |
|
|
|
: (isDarkMode ? Colors.grey[800] : Colors.grey[200]), |
|
|
|
borderRadius: BorderRadius.circular(16.r), |
|
|
|
border: Border.all( |
|
|
|
color: isSelected |
|
|
|
? Colors.red[700]! |
|
|
|
: (isDarkMode ? Colors.grey[700]! : Colors.grey[300]!), |
|
|
|
width: isSelected ? 1.0 : 0.5, |
|
|
|
), |
|
|
|
), |
|
|
|
child: Text( |
|
|
|
label, |
|
|
|
style: TextStyle( |
|
|
|
color: isSelected |
|
|
|
? Colors.white |
|
|
|
: (isDarkMode ? Colors.white : Colors.black87), |
|
|
|
fontSize: 14.sp, |
|
|
|
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal, |
|
|
|
), |
|
|
|
), |
|
|
|
), |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 声音柱动画组件 |
|
|
|
class _SoundBar extends StatefulWidget { |
|
|
|
final double delay; |
|
|
|
|