带滚动数字的分段切换器
点选或拖动 Drive、Transit、Walk、Bike 时,白色指示块以前沿领先的弹簧滑动,分钟与到达时间只滚动变化的几位。路线条在实线、点线与换乘段之间伸缩,每个图标演出各自的出行方式。
灵感来自 @dev_ya 在 X 上发布的设计由 Now In Code 从零重建
import { Piece } from "./components";
export function Example() {
const progress = useSharedValue(0);
…
export function Example() {
const progress = useSharedValue(0);
…
Agent 提示词
Add the Now In Code component "segmented-switcher-with-rolling-digits" to this project. The full source is attached at the end of this prompt. Put the files under components/segmented-switcher-with-rolling-digits/, 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. === Source files are attached here for paid plans ===
Pro 作品。提示词包含完整源码。开始使用
详情
- 平台
- iOS、Android、Web
- 依赖
- Expo SDK 54+
- 权限
- Pro
- 更新于
- 2026年11月11日
- 许可证
- 无限商业项目
- 原始设计
- @dev_ya(X)
你是设计者吗? 请求我们修改或下架此作品.
CLI 与 MCP 服务器 即将推出
在终端添加作品,或让智能体自行获取。在此之前,用“复制提示词”也能做到。 文档
功能说明
一张白色的通勤卡片,上面有四段式分段控件,分别为 Drive、Transit、Walk 和 Bike。选择一种出行方式时,白色指示器会滑动过去,并在移动途中略微拉伸,每个图标都会演绎对应的出行方式。行程时间滚动为新的数字,到达时间和路线说明原地变化,路线线条重绘:驾车和骑行为蓝色实线,公共交通为带蓝色伸展段的灰色虚线,步行为蓝色虚线。骑行时会增加一个“Fastest”徽章。按下指示器会使其缩小,拖动时它跟随手指,松手后吸附到最近的出行方式,此时数据才会切换。
实现方式
共享 JavaScript 时间线模块保存出行方式数据和动画状态,React Native 组件用 react-native-svg 绘制,由 requestAnimationFrame 循环推进。指示器使用两个由弹簧驱动的边缘,前缘领先于后缘,从而产生拉伸效果。拖动由 PanResponder 处理。数字位于固定的等宽数字槽位中,因此单位标签不会移动。
适用场景
- 地图或网约车应用中的路线或出行方式选择器
- 数值需要原地更新的套餐或定价切换器
- 任何标签会随指示器经过而产生反应的分段控件
依赖
react-native-svgreact-native标签
卡片拖拽数字滚动数字路径描绘按压反馈弹簧标签页出行旅行