refactor(class): 优化接口请求与页面细节
1. 统一处理后端统一包结构,自动解析data字段 2. 新增点赞评论栏显示控制参数,详情页隐藏该栏 3. 简化详情页数据更新逻辑,对齐Vue版本实现 4. 重构确认弹窗组件,优化样式与弹窗尺寸 5. 为评论项添加水平边距,优化列表排版
This commit is contained in:
@@ -29,6 +29,8 @@ Future<bool> showConfirmBox(
|
||||
bool showCancel = true,
|
||||
double? minWidth, // 弹窗最小宽度(逻辑像素,调用方自行 .w 换算)
|
||||
}) {
|
||||
// 默认弹窗固定宽度 310.w(按钮 135.w × 2 + 间距 10.w + 左右 15.w×2 = 310.w)
|
||||
minWidth ??= 310.w;
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: true, // 点遮罩关闭 → false(对标 onPopupClose)
|
||||
@@ -66,15 +68,18 @@ class ConfirmBox extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
backgroundColor: Colors.transparent,
|
||||
// Dialog 默认左右 insetPadding: 40 太宽,310.w 在手机上放不下
|
||||
// 这里减到 20,给 310.w 固定宽度留足空间(375-40=335 > 310)
|
||||
insetPadding: EdgeInsets.symmetric(horizontal: 20.w),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 30.w, horizontal: 15.w), // 60rpx 30rpx
|
||||
constraints:
|
||||
minWidth != null ? BoxConstraints(minWidth: minWidth!) : null,
|
||||
width: minWidth, // 固定宽度(minWidth 语义变了:这里就是固定宽)
|
||||
padding: EdgeInsets.symmetric(vertical: 30.w, horizontal: 15.w),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(20.w), // 40rpx
|
||||
image: DecorationImage(
|
||||
image: NetworkImage(
|
||||
ImgUrl.build('/StaticResource/2026-03-31/header-bac.png')),
|
||||
ImgUrl.build('/StaticResource/2026-03-31/header-bac.png'),
|
||||
),
|
||||
fit: BoxFit.fill, // background-size: 100% 100%
|
||||
),
|
||||
),
|
||||
@@ -94,7 +99,9 @@ class ConfirmBox extends StatelessWidget {
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 18.w), // 36rpx
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: 263.w), // max-width 526rpx
|
||||
constraints: BoxConstraints(
|
||||
maxWidth: 263.w,
|
||||
), // max-width 526rpx
|
||||
child: Text(
|
||||
content,
|
||||
style: TextStyle(
|
||||
@@ -115,6 +122,7 @@ class ConfirmBox extends StatelessWidget {
|
||||
backgroundColor: const Color(0xFFFDFFFF),
|
||||
textColor: const Color(0xFF6195F6),
|
||||
onTap: () => Navigator.of(context).pop(false),
|
||||
isConfirm: false,
|
||||
),
|
||||
SizedBox(width: 10.w), // 20rpx
|
||||
],
|
||||
@@ -133,6 +141,7 @@ class ConfirmBox extends StatelessWidget {
|
||||
),
|
||||
textColor: Colors.white,
|
||||
onTap: () => Navigator.of(context).pop(true),
|
||||
isConfirm: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -143,40 +152,45 @@ class ConfirmBox extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 胶囊按钮(对标 default-button5 渐变确定键 / default-button6 白底取消键)
|
||||
/// 胶囊按钮:取消键(白底+蓝字+边框+阴影)/ 确定键(渐变+边框+阴影)
|
||||
Widget _buildButton({
|
||||
required String text,
|
||||
required Color textColor,
|
||||
required VoidCallback onTap,
|
||||
required bool isConfirm,
|
||||
Color? backgroundColor,
|
||||
Gradient? gradient,
|
||||
}) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
height: 46.w, // 92rpx
|
||||
padding: EdgeInsets.symmetric(horizontal: 20.w),
|
||||
constraints: BoxConstraints(minWidth: 135.w), // min-width 270rpx
|
||||
width: 135.w,
|
||||
height: 49.w,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor,
|
||||
gradient: gradient,
|
||||
borderRadius: BorderRadius.circular(100), // border-radius: 100px
|
||||
boxShadow: gradient != null
|
||||
? [
|
||||
// CSS: 0px 15px 11.3px rgba(61,125,245,0.08)
|
||||
// (inset 内发光 Flutter 不支持,省略)
|
||||
BoxShadow(
|
||||
color: const Color(0x143D7DF5),
|
||||
offset: Offset(0, 15.w),
|
||||
blurRadius: 11.w,
|
||||
),
|
||||
]
|
||||
: null,
|
||||
borderRadius: BorderRadius.circular(50.w),
|
||||
boxShadow: [
|
||||
if (isConfirm)
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.25),
|
||||
offset: Offset(0, 1.w),
|
||||
blurRadius: 9.2.w,
|
||||
spreadRadius: 3.w,
|
||||
)
|
||||
else
|
||||
BoxShadow(
|
||||
color: Colors.black.withValues(alpha: 0.25),
|
||||
offset: Offset(0, 2.w),
|
||||
blurRadius: 12.2.w,
|
||||
spreadRadius: 0.5.w,
|
||||
),
|
||||
],
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(fontSize: 16.sp, color: textColor), // 32rpx
|
||||
style: TextStyle(fontSize: 16.sp, color: textColor),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user