Skip to content

feat(TCell): 修复卡片形态 cardBorderRadius 不生效,新增 cardBackgroundColor - #1262

Open
lnuxe wants to merge 3 commits into
Tencent:developfrom
lnuxe:fix/cell-card-background-1240
Open

lnuxe wants to merge 3 commits into
Tencent:developfrom
lnuxe:fix/cell-card-background-1240

Conversation

@lnuxe

@lnuxe lnuxe commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

🤔 这个 PR 的性质是?

勾选规则:
1.只要有新增参数,就勾选”新特性提交“
2.只修改内部bug,未新增参数,才勾选”日常 bug 修复“
3.其他选项视具体改动判断

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

Fixes #1240

💡 需求背景和解决方案

问题:TCellGroup(variant: TCellGroupVariant.card) 设置 cardBorderRadius 后看不到圆角,只有同时把 cardPadding 设为 EdgeInsets.zero 才生效。

真机截图(iPhone 17 Pro 模拟器,iOS 26.1,同一份代码):

修复前 修复后
before after

compare

gif

根因:圆角一直画在组容器的 BoxDecoration 上,但容器没有 color;可见的白色来自内部 TCell 的 bgColorContainer。cardPadding 默认左右 16 逻辑像素让单元格内缩,圆角弧线所在的这圈区域没有任何可填充内容,所以 cardBorderRadius 计算正确却没有可见效果。

实机截图判读(cardRadius: 12、默认 cardPadding,取卡片左上角首行白色像素的横坐标):

版本 顶部起 x 判读
修复前 恒为 96(内缩处的 90° 直角) 圆角不可见
修复后 72 → 64 → 59 → 56 → 53 → 51 → 50 收敛 12 逻辑像素圆弧

改动:

  1. TCellThemeData 新增可选 cardBackgroundColor,未配置时回退 bgColorContainer Token;
  2. 卡片形态的组容器按该字段绘制背景色,通栏形态不绘制(行为不变);
  3. cardPadding 的语义收敛为卡片内边距,不再隐含决定圆角是否可见。
Theme(
  data: Theme.of(context).mergeExtension(
    const TCellThemeData(
      cardBorderRadius: BorderRadius.all(Radius.circular(12)),
      // 可选:不配置时取 bgColorContainer
      cardBackgroundColor: Colors.white,
    ),
  ),
  child: TCellGroup(
    variant: TCellGroupVariant.card,
    cells: [...],
  ),
);

验证:

检查 结果
flutter test test/components/cell 43 项通过(新增 2 项回归用例)
flutter analyze lib/src/components/cell test/components/cell 零诊断
card golden(light / dark) 更新后通过,diff bbox (16,16)-(359,146) 限于卡片矩形
全量测试(macOS) 4418 通过 / 97 失败;同环境未打补丁基线 4414 通过 / 99 失败,失败项均为 macOS 与 Linux golden 基线差异,本次净消除 2 项

Spec 与验收记录见 specs/components/084-DataDisplay-Cell/spec.md、acceptance.md。

📝 更新日志

  • fix(TCell): 修复卡片形态下设置 cardBorderRadius 看不到圆角的问题

  • feat(TCell): 新增 TCellThemeData.cardBackgroundColor,用于配置卡片组背景色

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项。⚠️

  • 标题遵循 Conventional Commits 格式:type(<scope>?): 修改描述。
    示例:fix(TBottomTabBar): 修复 iconText 模式底部溢出
  • “相关 Issue”处带上修复的 Issue 链接或无关联 Issue
  • 已添加对应的 Spec 链接,或已由 Review 确认本次改动无需 Spec
  • 相关文档已补充或无须补充

@tencent-adm

tencent-adm commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

CLA assistant check
All committers have signed the CLA.

@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

完成

Web Demo

APK 下载

TCellGroup 卡片形态的圆角一直画在组容器上,但容器没有绘制背景色,
可见的白色来自内部 TCell;cardPadding 默认左右 16 使单元格内缩,
圆角弧线所在的这圈区域没有任何可填充内容,表现为改了 cardBorderRadius
却看不到圆角,只有把 cardPadding 设为 EdgeInsets.zero 时才可见。

新增可选字段 TCellThemeData.cardBackgroundColor,未配置时回退
bgColorContainer Token;通栏形态不绘制背景,行为不变。
@lnuxe
lnuxe force-pushed the fix/cell-card-background-1240 branch from f2ac0f0 to bec8e75 Compare November 27, 2026 02:32

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TCell] card无法修改圆角的大小

3 participants