Skip to content

feat(AlertDialogView): expose customization attributes for better flexibility and reuse - #1621

Open
whysqwhw wants to merge 1 commit into
Tencent-TDS:mainfrom
whysqwhw:main
Open

feat(AlertDialogView): expose customization attributes for better flexibility and reuse #1621
whysqwhw wants to merge 1 commit into
Tencent-TDS:mainfrom
whysqwhw:main

Conversation

@whysqwhw

Copy link
Copy Markdown
Contributor

expose customization attributes for better flexibility and reuse

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 KuiklyAI Code Review

基本信息

  • PR:#1621 · feat(AlertDialogView): expose customization attributes for better flexibility and reuse
  • 作者:whysqwhw main ← main

变更概述

  • 干了什么:为 AlertDialog 暴露一批自定义能力——titleCustomAttr/msgCustomAttr(覆盖标题/正文的 TextAttr)、dialogAttr(替换默认内容容器样式)、customMsgView(在内容区插入自定义 UI,如 RichText),并新增 clickTitle/clickMsg 点击回调。
  • 解决什么:作者声明「expose customization attributes for better flexibility and reuse」,让业务在不替换整个前景 View 的前提下细粒度定制弹窗外观与正文内容。
  • 方案 & 合理性:在既有 contentViewCreator 框架内做条件分支(dialogAttr != null 走自定义、否则走原默认色值),title/message 在默认样式后追加 titleAttr/messageAttr?.invoke(this) 形成「自定义覆盖」,新增 msgViewCreator 作为 message 之后的扩展槽。层级正确、与现有 customContentView/customBackgroundView 风格一致,二进制兼容(仅新增 public 成员 + typealias,无签名破坏)。增量改动幅度合理。

审查结论

  • 功能正确性:跨文件追了 contentViewCreator 提前 return、vif 渲染顺序、actionButtonsCustomAttr + 2 按钮 → size == 2 分支、TextSpan 继承 TextAttrclick/fontWeight400/lineHeight 等可用性,均符合预期;新 click 事件参数类型 (ClickParams) -> Unit 与既有 clickBackgroundMask 一致。未发现逻辑缺陷。
  • 代码质量:边界/包名/API 可见性符合项目规则(新成员与既有同文件成员可见性一致);typealias TextAttrBuilder 与既有 ActionButtonTitleAttr 同为 TextAttr.() -> Unit,存在重复定义,建议合并。其余见 inline。
  • 文档同步:docs/API/components/alert-dialog.md 当前未收录本次新增的 titleCustomAttrmsgCustomAttrdialogAttrcustomMsgView 属性以及 clickTitleclickMsg 事件,建议补充属性表/事件列表,保持对外文档与 API 同步。

}

typealias ActionButtonTitleAttr = TextAttr.() -> Unit
typealias TextAttrBuilder = TextAttr.() -> Unit

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里新增的 TextAttrBuilder = TextAttr.() -> Unit 和上一行已有的 ActionButtonTitleAttr 是同一个类型,只是换了个名字。两者都在同一文件作用域里,外部引用时容易困惑该用哪个。建议直接复用 ActionButtonTitleAttr,或者把两者统一成一个语义更中心的命名(比如都叫 TextAttrBuilder),避免同一个函数类型出现两个等价别名。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ActionButtonTitleAttr 是按钮的,老版本的 api 动了会导致一些使用的地方有兼容问题

lineHeight(20f)
letterSpacing(-0.2f)

click {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 click { } 是空实现,留着会让 TextSpan.hasClickEvent() 返回 true、白白挂上点击命中区域但不做任何事。如果只是占位、暂时没交互,建议先注释掉或留个 TODO;否则补上实际逻辑。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demo 而已,不用写的很完善

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个看起来最好还是处理一下

}
}
}
AlertDialog {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个第二个 AlertDialog 没有注册 willDismiss,在系统返回键/右滑返回时无法关闭弹窗(第一个 AlertDialog 有处理)。作为 demo 建议补上与第一个一致的 willDismiss { ctx.showAgreeDialog = false },避免别人照抄时遇到返回键关不掉的问题。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

demo 而已,不用很严格

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已解决:第二个 AlertDialog 已补上 willDismiss { ctx.showAgreeDialog = false },返回键/右滑关闭逻辑和第一个一致了。

val colorHex: Long
val alpha: Float
if (getPager().isNightMode()) {
colorHex = 0x000000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

常量提取,下同

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 KuiklyAI Code Review

增量回顾

上轮提了 3 点:

  • 第二个 AlertDialog 缺 willDismiss — 已补上,已解决 ✅
  • TextAttrBuilderActionButtonTitleAttr 是等价别名 — 仍并存,未处理
  • Spanclick {} 空实现会让 hasClickEvent() 返回 true、挂上空点击区域 — 改成了 click { //TODO },但空实现本身仍在,hasClickEvent() 依旧为 true

这次新增了 dialogAttr / customMsgView / titleCustomAttr / msgCustomAttr / clickTitle / clickMsg 一组定制能力,API 均为新增、未破坏既有签名,整体方向 OK。新增能力里有一个用法上的注意点,见 inline。

@KuiklyAI KuiklyAI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 KuiklyAI Code Review

增量回顾

上轮(ee39613a → c3f682f)只改了 demo 第二个 AlertDialog 的 clickActionButtonctx.showAgreeDialog = false 改成 ctx.showAgreeDialog = index == 1,core 没动。

上轮提的几点状态:

  • TextAttrBuilderActionButtonTitleAttr 等价别名 — 仍在,未处理
  • Spanclick { //TODO } 空实现 — 仍在
  • 第二个 AlertDialog 缺 willDismiss — 已解决(上轮已确认)
  • dialogAttr?.invoke(this) 覆盖夜间/blur 背景色 — 仍在,core 未改动

这轮新增改动里有一个按钮语义上的小问题,见 inline。core 侧无新增风险。

@ruifanyuan ruifanyuan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

3 participants