laoyang
d9ca9dbe31
下拉框与网页端对齐(照 FeedLite 那套观感)(#86)
用户 2026-11-05:「好了,鸿蒙端也用类似的方式调,效果让它保持一致。」
端上**不需要像网页那样手写浮层** —— 网页端必须自绘是因为
「原生 select 的展开列表由浏览器绘制,CSS 改不动」;
ArkUI 的 Select 本身就是自绘的、选项列表也归框架管。
⇒ 把对应属性都设上就等价了:
网页端 ArkUI Select
──────────────────────────────────────────────────────
按钮 40 高 / 圆角 / 细边框 height(40) + borderRadius + border
箭头打开转 180° 框架内置(自带动画)
悬停 tint-1 不支持(触屏没有 hover)→ 用打开态代替
选中项底 tint-2 selectedOptionBgColor(fbMixWhite(accent,0.80))
选中项文字 主题色 selectedOptionFontColor(accent)
选中项右侧对勾 showDefaultSelectedIcon(true)
浮层白底 + 细边框 menuBackgroundColor(White) + border
浮层与按钮同宽 optionWidth(OptionWidthMode.FIT_TRIGGER)
未选值次要色 fontColor(有值 ? accent : Faint)
① Theme 新增 fbMixWhite(hex, ratio)
与网页端 fb_color_tint() **同算法同比例**(混 91/80/72% 白)。
⚠️ 为什么不用现成的 fbAlpha():那是「原色 + 透明度」,
会透出父容器底色 —— 下拉浮层背景不确定,那样会时深时浅;
这里是实色混合,颜色确定。
⚠️ 实测 16 组(4 个主题色 × 4 档比例)与 PHP 输出逐个比对,全部一致。
② 边框单独用一档
按钮边框 fbMixWhite(accent, 0.62) —— 比 tint-3 再深一点,
否则在 tint-1 的浅底上几乎看不见边界。
③ 修一个类型坑
本来写了个 pickFontColor(): string 返回 accent / FbColors.muted,
但 FbColors.muted 是 Resource($r(...)),返回 string | Resource
会让 fontColor() 报「Type 'string | Resource' is not assignable to 'string'」。
⇒ 改成内联三元,且未选用 FbColors.faint(那个是 string 常量)。
编译通过,已装真机。
2026-11-05 20:25:59 +08:00
..
2026-11-05 20:25:59 +08:00
2026-10-11 22:07:48 +08:00
2026-10-11 22:07:48 +08:00
2026-10-11 22:07:48 +08:00
2026-10-11 22:07:48 +08:00