长按确认光效填充按钮
按住药丸,光团从左侧涌入并过曝成白色,满 2 秒变为对勾并沿轮廓迸出粒子。WebGL 与 React Native Skia 共用一份 SkSL 着色器。
灵感来自 @a_cucos 在 X 上发布的设计由 Now In Code 从零重建
Piece.tsxindex.ts
// Sign in to see the source. Free pieces need a free account.
Agent 提示词
Add the Now In Code component "hold-to-confirm-glow-fill-button" to this project. The full source is attached at the end of this prompt. Put the files under components/hold-to-confirm-glow-fill-button/, install the listed dependencies with `npx expo install`, and render it on a route I can open. Keep the timing and easing values documented in the source comments. Replace the sample copy and artwork with content from my app, or leave placeholders and list what I still need to supply. === Sign in to attach the source files ===
详情
- 平台
- iOS、Android
- 依赖
- Expo SDK 54+
- 权限
- 免费
- 更新于
- 2026年10月8日
- 许可证
- 无限商业项目
- 原始设计
- @a_cucos(X)
你是设计者吗? 请求我们修改或下架此作品.
CLI 与 MCP 服务器 即将推出
在终端添加作品,或让智能体自行获取。在此之前,用“复制提示词”也能做到。 文档
功能说明
两个药丸形按钮,一个用于确认,一个用于破坏性操作。按住药丸时,它会略微收缩,同时光从左边缘被拉入。光在前进时变亮,小火花沿其前沿飘散,文字从“Hold to ...”模糊过渡为“Keep Holding...”。按住两秒后,药丸变白,显示一个对勾和过去式的标签。确认按钮还会从轮廓向外抛出粒子;破坏性按钮刻意不这样做。提前松手会让光收回,按钮在完成后不久自动重置。
实现方式
光效是一个 SkSL 片段着色器,编译为 Skia RuntimeEffect,在 Skia 画布中绘制。纯 JavaScript 核心根据按下和松开事件的日志计算每一帧,组件把该帧映射为视图:着色器画布、用于粒子的 Skia 圆形,以及用于对勾的 SVG 路径。动画由 requestAnimationFrame 循环驱动,而非 Reanimated。React Native 没有 CSS 模糊,因此文字模糊是通过一层清晰文字与一层带文字阴影的透明文字叠加实现的。
适用场景
- 确认删除账户或规则等破坏性操作
- 发送付款或发布等最终提交步骤,单次点按过于容易误触的场景
- 需要用户刻意开启的设置开关
依赖
@shopify/react-native-skiareact-native-svgexpo-hapticsreact-native标签
按钮深色光效辉光渐变长按霓虹科技粒子按压反馈习惯效率状态切换系统界面文字动画