Skip to content

播放条三枚读数收成网易云式缺口:图标右上角被咬掉一块,数字嵌在缺口里 - #739

Merged
ShellMonster merged 3 commits into
mainfrom
work/badge-notch
Nov 3, 2026
Merged

ShellMonster merged 3 commits into
mainfrom
work/badge-notch

Conversation

@ShellMonster

@ShellMonster ShellMonster commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

User description

做了什么

把播放条左边那三枚键(赞 / 收藏 / 评论)的读数从「图形右上外侧挂着的角标」改成网易云式缺口:图形的右上角被咬掉一块(露出播放条底色),数字嵌进那个缺口里——数字坐在图形的凹陷上,而不是悬在外面。

怎么实现的(矢量,不抠字形)

「挖空」用盖:在图形盒子(18×18)的右上角盖一块播放条底色的圆角块(ui.Box + Radius(5) + Background(bg)),那一角的字形笔画就被盖成底色——视觉上图标缺了一角;数字居中画在这块底色上。

  • 挂点:Attach(AnchorTopRight, AnchorTopRight) + Top(-2) + Right(-(notchW-6))——缺口上沿探出图形上沿 2px,左缘只收进图形右缘 6px(咬的是右上角那一小块);块的主体往右探进图形外的空气里。
  • 为什么这么咬:宽字档「99k+」≈22px 比图形 18 还宽——若让缺口包住整个图形,最宽档会把图标吃得只剩下半截(实测星标缩成「∧」)。咬 6px 那一口,图标保住大半个形状。
  • 缺口宽按字量:MeasureText 量出字宽 + 两侧 space.Px3——窄档缺口小、最宽档也容得下,「+」结构上截不掉(没有给截断发生的格子)。
  • 缺口色 = 数字底下的实际背景:coverWash(t.Background)(封面取色染过的播放条底),三个调用点都在播放条那一列、传同一个值。悬停不用跟着换色——flat.feel 的悬停淡底是 DrawOver,画在一切(含缺口块和数字)之上,缺口和四周同帧变深,缝还是看不见。
  • PassThrough():缺口块不登记命中,底下的按钮照点、悬停照常。
  • 三枚键走同一份 countBadge(赞键自己拼图形盒子、角标也走这里);键宽仍是 32(角标不占布局)。

测试

  • TestTheThreeCountsSitInsideANotchOnTheIconsTopRight:角标左缘收在图形右半部以内(骑在缺口上)、下缘在图形中线上方、右缘不探出缺口——外侧角标版 / 横排版 / 「包住整个图形」版都立刻红。
  • E2E(internal/e2e/counts_test.go)改成「缺口嵌字」判据:图形右上角那一口被咬成底色(以前是星臂 / 拇指背 / 气泡弧的字形笔画)、数字墨迹骑在图形右缘上、主体探在图形右侧空气里。
  • 截图自审(BIU_SHOT_DIR):三枚图标各保住大半个形状,「99k+」从左收进缺口、往右排进空气里,缺口圆角读起来是「咬进去一口」不是「贴了块补丁」。

已知边界

  • 数字的右半截探在图形右侧的键间缝里(PassThrough,不挡邻居的命中)——网易云本来就是那个形状,而那一列的底色是均一的,缝看不见。
  • go test ./internal/e2e/ 在 menu_test.go 有一处先于本票的编译错(seedSession 未定义,origin/main 上同样红),与本票无关。

CodeAnt-AI Description

将播放条互动数嵌入图标右上角缺口

What Changed

  • 点赞、收藏和评论数现在嵌在图标右上角的缺口中,不再悬在图标外侧
  • 缺口与播放条背景融为一体,数字按内容宽度显示,保留「+」标记
  • 数字不改变按钮宽度,缺口区域也不会影响按钮点击和悬停

Impact

✅ 播放条互动数与图标融为一体
✅ 点击和悬停仍可正常使用
✅ 大数显示保留「+」且不撑宽按钮

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

