Browse Source

fix(举报弹窗): 修复键盘弹出时布局遮挡问题

- 添加isScrollControlled属性使弹窗随键盘移动
- 增加底部内边距避免键盘遮挡内容
- 使用SingleChildScrollView确保内容可滚动
- 优化关闭按钮位置和样式
weicu
lxm 1 year ago
parent
commit
44760024f2
  1. 193
      lib/modules/agent/views/agent_view.dart

193
lib/modules/agent/views/agent_view.dart

@ -594,8 +594,8 @@ class AgentView extends StatelessWidget {
child: Divider( child: Divider(
height: 1, height: 1,
thickness: 0.8, thickness: 0.8,
indent: 12, indent: 0,
endIndent: 12, endIndent: 0,
color: isDarkMode ? Colors.grey[700] : Colors.grey[300], color: isDarkMode ? Colors.grey[700] : Colors.grey[300],
), ),
), ),
@ -611,101 +611,130 @@ class AgentView extends StatelessWidget {
// 实现举报功能 // 实现举报功能
showModalBottomSheet( showModalBottomSheet(
context: context, context: context,
isScrollControlled: true, // 关键:允许弹窗随键盘移动
backgroundColor: backgroundColor:
isDarkMode ? AppColors.cardBackground : Colors.white, isDarkMode ? AppColors.cardBackground : Colors.white,
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(top: Radius.circular(16.r)), borderRadius: BorderRadius.vertical(top: Radius.circular(16.r)),
), ),
builder: (BuildContext context) { builder: (BuildContext context) {
return Container( return Padding(
padding: EdgeInsets.all(16.w), // 添加底部内边距以容纳键盘
child: Column( padding: EdgeInsets.only(
mainAxisSize: MainAxisSize.min, bottom: MediaQuery.of(context).viewInsets.bottom,
crossAxisAlignment: CrossAxisAlignment.stretch, ),
children: [ child: Container(
Row( padding: EdgeInsets.all(16.w),
mainAxisAlignment: MainAxisAlignment.spaceBetween, child: SingleChildScrollView(
// 添加滚动视图
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Text( Stack(
'举报', alignment: Alignment.center,
style: TextStyle( children: [
fontSize: 18.sp, Center(
fontWeight: FontWeight.bold, child: Text(
color: isDarkMode ? Colors.white : Colors.black, '举报',
), 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),
),
),
],
), ),
IconButton( Container(
icon: Icon( padding: EdgeInsets.symmetric(horizontal: 12.w),
Icons.close, margin: EdgeInsets.only(bottom: 10.w),
color: child: Divider(
isDarkMode ? Colors.white70 : Colors.black54, height: 1,
color: Colors.grey[300],
), ),
onPressed: () => Navigator.pop(context),
), ),
], Wrap(
), spacing: 8.w,
SizedBox(height: 16.h), runSpacing: 8.h,
Wrap( children: [
spacing: 8.w, _buildReportChip('有害/不安全', isDarkMode),
runSpacing: 8.h, _buildReportChip('色情低俗', isDarkMode),
children: [ _buildReportChip('误导攻击', isDarkMode),
_buildReportChip('有害/不安全', isDarkMode), _buildReportChip('违法犯罪', isDarkMode),
_buildReportChip('色情低俗', isDarkMode), _buildReportChip('隐私相关', isDarkMode),
_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( SizedBox(height: 16.h),
hintText: '我们想知道你举报的原因,你可以描述你遇到的问题。', Container(
hintStyle: TextStyle( padding: EdgeInsets.all(12.w),
color: decoration: BoxDecoration(
isDarkMode ? Colors.white70 : Colors.black54, color: isDarkMode
fontSize: 14.sp, ? 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,
),
), ),
border: InputBorder.none,
), ),
), SizedBox(height: 14.h),
), ElevatedButton(
SizedBox(height: 14.h), style: ElevatedButton.styleFrom(
ElevatedButton( backgroundColor: Colors.blue,
style: ElevatedButton.styleFrom( foregroundColor: Colors.white,
backgroundColor: Colors.blue, padding: EdgeInsets.symmetric(vertical: 12.h),
foregroundColor: Colors.white, shape: RoundedRectangleBorder(
padding: EdgeInsets.symmetric(vertical: 12.h), borderRadius: BorderRadius.circular(8.r),
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),
child: Text('提交'), ],
onPressed: () {
// 处理举报提交逻辑
Navigator.pop(context);
Get.snackbar(
'提示',
'举报已提交,我们会尽快处理',
backgroundColor: Colors.green.withOpacity(0.8),
colorText: Colors.white,
);
},
), ),
SizedBox(height: 8.h), ),
],
), ),
); );
}, },

Loading…
Cancel
Save