Browse Source

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

- 添加isScrollControlled属性使弹窗随键盘移动
- 增加底部内边距避免键盘遮挡内容
- 使用SingleChildScrollView确保内容可滚动
- 优化关闭按钮位置和样式
weicu
lxm 1 year ago
parent
commit
44760024f2
  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( 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,40 +611,66 @@ 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.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: Container(
padding: EdgeInsets.all(16.w), padding: EdgeInsets.all(16.w),
child: SingleChildScrollView(
// 添加滚动视图
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
Row( Stack(
mainAxisAlignment: MainAxisAlignment.spaceBetween, alignment: Alignment.center,
children: [ children: [
Text( Center(
child: Text(
'举报', '举报',
style: TextStyle( style: TextStyle(
fontSize: 18.sp, fontSize: 18.sp,
fontWeight: FontWeight.bold, 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( icon: Icon(
Icons.close, Icons.close,
color: color: isDarkMode
isDarkMode ? Colors.white70 : Colors.black54, ? Colors.grey[400]
: Colors.black54,
), ),
onPressed: () => Navigator.pop(context), 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( Wrap(
spacing: 8.w, spacing: 8.w,
runSpacing: 8.h, runSpacing: 8.h,
@ -662,8 +688,9 @@ class AgentView extends StatelessWidget {
Container( Container(
padding: EdgeInsets.all(12.w), padding: EdgeInsets.all(12.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: color: isDarkMode
isDarkMode ? Colors.grey[800] : Colors.grey[200], ? Colors.grey[800]
: Colors.grey[200],
borderRadius: BorderRadius.circular(8.r), borderRadius: BorderRadius.circular(8.r),
), ),
child: TextField( child: TextField(
@ -674,8 +701,9 @@ class AgentView extends StatelessWidget {
decoration: InputDecoration( decoration: InputDecoration(
hintText: '我们想知道你举报的原因,你可以描述你遇到的问题。', hintText: '我们想知道你举报的原因,你可以描述你遇到的问题。',
hintStyle: TextStyle( hintStyle: TextStyle(
color: color: isDarkMode
isDarkMode ? Colors.white70 : Colors.black54, ? Colors.white70
: Colors.black54,
fontSize: 14.sp, fontSize: 14.sp,
), ),
border: InputBorder.none, border: InputBorder.none,
@ -694,7 +722,6 @@ class AgentView extends StatelessWidget {
), ),
child: Text('提交'), child: Text('提交'),
onPressed: () { onPressed: () {
// 处理举报提交逻辑
Navigator.pop(context); Navigator.pop(context);
Get.snackbar( Get.snackbar(
'提示', '提示',
@ -707,6 +734,8 @@ class AgentView extends StatelessWidget {
SizedBox(height: 8.h), SizedBox(height: 8.h),
], ],
), ),
),
),
); );
}, },
); );

Loading…
Cancel
Save