上一版(PR #736)的角标贴在图形右上外侧;本票改成网易云式——图形
右上角被一块底色圆角块「咬掉」,数字嵌进那个缺口里。

- 缺口块:Attach(TopRight→TopRight),上沿探出 2、左缘收进图形右缘
  6(只咬右上角那一口,不包住整个图形——宽字档「99k+」≈22 比图形
  18 还宽,全包会把图标吃得只剩下半截),块的主体往右探进图形外
  的空气里。宽按字量(MeasureText + 两侧 3),「+」结构上截不掉。
- 缺口色 = 按钮底下那块底(coverWash(t.Background)),调用方传进
  countBadge;悬停/按下不用换色——flat.feel 的 DrawOver 画在一切
  之上,缺口和四周同帧变深。
- 缺口块 PassThrough:底下的按钮照点,悬停照常。
- 三枚键共用同一份(赞键自己拼图形盒子也走 countBadge),键宽
  仍是 32、带不带数字都一样。
- E2E 改成「缺口嵌字」判据:图形右上角那一口被咬成底色(以前是
  字形笔画)、数字左缘收进图形右缘以内、主体探在图形右侧空气里。
@codeant-ai

codeant-ai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

CodeAnt  CodeAnt Review Status

✅  Review completed

Status Commit Started (UTC) Finished (UTC)
✅  #a6041 Reviewed your PR 87af0d7 Nov 03, 2026 · 02:14 02:23

@codeant-ai

codeant-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

PudMusic UI 截图

截图测试已通过。

截图来自项目现有的 MyGo UI 测试渲染器,使用本地 fixture,不启动真实登录态。

@codeant-ai

codeant-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt Nitpicks

4 code suggestions

1. The fixture inherits the system theme, but darkerIn only detects darker pixels; in dark mode the muted count text is lighter, so correct output fails this assertion.

Logic error · internal/e2e/counts_test.go:175


2. Radius(5) leaves these sampled corner pixels uncovered, but the assertion requires zero dark pixels; an underlying icon stroke can fail this test with the intended notch.

Logic error · internal/e2e/counts_test.go:180


3. coverWash can see the asynchronous tint finish after the bar background is built, giving this notch a different color and a visible patch for one frame.

Race condition · internal/ui/playbar.go:945-946


4. For 99k+, the correctly placed text ends around iRight+19, but this limit is only iRight+17.5, so the widest valid badge fails this check.

Incorrect condition logic · internal/ui/playbar_counts_test.go:516

@codeant-ai

codeant-ai Bot commented Nov 3, 2026

Copy link
Copy Markdown

CodeAnt  CodeAnt PR Risk

🟢  Low Risk

  • The PR appears safe to merge; no actionable issues were identified in the review.

Assessed commit: 87af0d7a1173

视觉审查打回:数字和图标贴得太近——放大看「99k+」的字身几乎顶在
星形/拇指/气泡的笔画上,比网易云那种「豁口里留一圈白」挤。

缺口块的左右 padding 从对称 3 改成不对称:咬进图形的那一边留 8
(数字起笔和图形残笔之间有一眼能看到的缝),探在空气里的那一边
留 6。缺口块宽跟着两边一起长(textW + 8 + 6),不是字往右挤。

测试跟着新几何改:数字左缘钉在「缺口左缘 + PadL」那一带(PadL
大于 bite 时它探出图形右缘 PadL−bite——缝在数字左边);右缘上限
换成最宽探出量 textW+PadL+PadR−bite。E2E 加一条「缝」判据:缺口
左端到数字起笔之间的那一带一个比底色深的像素都不该有。
1. MeasureText 回 0 时 textW=0 → notchW 只剩两侧 padding(≥最小宽、
   兜底救不回),而 Text 的 MinWidth(0).MaxWidth(0) 把整串数字裁成
   零宽——画面上剩一个空底色缺口。抽一支纯函数 badgeTextWidth:量
   出来的值 ≤0 就退回上限档 playbarBadgeMaxW(缺口画宽一点,数字
   一定画得出)。MeasureText 在 *ui.Context 上、mock 不掉,所以把
   「量出来的值 → 兜底后的值」抽成纯函数,测试喂 0/负/正常宽三档。

2. 赞键长按三连的抖动 Translate(dx,0) 只作用在底色层和图标层,缺
   口块挂在图形盒子上不吃同一个平移——按住 2.5s 全程是「图标在抖、
   缺口原地不动」。给 countBadge 加一个 dx 参数:赞键传自己的
   likeShakeDX,收藏/评论/测试传 0(不抖的那几枚就是恒等变换)。
@ShellMonster
ShellMonster merged commit 29ac94f into main Nov 3, 2026
2 of 3 checks passed
@ShellMonster
ShellMonster deleted the work/badge-notch branch November 3, 2026 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant