Browse Source

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

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

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

@ -594,8 +594,8 @@ class AgentView extends StatelessWidget {
child: Divider(
height: 1,
thickness: 0.8,
indent: 12,
endIndent: 12,
indent: 0,
endIndent: 0,
color: isDarkMode ? Colors.grey[700] : Colors.grey[300],
),
),
@ -611,40 +611,66 @@ class AgentView extends StatelessWidget {
// 实现举报功能
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 Container(
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: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
Stack(
alignment: Alignment.center,
children: [
Text(
Center(
child: Text(
'举报',
style: TextStyle(
fontSize: 18.sp,
fontWeight: FontWeight.bold,
color: isDarkMode ? Colors.white : Colors.black,
color: isDarkMode
? Colors.white
: Colors.black,
),
),
),
IconButton(
SizedBox(
height: 20.w,
),
Positioned(
right: 0,
child: IconButton(
icon: Icon(
Icons.close,
color:
isDarkMode ? Colors.white70 : Colors.black54,
color: isDarkMode
? Colors.grey[400]
: Colors.black54,
),
onPressed: () => Navigator.pop(context),
),
),
],
),
SizedBox(height: 16.h),
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,
@ -662,8 +688,9 @@ class AgentView extends StatelessWidget {
Container(
padding: EdgeInsets.all(12.w),
decoration: BoxDecoration(
color:
isDarkMode ? Colors.grey[800] : Colors.grey[200],
color: isDarkMode
? Colors.grey[800]
: Colors.grey[200],
borderRadius: BorderRadius.circular(8.r),
),
child: TextField(
@ -674,8 +701,9 @@ class AgentView extends StatelessWidget {
decoration: InputDecoration(
hintText: '我们想知道你举报的原因,你可以描述你遇到的问题。',
hintStyle: TextStyle(
color:
isDarkMode ? Colors.white70 : Colors.black54,
color: isDarkMode
? Colors.white70
: Colors.black54,
fontSize: 14.sp,
),
border: InputBorder.none,
@ -694,7 +722,6 @@ class AgentView extends StatelessWidget {
),
child: Text('提交'),
onPressed: () {
// 处理举报提交逻辑
Navigator.pop(context);
Get.snackbar(
'提示',
@ -707,6 +734,8 @@ class AgentView extends StatelessWidget {
SizedBox(height: 8.h),
],
),
),
),
);
},
);

Loading…
Cancel
Save